Fix PR3666: isel calls to constant addresses.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 4 Mar 2009 06:48:53 +0000 (06:48 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 4 Mar 2009 06:48:53 +0000 (06:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66024 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/X86Instr64bit.td
lib/Target/X86/X86InstrInfo.td
test/CodeGen/X86/call-imm.ll [new file with mode: 0644]

index 5fff5b9a0f3419698fe412abf7f3cc219b64e9ab..0595b6fbd1390e511db766afbad4a4a6cfe0186c 100644 (file)
@@ -307,7 +307,9 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
   }
 
   case MachineOperand::MO_Immediate:
-    if (!Modifier ||
+    if (Modifier && !strcmp(Modifier, "call"))
+      O << '*';
+    else if (!Modifier ||
         (strcmp(Modifier, "debug") && strcmp(Modifier, "mem")))
       O << '$';
     O << MO.getImm();
index 38a16135cdfba65beec8c86bdc2537c267b4565c..88a4f477b900cd5ef0c5d0bdd9d7a208b290f45d 100644 (file)
@@ -109,8 +109,10 @@ let isCall = 1 in
               XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
               XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
       Uses = [RSP] in {
-    def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops),
-                          "call\t${dst:call}", []>;
+    def CALL64pcrel32 : I<0xE8, RawFrm,
+                          (outs), (ins i64i32imm:$dst, variable_ops),
+                          "call\t${dst:call}", [(X86call imm:$dst)]>,
+                        Requires<[In64BitMode]>;
     def CALL64r       : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
                           "call\t{*}$dst", [(X86call GR64:$dst)]>;
     def CALL64m       : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
index 93f9e02802215d589f31a0ff2042dafe177aa438..f9585b0810965724f120ba93fbee10c167b8aeae 100644 (file)
@@ -489,7 +489,8 @@ let isCall = 1 in
               XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
       Uses = [ESP] in {
     def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
-                           "call\t${dst:call}", []>;
+                           "call\t${dst:call}", [(X86call imm:$dst)]>,
+                      Requires<[In32BitMode]>;
     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),
diff --git a/test/CodeGen/X86/call-imm.ll b/test/CodeGen/X86/call-imm.ll
new file mode 100644 (file)
index 0000000..25b911f
--- /dev/null
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | llc -march=x86    | grep call | grep 12345678
+; RUN: llvm-as < %s | llc -march=x86-64 | grep call | grep 12345678
+; PR3666
+
+define i32 @main() nounwind {
+entry:
+       %0 = call i32 inttoptr (i32 12345678 to i32 (i32)*)(i32 0) nounwind             ; <i32> [#uses=1]
+       ret i32 %0
+}