The x86 backend allows %rsp to be used as an index register in an address operand. Some assemblers accept this and automatically rewrite it so that %rsp is the base register to make it legal, but some don't, including GAS.
Created attachment 553 [details] test case Compile with llc -march=x86-64 -sched=none and look for ',%rsp)' in the output.
To clarify, you're saying that: leaq 16(%r10,%rsp), %r10 should be: leaq 16(%rsp,%r10), %r10 ?
okay, right. The official syntax is: section:disp(base, index, scale)
This looks like a register coallescing issue. llc -print-machineinstrs shows this after isel: %reg1165 = CMOVS64rr %reg1032, %reg1163 %reg1038 = SUB32rr %reg1025, %reg1024 %reg1034 = MOV64rr %RSP ... %reg1037 = LEA64r %reg1166, 1, %reg1034, 16 %reg1036 = LEA64r %reg1164, 1, %reg1034, 16 When reg1034 is coallesced with RSP, we get the problem.
The most straight-forward way to fix this is in the asmprinter. Addressed with this patch: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070108/042639.html Testcase here: Regression/CodeGen/X86/2007-01-13-StackPtrIndex.ll -Chris