forked from OSchip/llvm-project
Temporarily revert r60195. It's causing an optimized bootstrap of llvm-gcc to fail.
llvm-svn: 60233
This commit is contained in:
parent
e4d32791ef
commit
469e3aa696
|
@ -240,30 +240,31 @@ Value *LoopStrengthReduce::getCastedVersionOf(Instruction::CastOps opcode,
|
||||||
/// their operands subsequently dead.
|
/// their operands subsequently dead.
|
||||||
void LoopStrengthReduce::
|
void LoopStrengthReduce::
|
||||||
DeleteTriviallyDeadInstructions(SetVector<Instruction*> &Insts) {
|
DeleteTriviallyDeadInstructions(SetVector<Instruction*> &Insts) {
|
||||||
SmallVector<Instruction*, 16> DeadInsts;
|
|
||||||
|
|
||||||
while (!Insts.empty()) {
|
while (!Insts.empty()) {
|
||||||
Instruction *I = Insts.back();
|
Instruction *I = Insts.back();
|
||||||
Insts.pop_back();
|
Insts.pop_back();
|
||||||
|
|
||||||
// If I is dead, delete it and all the things that it recursively uses
|
|
||||||
// that become dead.
|
|
||||||
RecursivelyDeleteTriviallyDeadInstructions(I, &DeadInsts);
|
|
||||||
|
|
||||||
if (DeadInsts.empty()) continue;
|
|
||||||
Changed = true;
|
|
||||||
|
|
||||||
while (!DeadInsts.empty()) {
|
if (PHINode *PN = dyn_cast<PHINode>(I)) {
|
||||||
Instruction *DeadInst = DeadInsts.back();
|
// If all incoming values to the Phi are the same, we can replace the Phi
|
||||||
DeadInsts.pop_back();
|
// with that value.
|
||||||
|
if (Value *PNV = PN->hasConstantValue()) {
|
||||||
// Make sure ScalarEvolutions knows this instruction is gone.
|
if (Instruction *U = dyn_cast<Instruction>(PNV))
|
||||||
SE->deleteValueFromRecords(DeadInst);
|
Insts.insert(U);
|
||||||
|
SE->deleteValueFromRecords(PN);
|
||||||
// Make sure that this instruction is removed from DeadInsts if it was
|
PN->replaceAllUsesWith(PNV);
|
||||||
// recursively removed.
|
PN->eraseFromParent();
|
||||||
if (DeadInst != I)
|
Changed = true;
|
||||||
Insts.remove(DeadInst);
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInstructionTriviallyDead(I)) {
|
||||||
|
for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
|
||||||
|
if (Instruction *U = dyn_cast<Instruction>(*i))
|
||||||
|
Insts.insert(U);
|
||||||
|
SE->deleteValueFromRecords(I);
|
||||||
|
I->eraseFromParent();
|
||||||
|
Changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue