Cannot use immediate as call absolute target in PIC mode.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 20 May 2009 01:11:00 +0000 (01:11 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 20 May 2009 01:11:00 +0000 (01:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72154 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrInfo.td
test/CodeGen/X86/call-imm.ll

index 1ebe67f7e4c974e8b763ee860082a70aa46884cd..10eddf0f110d88cecf8c615a39e19e3322e0142a 100644 (file)
@@ -234,6 +234,7 @@ def In64BitMode  : Predicate<"Subtarget->is64Bit()">;
 def SmallCode    : Predicate<"TM.getCodeModel() == CodeModel::Small">;
 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
 def IsStatic     : Predicate<"TM.getRelocationModel() == Reloc::Static">;
+def IsNotPIC     : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
 def OptForSpeed  : Predicate<"!OptForSize">;
 def FastBTMem    : Predicate<"!Subtarget->isBTMemSlow()">;
 
@@ -562,7 +563,7 @@ let isCall = 1 in
       Uses = [ESP] in {
     def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
                            "call\t${dst:call}", [(X86call imm:$dst)]>,
-                      Requires<[In32BitMode]>;
+                      Requires<[In32BitMode, IsNotPIC]>;
     def CALL32r     : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
                         "call\t{*}$dst", [(X86call GR32:$dst)]>;
     def CALL32m     : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
index 8233d8698ab04f1ca3b1f3f39fd113981aab3f02..b22b65eaea270d605b9260da0a75944f574a9c02 100644 (file)
@@ -1,4 +1,5 @@
 ; RUN: llvm-as < %s | llc -march=x86    | grep {call.*12345678}
+; RUN: llvm-as < %s | llc -march=x86 -relocation-model=pic | not grep {call.*12345678}
 
 ; Call to immediate is not safe on x86-64 unless we *know* that the
 ; call will be within 32-bits pcrel from the dest immediate.
@@ -7,6 +8,7 @@
 
 ; PR3666
 ; PR3773
+; rdar://6904453
 
 define i32 @main() nounwind {
 entry: