mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-25 00:33:15 +00:00
Simplify this code by using hasDefinitiveInitializer().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81161 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b73e4aec2e
commit
fd54a898be
@ -2024,20 +2024,21 @@ static Constant *getVal(DenseMap<Value*, Constant*> &ComputedValues,
|
|||||||
/// we punt. We basically just support direct accesses to globals and GEP's of
|
/// we punt. We basically just support direct accesses to globals and GEP's of
|
||||||
/// globals. This should be kept up to date with CommitValueTo.
|
/// globals. This should be kept up to date with CommitValueTo.
|
||||||
static bool isSimpleEnoughPointerToCommit(Constant *C, LLVMContext &Context) {
|
static bool isSimpleEnoughPointerToCommit(Constant *C, LLVMContext &Context) {
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
|
||||||
if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage())
|
// Do not allow weak/linkonce/dllimport/dllexport linkage or
|
||||||
return false; // do not allow weak/linkonce/dllimport/dllexport linkage.
|
// external globals.
|
||||||
return !GV->isDeclaration(); // reject external globals.
|
return GV->hasDefinitiveInitializer();
|
||||||
}
|
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
||||||
// Handle a constantexpr gep.
|
// Handle a constantexpr gep.
|
||||||
if (CE->getOpcode() == Instruction::GetElementPtr &&
|
if (CE->getOpcode() == Instruction::GetElementPtr &&
|
||||||
isa<GlobalVariable>(CE->getOperand(0))) {
|
isa<GlobalVariable>(CE->getOperand(0))) {
|
||||||
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
|
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
|
||||||
if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage())
|
// Do not allow weak/linkonce/dllimport/dllexport linkage or
|
||||||
return false; // do not allow weak/linkonce/dllimport/dllexport linkage.
|
// external globals.
|
||||||
return GV->hasInitializer() &&
|
if (!GV->hasDefinitiveInitializer())
|
||||||
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE,
|
return false;
|
||||||
|
return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE,
|
||||||
Context);
|
Context);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user