Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit dd6794f

Browse files
committed
Small cleanup on how we clear constant variables. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223474 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 58f462f commit dd6794f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

lib/Linker/LinkModules.cpp

+9-14
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,14 @@ bool ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) {
10451045
NewGO->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
10461046
}
10471047

1048+
if (auto *NewGVar = dyn_cast<GlobalVariable>(NewGV)) {
1049+
auto *DGVar = dyn_cast_or_null<GlobalVariable>(DGV);
1050+
auto *SGVar = dyn_cast<GlobalVariable>(SGV);
1051+
if (DGVar && SGVar && DGVar->isDeclaration() && SGVar->isDeclaration() &&
1052+
(!DGVar->isConstant() || !SGVar->isConstant()))
1053+
NewGVar->setConstant(false);
1054+
}
1055+
10481056
// Make sure to remember this mapping.
10491057
if (NewGV != DGV) {
10501058
if (DGV) {
@@ -1062,21 +1070,8 @@ bool ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) {
10621070
GlobalValue *ModuleLinker::linkGlobalVariableProto(const GlobalVariable *SGVar,
10631071
GlobalValue *DGV,
10641072
bool LinkFromSrc) {
1065-
bool ClearConstant = false;
1066-
1067-
if (DGV) {
1068-
auto *DGVar = dyn_cast<GlobalVariable>(DGV);
1069-
if (!SGVar->isConstant() || (DGVar && !DGVar->isConstant()))
1070-
ClearConstant = true;
1071-
}
1072-
1073-
if (!LinkFromSrc) {
1074-
if (auto *NewGVar = dyn_cast<GlobalVariable>(DGV)) {
1075-
if (NewGVar->isDeclaration() && ClearConstant)
1076-
NewGVar->setConstant(false);
1077-
}
1073+
if (!LinkFromSrc)
10781074
return DGV;
1079-
}
10801075

10811076
// No linking to be performed or linking from the source: simply create an
10821077
// identical version of the symbol over in the dest module... the

0 commit comments

Comments
 (0)