diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-12-05 16:05:19 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-12-05 16:05:19 +0000 |
commit | 879aeb776c0bdba49e2de9f02eb7aae279e54542 (patch) | |
tree | 2d4f6c68696b89b9b4cf78927386567e18b3a9a7 /llvm/lib/Linker/LinkModules.cpp | |
parent | 85fb8c7abd0ee53d5c510e394390a4f676f7a954 (diff) | |
download | bcm5719-llvm-879aeb776c0bdba49e2de9f02eb7aae279e54542.tar.gz bcm5719-llvm-879aeb776c0bdba49e2de9f02eb7aae279e54542.zip |
Small cleanup on how we clear constant variables. NFC.
llvm-svn: 223474
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 561b02136b8..4aa0b88df5b 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -1045,6 +1045,14 @@ bool ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) { NewGO->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment())); } + if (auto *NewGVar = dyn_cast<GlobalVariable>(NewGV)) { + auto *DGVar = dyn_cast_or_null<GlobalVariable>(DGV); + auto *SGVar = dyn_cast<GlobalVariable>(SGV); + if (DGVar && SGVar && DGVar->isDeclaration() && SGVar->isDeclaration() && + (!DGVar->isConstant() || !SGVar->isConstant())) + NewGVar->setConstant(false); + } + // Make sure to remember this mapping. if (NewGV != DGV) { if (DGV) { @@ -1062,21 +1070,8 @@ bool ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) { GlobalValue *ModuleLinker::linkGlobalVariableProto(const GlobalVariable *SGVar, GlobalValue *DGV, bool LinkFromSrc) { - bool ClearConstant = false; - - if (DGV) { - auto *DGVar = dyn_cast<GlobalVariable>(DGV); - if (!SGVar->isConstant() || (DGVar && !DGVar->isConstant())) - ClearConstant = true; - } - - if (!LinkFromSrc) { - if (auto *NewGVar = dyn_cast<GlobalVariable>(DGV)) { - if (NewGVar->isDeclaration() && ClearConstant) - NewGVar->setConstant(false); - } + if (!LinkFromSrc) return DGV; - } // No linking to be performed or linking from the source: simply create an // identical version of the symbol over in the dest module... the |