mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-24 08:24:33 +00:00
* Fix bug: test/Regression/Other/2002-03-11-LevelRaiseIterInvalidate.ll
* Use more concise form of ReplaceInstWithInst to make code simpler * Output nicer message for dead code eliminated when debugging git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1861 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -85,25 +85,19 @@ static bool HandleCastToPointer(BasicBlock::iterator BI,
|
|||||||
|
|
||||||
// If we have a getelementptr capability... transform all of the
|
// If we have a getelementptr capability... transform all of the
|
||||||
// add instruction uses into getelementptr's.
|
// add instruction uses into getelementptr's.
|
||||||
for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end();
|
while (!CI->use_empty()) {
|
||||||
UI != E; ++UI) {
|
Instruction *I = cast<Instruction>(*CI->use_begin());
|
||||||
Instruction *I = cast<Instruction>(*UI);
|
|
||||||
assert(I->getOpcode() == Instruction::Add && I->getNumOperands() == 2 &&
|
assert(I->getOpcode() == Instruction::Add && I->getNumOperands() == 2 &&
|
||||||
"Use is not a valid add instruction!");
|
"Use is not a valid add instruction!");
|
||||||
|
|
||||||
// Get the value added to the cast result pointer...
|
// Get the value added to the cast result pointer...
|
||||||
Value *OtherPtr = I->getOperand((I->getOperand(0) == CI) ? 1 : 0);
|
Value *OtherPtr = I->getOperand((I->getOperand(0) == CI) ? 1 : 0);
|
||||||
|
|
||||||
BasicBlock *BB = I->getParent();
|
|
||||||
BasicBlock::iterator AddIt = find(BB->getInstList().begin(),
|
|
||||||
BB->getInstList().end(), I);
|
|
||||||
|
|
||||||
GetElementPtrInst *GEP = new GetElementPtrInst(OtherPtr, Indices);
|
GetElementPtrInst *GEP = new GetElementPtrInst(OtherPtr, Indices);
|
||||||
|
|
||||||
PRINT_PEEPHOLE1("cast-add-to-gep:i", I);
|
PRINT_PEEPHOLE1("cast-add-to-gep:i", I);
|
||||||
|
|
||||||
// Replace the old add instruction with the shiny new GEP inst
|
// Replace the old add instruction with the shiny new GEP inst
|
||||||
ReplaceInstWithInst(BB->getInstList(), AddIt, GEP);
|
ReplaceInstWithInst(I, GEP);
|
||||||
PRINT_PEEPHOLE1("cast-add-to-gep:o", GEP);
|
PRINT_PEEPHOLE1("cast-add-to-gep:o", GEP);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -417,7 +411,7 @@ static bool DoRaisePass(Method *M) {
|
|||||||
if (dceInstruction(BIL, BI) || doConstantPropogation(BB, BI)) {
|
if (dceInstruction(BIL, BI) || doConstantPropogation(BB, BI)) {
|
||||||
Changed = true;
|
Changed = true;
|
||||||
#ifdef DEBUG_PEEPHOLE_INSTS
|
#ifdef DEBUG_PEEPHOLE_INSTS
|
||||||
cerr << "DeadCode Elinated!\n";
|
cerr << "***\t\t^^-- DeadCode Elinated!\n";
|
||||||
#endif
|
#endif
|
||||||
} else if (PeepholeOptimize(BB, BI))
|
} else if (PeepholeOptimize(BB, BI))
|
||||||
Changed = true;
|
Changed = true;
|
||||||
|
Reference in New Issue
Block a user