Target/X86/X86FastISel: [PR6275] Fix Win32's dllimport function with fastisel.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 21 Feb 2011 04:50:06 +0000 (04:50 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 21 Feb 2011 04:50:06 +0000 (04:50 +0000)
"dllimport" function must not be GlobalVariable, but Function. It is enough to check with GlobalValue.
test/CodeGen/X86/dll-linkage.ll is updated to check llc -O0.

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

lib/Target/X86/X86FastISel.cpp
test/CodeGen/X86/dll-linkage.ll

index 9d42ac2e470c2ccf63be6b44fba931918446c8d1..6fa928462b28ad0a49ce47d33eff352925fb91fe 100644 (file)
@@ -597,9 +597,13 @@ bool X86FastISel::X86SelectCallAddress(const Value *V, X86AddressMode &AM) {
         (AM.Base.Reg != 0 || AM.IndexReg != 0))
       return false;
 
-    // Can't handle TLS or DLLImport.
+    // Can't handle DLLImport.
+    if (GV->hasDLLImportLinkage())
+      return false;
+
+    // Can't handle TLS.
     if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV))
-      if (GVar->isThreadLocal() || GVar->hasDLLImportLinkage())
+      if (GVar->isThreadLocal())
         return false;
 
     // Okay, we've committed to selecting this global. Set up the basic address.
index 913617585206b5c0261dcfa67195581626dac7a6..a0c2a54a99a468a841325edaa92e51296d2ec86a 100644 (file)
@@ -1,9 +1,14 @@
 ; RUN: llc < %s -mtriple=i386-pc-mingw32 | FileCheck %s
 
+; RUN: llc < %s -mtriple=i386-pc-mingw32 -O0 | FileCheck %s -check-prefix=FAST
+; PR6275
+
 declare dllimport void @foo()
 
 define void @bar() nounwind {
 ; CHECK: calll *__imp__foo
+; FAST:  movl   __imp__foo, [[R:%[a-z]{3}]]
+; FAST:  calll  *[[R]]
   call void @foo()
   ret void
 }