mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
Fix a bug where we would evaluate stores into linkonce objects which could be
potentially replaced at link-time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23463 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cd27142cc8
commit
231308c545
@ -1239,13 +1239,18 @@ static Constant *getVal(std::map<Value*, Constant*> &ComputedValues,
|
||||
/// we punt. We basically just support direct accesses to globals and GEP's of
|
||||
/// globals. This should be kept up to date with CommitValueTo.
|
||||
static bool isSimpleEnoughPointerToCommit(Constant *C) {
|
||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
|
||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
||||
if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
|
||||
return false; // do not allow weak/linkonce linkage.
|
||||
return !GV->isExternal(); // reject external globals.
|
||||
}
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
||||
// Handle a constantexpr gep.
|
||||
if (CE->getOpcode() == Instruction::GetElementPtr &&
|
||||
isa<GlobalVariable>(CE->getOperand(0))) {
|
||||
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
|
||||
if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
|
||||
return false; // do not allow weak/linkonce linkage.
|
||||
return GV->hasInitializer() &&
|
||||
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user