[ThinLTO] Fix FunctionImport alias checking and test
authorTeresa Johnson <tejohnson@google.com>
Tue, 24 Nov 2015 16:10:43 +0000 (16:10 +0000)
committerTeresa Johnson <tejohnson@google.com>
Tue, 24 Nov 2015 16:10:43 +0000 (16:10 +0000)
Skip imports for weak_any aliases as well. Fix the test to check
non-import of weak aliases and functions, and import of normal alias.

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

lib/Transforms/IPO/FunctionImport.cpp
test/Transforms/FunctionImport/Inputs/funcimport.ll
test/Transforms/FunctionImport/funcimport.ll

index 725796790ea7997f9b720853b0f65cc11bb4e185..c874e4f5da769303d908030dbe8b9b1622786623 100644 (file)
@@ -142,11 +142,12 @@ bool FunctionImporter::importFunctions(Module &M) {
       llvm_unreachable("Can't load function in Module");
     }
 
-    // We cannot import weak_any functions without possibly affecting the
-    // order they are seen and selected by the linker, changing program
+    // We cannot import weak_any functions/aliases without possibly affecting
+    // the order they are seen and selected by the linker, changing program
     // semantics.
-    if (F->hasWeakAnyLinkage()) {
-      DEBUG(dbgs() << "Ignoring import request for weak-any function "
+    if (SGV->hasWeakAnyLinkage()) {
+      DEBUG(dbgs() << "Ignoring import request for weak-any "
+                   << (isa<Function>(SGV) ? "function " : "alias ")
                    << CalledFunctionName << " from " << FileName << "\n");
       continue;
     }
index c0298b55ea42daf274973301e61883ac4f0bbbcf..96555892fe3c65520ae2a6b2457bc7ea4e5966ba 100644 (file)
@@ -74,12 +74,6 @@ entry:
   ret void
 }
 
-define void @callweakfunc() #0 {
-entry:
-  call void @weakfunc()
-  ret void
-}
-
 define internal i32 @staticfunc() #0 {
 entry:
   ret i32 1
index c9a376aca532ba03d59f6e6013e5e964ea52a3e3..8d790520e33379c0289817f1bd05dc2c4ffc3530 100644 (file)
@@ -15,12 +15,17 @@ entry:
   %call2 = call i32 (...) @referencecommon()
   call void (...) @setfuncptr()
   call void (...) @callfuncptr()
-  call void (...) @callweakfunc()
+  call void (...) @weakfunc()
   ret i32 0
 }
 
-; Won't import alias
+; Won't import weak alias
+; CHECK-DAG: declare extern_weak void @weakalias()
 declare void @weakalias(...) #1
+
+; Aliases import the aliasee function
+; CHECK-DAG: @analias = alias void (...), bitcast (void ()* @globalfunc2 to void (...)*)
+; CHECK-DAG: define available_externally void @globalfunc2()
 declare void @analias(...) #1
 
 ; CHECK-DAG: define available_externally i32 @referencestatics(i32 %i)
@@ -39,4 +44,6 @@ declare void @setfuncptr(...) #1
 declare void @callfuncptr(...) #1
 
 ; Won't import weak func
-declare void @callweakfunc(...) #1
+; CHECK-DAG: declare void @weakfunc(...)
+declare void @weakfunc(...) #1
+