Skip to content

Commit

Permalink
Factor two calls to a common location.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254967 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Dec 7, 2015
1 parent b69b6b5 commit e826a2e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/Linker/LinkModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ class ModuleLinker {

/// Handles cloning of a global values from the source module into
/// the destination module, including setting the attributes and visibility.
GlobalValue *copyGlobalValueProto(const GlobalValue *SGV,
const GlobalValue *DGV, bool ForDefinition);
GlobalValue *copyGlobalValueProto(const GlobalValue *SGV, bool ForDefinition);

/// Check if we should promote the given local value to global scope.
bool doPromoteLocalToGlobal(const GlobalValue *SGV);
Expand Down Expand Up @@ -816,7 +815,6 @@ void ModuleLinker::setVisibility(GlobalValue *NewGV, const GlobalValue *SGV,
}

GlobalValue *ModuleLinker::copyGlobalValueProto(const GlobalValue *SGV,
const GlobalValue *DGV,
bool ForDefinition) {
GlobalValue *NewGV;
if (auto *SGVar = dyn_cast<GlobalVariable>(SGV)) {
Expand All @@ -842,7 +840,6 @@ GlobalValue *ModuleLinker::copyGlobalValueProto(const GlobalValue *SGV,
NewGV->setLinkage(GlobalValue::ExternalWeakLinkage);

copyGVAttributes(NewGV, SGV);
setVisibility(NewGV, SGV, DGV);
return NewGV;
}

Expand Down Expand Up @@ -1364,18 +1361,17 @@ Constant *ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) {
GlobalValue *NewGV;
if (!LinkFromSrc && DGV) {
NewGV = DGV;
// When linking from source we setVisibility from copyGlobalValueProto.
setVisibility(NewGV, SGV, DGV);
} else {
// If we are done linking global value bodies (i.e. we are performing
// metadata linking), don't link in the global value due to this
// reference, simply map it to null.
if (DoneLinkingBodies)
return nullptr;

NewGV = copyGlobalValueProto(SGV, DGV, LinkFromSrc);
NewGV = copyGlobalValueProto(SGV, LinkFromSrc);
}

setVisibility(NewGV, SGV, DGV);
NewGV->setUnnamedAddr(HasUnnamedAddr);

if (auto *NewGO = dyn_cast<GlobalObject>(NewGV)) {
Expand Down

0 comments on commit e826a2e

Please sign in to comment.