forked from OSchip/llvm-project
parent
f0eb568021
commit
1c731fa86f
|
@ -1358,13 +1358,8 @@ static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV,
|
||||||
static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
|
static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
|
||||||
Module::global_iterator &GVI,
|
Module::global_iterator &GVI,
|
||||||
TargetData &TD) {
|
TargetData &TD) {
|
||||||
if (BitCastInst *CI = dyn_cast<BitCastInst>(StoredOnceVal))
|
// Ignore no-op GEPs and bitcasts.
|
||||||
StoredOnceVal = CI->getOperand(0);
|
StoredOnceVal = StoredOnceVal->stripPointerCasts();
|
||||||
else if (GetElementPtrInst *GEPI =dyn_cast<GetElementPtrInst>(StoredOnceVal)){
|
|
||||||
// "getelementptr Ptr, 0, 0, 0" is really just a cast.
|
|
||||||
if (GEPI->hasAllZeroIndices())
|
|
||||||
StoredOnceVal = GEPI->getOperand(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we are dealing with a pointer global that is initialized to null and
|
// If we are dealing with a pointer global that is initialized to null and
|
||||||
// only has one (non-null) value stored into it, then we can optimize any
|
// only has one (non-null) value stored into it, then we can optimize any
|
||||||
|
|
Loading…
Reference in New Issue