[llvm] r254556 - Delete what is now duplicated code.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 2 14:22:25 PST 2015
Author: rafael
Date: Wed Dec 2 16:22:24 2015
New Revision: 254556
URL: http://llvm.org/viewvc/llvm-project?rev=254556&view=rev
Log:
Delete what is now duplicated code.
Having to import an alias as declaration is not thinlto specific.
The test difference are because when we already have a decl and we are
not importing it, we just leave the decl alone.
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
llvm/trunk/test/Linker/funcimport.ll
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=254556&r1=254555&r2=254556&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Dec 2 16:22:24 2015
@@ -791,30 +791,6 @@ Function *ModuleLinker::copyFunctionProt
/// Set up prototypes for any aliases that come over from the source module.
GlobalValue *ModuleLinker::copyGlobalAliasProto(TypeMapTy &TypeMap,
const GlobalAlias *SGA) {
- // If we are importing and encounter a weak_any alias, or an alias to
- // an object being imported as a declaration, we must import the alias
- // as a declaration as well, which involves converting it to a non-alias.
- // See comments in ModuleLinker::getLinkage for why we cannot import
- // weak_any defintions.
- if (isPerformingImport() && !doImportAsDefinition(SGA)) {
- // Need to convert to declaration. All aliases must be definitions.
- const GlobalValue *GVal = SGA->getBaseObject();
- GlobalValue *NewGV;
- if (auto *GVar = dyn_cast<GlobalVariable>(GVal))
- NewGV = copyGlobalVariableProto(TypeMap, GVar);
- else {
- auto *F = dyn_cast<Function>(GVal);
- assert(F);
- NewGV = copyFunctionProto(TypeMap, F);
- }
- // Set the linkage to External or ExternalWeak (see comments in
- // ModuleLinker::getLinkage for why WeakAny is converted to ExternalWeak).
- if (SGA->hasWeakAnyLinkage())
- NewGV->setLinkage(GlobalValue::ExternalWeakLinkage);
- else
- NewGV->setLinkage(GlobalValue::ExternalLinkage);
- return NewGV;
- }
// If there is no linkage to be performed or we're linking from the source,
// bring over SGA.
auto *Ty = TypeMap.get(SGA->getValueType());
@@ -1421,7 +1397,9 @@ bool ModuleLinker::linkGlobalValueProto(
Comdat *C = nullptr;
bool HasUnnamedAddr = SGV->hasUnnamedAddr();
- if (const Comdat *SC = SGV->getComdat()) {
+ if (isPerformingImport() && !doImportAsDefinition(SGV)) {
+ LinkFromSrc = false;
+ } else if (const Comdat *SC = SGV->getComdat()) {
Comdat::SelectionKind SK;
std::tie(SK, LinkFromSrc) = ComdatsChosen[SC];
C = DstM.getOrInsertComdat(SC->getName());
@@ -1454,9 +1432,6 @@ bool ModuleLinker::linkGlobalValueProto(
setVisibility(NewGV, SGV, DGV);
} else {
NewGV = copyGlobalValueProto(TypeMap, SGV, DGV, LinkFromSrc);
-
- if (isPerformingImport() && !doImportAsDefinition(SGV))
- DoNotLinkFromSource.insert(SGV);
}
NewGV->setUnnamedAddr(HasUnnamedAddr);
Modified: llvm/trunk/test/Linker/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/funcimport.ll?rev=254556&r1=254555&r2=254556&view=diff
==============================================================================
--- llvm/trunk/test/Linker/funcimport.ll (original)
+++ llvm/trunk/test/Linker/funcimport.ll Wed Dec 2 16:22:24 2015
@@ -27,36 +27,36 @@
; RUN: llvm-link %t2.bc -functionindex=%t3.thinlto.bc -import=globalfunc1:%t.bc -S | FileCheck %s --check-prefix=IMPORTGLOB1
; IMPORTGLOB1-DAG: define available_externally void @globalfunc1
; IMPORTGLOB1-DAG: declare void @globalfunc2
-; IMPORTGLOB1-DAG: declare extern_weak void @weakalias
+; IMPORTGLOB1-DAG: declare void @weakalias
; IMPORTGLOB1-DAG: declare void @analias
-; IMPORTGLOB1-DAG: declare void @linkoncealias
+; IMPORTGLOB1-DAG: @linkoncealias = external global
; IMPORTGLOB1-NOT: @linkoncefunc
; Ensure that weak alias to a non-imported function is correctly
; turned into a declaration, but that strong alias to an imported function
; is imported as alias.
; RUN: llvm-link %t2.bc -functionindex=%t3.thinlto.bc -import=globalfunc2:%t.bc -S | FileCheck %s --check-prefix=IMPORTGLOB2
-; IMPORTGLOB2-DAG: declare void @analias()
+; IMPORTGLOB2-DAG: declare void @analias
; IMPORTGLOB2-DAG: declare void @globalfunc1
; IMPORTGLOB2-DAG: define available_externally void @globalfunc2
-; IMPORTGLOB2-DAG: declare extern_weak void @weakalias
+; IMPORTGLOB2-DAG: declare void @weakalias
; Ensure that strong alias imported in second pass of importing ends up
; as an alias.
; RUN: llvm-link %t2.bc -functionindex=%t3.thinlto.bc -import=globalfunc1:%t.bc -import=globalfunc2:%t.bc -S | FileCheck %s --check-prefix=IMPORTGLOB3
-; IMPORTGLOB3-DAG: declare void @analias()
+; IMPORTGLOB3-DAG: declare void @analias
; IMPORTGLOB3-DAG: define available_externally void @globalfunc1
; IMPORTGLOB3-DAG: define available_externally void @globalfunc2
-; IMPORTGLOB3-DAG: declare extern_weak void @weakalias
+; IMPORTGLOB3-DAG: declare void @weakalias
; Ensure that strong alias imported in first pass of importing ends up
; as an alias, and that seeing the alias definition during a second inlining
; pass is handled correctly.
; RUN: llvm-link %t2.bc -functionindex=%t3.thinlto.bc -import=globalfunc2:%t.bc -import=globalfunc1:%t.bc -S | FileCheck %s --check-prefix=IMPORTGLOB4
-; IMPORTGLOB4-DAG: declare void @analias()
+; IMPORTGLOB4-DAG: declare void @analias
; IMPORTGLOB4-DAG: define available_externally void @globalfunc2
; IMPORTGLOB4-DAG: define available_externally void @globalfunc1
-; IMPORTGLOB4-DAG: declare extern_weak void @weakalias
+; IMPORTGLOB4-DAG: declare void @weakalias
; An alias to an imported function is imported as alias if the function is not
; available_externally.
Modified: llvm/trunk/test/Transforms/FunctionImport/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport.ll?rev=254556&r1=254555&r2=254556&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport.ll Wed Dec 2 16:22:24 2015
@@ -25,11 +25,11 @@ entry:
}
; Won't import weak alias
-; CHECK-DAG: declare extern_weak void @weakalias()
+; CHECK-DAG: declare void @weakalias
declare void @weakalias(...) #1
; Cannot create an alias to available_externally
-; CHECK-DAG: declare void @analias()
+; CHECK-DAG: declare void @analias
declare void @analias(...) #1
; Aliases import the aliasee function
More information about the llvm-commits
mailing list