Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%rsp emitted as an index register #1475

Closed
sunfishcode opened this issue Jan 10, 2007 · 5 comments
Closed

%rsp emitted as an index register #1475

sunfishcode opened this issue Jan 10, 2007 · 5 comments
Assignees
Labels
backend:X86 bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead

Comments

@sunfishcode
Copy link
Member

Bugzilla Link 1103
Resolution FIXED
Resolved on Feb 22, 2010 12:51
Version 1.9
OS Linux
Attachments test case

Extended Description

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.

@sunfishcode
Copy link
Member Author

assigned to @lattner

@lattner
Copy link
Collaborator

lattner commented Jan 14, 2007

To clarify, you're saying that:
leaq 16(%r10,%rsp), %r10

should be:

leaq 16(%rsp,%r10), %r10

?

@lattner
Copy link
Collaborator

lattner commented Jan 14, 2007

okay, right. The official syntax is:
section:disp(base, index, scale)

@lattner
Copy link
Collaborator

lattner commented Jan 14, 2007

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.

@lattner
Copy link
Collaborator

lattner commented Jan 14, 2007

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

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead
Projects
None yet
Development

No branches or pull requests

2 participants