-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Description
Bugzilla Link | 1062 |
Resolution | FIXED |
Resolved on | Feb 22, 2010 12:55 |
Version | 1.9 |
OS | Linux |
Extended Description
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(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();