summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2015-11-24 19:46:58 +0000
committerTeresa Johnson <tejohnson@google.com>2015-11-24 19:46:58 +0000
commitb098f0c133e6b9a8168def5a1942ea66e7712928 (patch)
treeb975c77de378543ff4bb1b70cd0b0f20f2e8252b /llvm
parent6a829f78f90b28494ac6ce36cc6a2bca50ce00e4 (diff)
downloadbcm5719-llvm-b098f0c133e6b9a8168def5a1942ea66e7712928.tar.gz
bcm5719-llvm-b098f0c133e6b9a8168def5a1942ea66e7712928.zip
[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). llvm-svn: 254009
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Linker/LinkModules.cpp4
-rw-r--r--llvm/test/Transforms/FunctionImport/funcimport.ll6
2 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index f97bbe5a8e5..8970fe44613 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -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;
diff --git a/llvm/test/Transforms/FunctionImport/funcimport.ll b/llvm/test/Transforms/FunctionImport/funcimport.ll
index 8d790520e33..43b2fb7919d 100644
--- a/llvm/test/Transforms/FunctionImport/funcimport.ll
+++ b/llvm/test/Transforms/FunctionImport/funcimport.ll
@@ -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
OpenPOWER on IntegriCloud