From: Rafael Espindola Date: Mon, 7 Dec 2015 23:32:39 +0000 (+0000) Subject: Factor two calls to a common location. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=e826a2ef86c0e89c60d7a4fa792dbbb0358e030e;hp=b69b6b56339cffdb675817ff4bab206254141bbe Factor two calls to a common location. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254967 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 3e1416d8d50..a2bc9560221 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -451,8 +451,7 @@ private: /// 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); @@ -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(SGV)) { @@ -842,7 +840,6 @@ GlobalValue *ModuleLinker::copyGlobalValueProto(const GlobalValue *SGV, NewGV->setLinkage(GlobalValue::ExternalWeakLinkage); copyGVAttributes(NewGV, SGV); - setVisibility(NewGV, SGV, DGV); return NewGV; } @@ -1364,8 +1361,6 @@ 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 @@ -1373,9 +1368,10 @@ Constant *ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) { 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(NewGV)) {