[LLVMbugs] [Bug 1062] NEW: address constants forced to registers in small-model static-reloc x86-64

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Dec 19 10:22:53 PST 2006


http://llvm.org/bugs/show_bug.cgi?id=1062

           Summary: address constants forced to registers in small-model
                    static-reloc x86-64
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: djg at cray.com


Weak, extern and linkonce symbols are currently excluded from address
operands in x86-64 with the small memory model and static linking.

With this test case:

%x = external global int

implementation

int %foo(long %i) {
        %a = getelementptr int* %x, long %i
        %t = load int* %a
        ret int %t
}

Currently llc -march=x86-64 -code-model=small -relocation-model=static
emits this:

        leaq x(%rip), %rcx
        movl (%rcx,%rax,4), %eax

I believe should emit this:

        movl x(,%rax,4), %eax

Unless I'm missing something, it should be safe to let llc do this,
with the following patch.

Index: X86ISelDAGToDAG.cpp
===================================================================
RCS file: /var/cvs/llvm/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp,v
retrieving revision 1.138
diff -u -r1.138 X86ISelDAGToDAG.cpp
--- X86ISelDAGToDAG.cpp
+++ X86ISelDAGToDAG.cpp
@@ -604,9 +604,7 @@
       SDOperand N0 = N.getOperand(0);
       if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(N0)) {
         GlobalValue *GV = G->getGlobal();
-        bool isAbs32 = !is64Bit ||
-          (isStatic && !(GV->isExternal() || GV->hasWeakLinkage() ||
-                         GV->hasLinkOnceLinkage()));
+        bool isAbs32 = !is64Bit || isStatic;
         if (isAbs32 || isRoot) {
           AM.GV = G->getGlobal();
           AM.Disp += G->getOffset();



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the llvm-bugs mailing list