mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-07 11:33:44 +00:00
Fix a logic error in ValueIsOnlyUsedLocallyOrStoredToOneGlobal that caused
miscompilation of 188.ammp. Reject select and bitcast in ValueIsOnlyUsedLocallyOrStoredToOneGlobal because RewriteHeapSROALoadUser can't handle it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41950 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ce4e748565
commit
5e6e494a97
@ -813,15 +813,14 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
|
|||||||
static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal(Instruction *V,
|
static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal(Instruction *V,
|
||||||
GlobalVariable *GV,
|
GlobalVariable *GV,
|
||||||
SmallPtrSet<PHINode*, 8> &PHIs) {
|
SmallPtrSet<PHINode*, 8> &PHIs) {
|
||||||
for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI)
|
for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI)
|
||||||
if (isa<LoadInst>(*UI) || isa<CmpInst>(*UI)) {
|
if (isa<LoadInst>(*UI) || isa<CmpInst>(*UI)) {
|
||||||
// Fine, ignore.
|
// Fine, ignore.
|
||||||
} else if (StoreInst *SI = dyn_cast<StoreInst>(*UI)) {
|
} else if (StoreInst *SI = dyn_cast<StoreInst>(*UI)) {
|
||||||
if (SI->getOperand(0) == V && SI->getOperand(1) != GV)
|
if (SI->getOperand(0) == V && SI->getOperand(1) != GV)
|
||||||
return false; // Storing the pointer itself... bad.
|
return false; // Storing the pointer itself... bad.
|
||||||
// Otherwise, storing through it, or storing into GV... fine.
|
// Otherwise, storing through it, or storing into GV... fine.
|
||||||
} else if (isa<GetElementPtrInst>(*UI) || isa<SelectInst>(*UI) ||
|
} else if (isa<GetElementPtrInst>(*UI)) {
|
||||||
isa<BitCastInst>(*UI)) {
|
|
||||||
if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(cast<Instruction>(*UI),
|
if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(cast<Instruction>(*UI),
|
||||||
GV, PHIs))
|
GV, PHIs))
|
||||||
return false;
|
return false;
|
||||||
@ -829,7 +828,8 @@ static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal(Instruction *V,
|
|||||||
// PHIs are ok if all uses are ok. Don't infinitely recurse through PHI
|
// PHIs are ok if all uses are ok. Don't infinitely recurse through PHI
|
||||||
// cycles.
|
// cycles.
|
||||||
if (PHIs.insert(PN))
|
if (PHIs.insert(PN))
|
||||||
return ValueIsOnlyUsedLocallyOrStoredToOneGlobal(PN, GV, PHIs);
|
if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(PN, GV, PHIs))
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user