mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-22 09:29:31 +00:00
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
This commit is contained in:
parent
58f462fe5c
commit
dd6794f01d
@ -1045,6 +1045,14 @@ bool ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) {
|
|||||||
NewGO->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
|
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.
|
// Make sure to remember this mapping.
|
||||||
if (NewGV != DGV) {
|
if (NewGV != DGV) {
|
||||||
if (DGV) {
|
if (DGV) {
|
||||||
@ -1062,21 +1070,8 @@ bool ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) {
|
|||||||
GlobalValue *ModuleLinker::linkGlobalVariableProto(const GlobalVariable *SGVar,
|
GlobalValue *ModuleLinker::linkGlobalVariableProto(const GlobalVariable *SGVar,
|
||||||
GlobalValue *DGV,
|
GlobalValue *DGV,
|
||||||
bool LinkFromSrc) {
|
bool LinkFromSrc) {
|
||||||
bool ClearConstant = false;
|
if (!LinkFromSrc)
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
return DGV;
|
return DGV;
|
||||||
}
|
|
||||||
|
|
||||||
// No linking to be performed or linking from the source: simply create an
|
// No linking to be performed or linking from the source: simply create an
|
||||||
// identical version of the symbol over in the dest module... the
|
// identical version of the symbol over in the dest module... the
|
||||||
|
Loading…
Reference in New Issue
Block a user