Accept RIP-relative symbols with 'i' constraint, and
authorDale Johannesen <dalej@apple.com>
Tue, 6 Jul 2010 23:27:00 +0000 (23:27 +0000)
committerDale Johannesen <dalej@apple.com>
Tue, 6 Jul 2010 23:27:00 +0000 (23:27 +0000)
print the (%rip) only if the 'a' modifier is present.
PR 7528.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107727 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/2010-07-06-asm-RIP.ll [new file with mode: 0644]

index f0b6bb371adb5a2925a422de9d577365191d8208..73bc603f18f13b285458bf7affa00418f56ce326 100644 (file)
@@ -388,6 +388,8 @@ bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
       } 
       if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol()) {
         printSymbolOperand(MO, O);
+        if (Subtarget->isPICStyleRIPRel())
+          O << "(%rip)";
         return false;
       }
       if (MO.isReg()) {
index e982a9360ba51ae3b04778c3e7b23424b8573f37..66917ad14bac27a1a9bf5ee41a91b4520082a2cd 100644 (file)
@@ -10264,8 +10264,7 @@ void X86TargetLowering::LowerAsmOperandForConstraint(SDValue Op,
     // In any sort of PIC mode addresses need to be computed at runtime by
     // adding in a register or some sort of table lookup.  These can't
     // be used as immediates.
-    if (Subtarget->isPICStyleGOT() || Subtarget->isPICStyleStubPIC() ||
-        Subtarget->isPICStyleRIPRel())
+    if (Subtarget->isPICStyleGOT() || Subtarget->isPICStyleStubPIC())
       return;
 
     // If we are in non-pic codegen mode, we allow the address of a global (with
diff --git a/test/CodeGen/X86/2010-07-06-asm-RIP.ll b/test/CodeGen/X86/2010-07-06-asm-RIP.ll
new file mode 100644 (file)
index 0000000..f646afa
--- /dev/null
@@ -0,0 +1,21 @@
+; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
+; PR 7528
+
+@n = global i32 0                                 ; <i32*> [#uses=2]
+
+define void @f(i32*) nounwind ssp {
+  ret void
+}
+
+define void @g() nounwind ssp {
+entry:
+; CHECK: _g:
+; CHECK: push $_f$_f
+; CHECK: call _f(%rip)
+  call void asm sideeffect "push\09$1$1\0A\09call\09${1:a}\0A\09pop\09%edx", "imr,i,~{dirflag},~{fpsr},~{flags},~{memory},~{cc},~{edi},~{esi},~{edx},~{ecx},~{ebx},~{eax}"(i32* @n, void (i32*)* @f) nounwind
+  br label %return
+
+return:                                           ; preds = %entry
+  ret void
+}
+