mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-09 10:31:14 +00:00
Enhance RecursivelyDeleteTriviallyDeadInstructions to optionally
return a list of deleted instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60193 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a0d4486073
commit
4f02c74a8e
@ -24,7 +24,7 @@ class PHINode;
|
|||||||
class AllocaInst;
|
class AllocaInst;
|
||||||
class ConstantExpr;
|
class ConstantExpr;
|
||||||
class TargetData;
|
class TargetData;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Local constant propagation.
|
// Local constant propagation.
|
||||||
//
|
//
|
||||||
@ -49,7 +49,11 @@ bool isInstructionTriviallyDead(Instruction *I);
|
|||||||
/// RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a
|
/// RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a
|
||||||
/// trivially dead instruction, delete it. If that makes any of its operands
|
/// trivially dead instruction, delete it. If that makes any of its operands
|
||||||
/// trivially dead, delete them too, recursively.
|
/// trivially dead, delete them too, recursively.
|
||||||
void RecursivelyDeleteTriviallyDeadInstructions(Value *V);
|
///
|
||||||
|
/// If DeadInst is specified, the vector is filled with the instructions that
|
||||||
|
/// are actually deleted.
|
||||||
|
void RecursivelyDeleteTriviallyDeadInstructions(Value *V,
|
||||||
|
SmallVectorImpl<Instruction*> *DeadInst = 0);
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Control Flow Graph Restructuring...
|
// Control Flow Graph Restructuring...
|
||||||
|
@ -176,7 +176,11 @@ bool llvm::isInstructionTriviallyDead(Instruction *I) {
|
|||||||
/// RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a
|
/// RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a
|
||||||
/// trivially dead instruction, delete it. If that makes any of its operands
|
/// trivially dead instruction, delete it. If that makes any of its operands
|
||||||
/// trivially dead, delete them too, recursively.
|
/// trivially dead, delete them too, recursively.
|
||||||
void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) {
|
///
|
||||||
|
/// If DeadInst is specified, the vector is filled with the instructions that
|
||||||
|
/// are actually deleted.
|
||||||
|
void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V,
|
||||||
|
SmallVectorImpl<Instruction*> *DeadInst) {
|
||||||
Instruction *I = dyn_cast<Instruction>(V);
|
Instruction *I = dyn_cast<Instruction>(V);
|
||||||
if (!I || !I->use_empty()) return;
|
if (!I || !I->use_empty()) return;
|
||||||
|
|
||||||
@ -186,12 +190,16 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) {
|
|||||||
while (!Insts.empty()) {
|
while (!Insts.empty()) {
|
||||||
I = *Insts.begin();
|
I = *Insts.begin();
|
||||||
Insts.erase(I);
|
Insts.erase(I);
|
||||||
if (isInstructionTriviallyDead(I)) {
|
if (!isInstructionTriviallyDead(I))
|
||||||
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
continue;
|
||||||
if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
|
|
||||||
Insts.insert(U);
|
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
||||||
I->eraseFromParent();
|
if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
|
||||||
}
|
Insts.insert(U);
|
||||||
|
I->eraseFromParent();
|
||||||
|
|
||||||
|
if (DeadInst)
|
||||||
|
DeadInst->push_back(I);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user