[llvm] r254009 - [ThinLTO] Handle previously imported and promoted locals in module linker

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 11:46:59 PST 2015


Author: tejohnson
Date: Tue Nov 24 13:46:58 2015
New Revision: 254009

URL: http://llvm.org/viewvc/llvm-project?rev=254009&view=rev
Log:
[ThinLTO] Handle previously imported and promoted locals in module linker

The new function import pass exposed an issue when we import references
to local values on multiple importing passes. They are renamed on each
import pass, and we need to ensure that the already promoted and renamed
references existing in the dest module are correctly identified and
updated so that they aren't spuriously renamed again (due to a perceived
conflict with the newly linked reference).

Modified:
    llvm/trunk/lib/Linker/LinkModules.cpp
    llvm/trunk/test/Transforms/FunctionImport/funcimport.ll

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=254009&r1=254008&r2=254009&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Nov 24 13:46:58 2015
@@ -517,11 +517,11 @@ private:
   GlobalValue *getLinkedToGlobal(const GlobalValue *SrcGV) {
     // If the source has no name it can't link.  If it has local linkage,
     // there is no name match-up going on.
-    if (!SrcGV->hasName() || SrcGV->hasLocalLinkage())
+    if (!SrcGV->hasName() || GlobalValue::isLocalLinkage(getLinkage(SrcGV)))
       return nullptr;
 
     // Otherwise see if we have a match in the destination module's symtab.
-    GlobalValue *DGV = DstM->getNamedValue(SrcGV->getName());
+    GlobalValue *DGV = DstM->getNamedValue(getName(SrcGV));
     if (!DGV)
       return nullptr;
 

Modified: llvm/trunk/test/Transforms/FunctionImport/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport.ll?rev=254009&r1=254008&r2=254009&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport.ll Tue Nov 24 13:46:58 2015
@@ -43,6 +43,12 @@ declare void @setfuncptr(...) #1
 ; CHECK-DAG: define available_externally void @callfuncptr()
 declare void @callfuncptr(...) #1
 
+; Ensure that all uses of local variable @P which has used in setfuncptr
+; and callfuncptr are to the same promoted/renamed global.
+; CHECK-DAG: @P.llvm.2 = available_externally hidden global void ()* null
+; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.2,
+; CHECK-DAG: store void ()* @staticfunc2.llvm.2, void ()** @P.llvm.2,
+
 ; Won't import weak func
 ; CHECK-DAG: declare void @weakfunc(...)
 declare void @weakfunc(...) #1




More information about the llvm-commits mailing list