[llvm] r253991 - [ThinLTO] Fix FunctionImport alias checking and test

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 08:10:43 PST 2015


Author: tejohnson
Date: Tue Nov 24 10:10:43 2015
New Revision: 253991

URL: http://llvm.org/viewvc/llvm-project?rev=253991&view=rev
Log:
[ThinLTO] Fix FunctionImport alias checking and test

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.

Modified:
    llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
    llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll
    llvm/trunk/test/Transforms/FunctionImport/funcimport.ll

Modified: llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp?rev=253991&r1=253990&r2=253991&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp Tue Nov 24 10:10:43 2015
@@ -142,11 +142,12 @@ bool FunctionImporter::importFunctions(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;
     }

Modified: llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll?rev=253991&r1=253990&r2=253991&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll Tue Nov 24 10:10:43 2015
@@ -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

Modified: llvm/trunk/test/Transforms/FunctionImport/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport.ll?rev=253991&r1=253990&r2=253991&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport.ll Tue Nov 24 10:10:43 2015
@@ -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
+




More information about the llvm-commits mailing list