diff options
author | Dan Gohman <gohman@apple.com> | 2009-05-03 05:46:20 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-05-03 05:46:20 +0000 |
commit | 5036695c32835ad0fb280b9d20f9214f5270dfb0 (patch) | |
tree | 611a881c018a3620022de19c72bd293785cf274c /llvm/lib/Transforms/Utils/Local.cpp | |
parent | 7d79a5f87dcd6ab25607315c894325088949b299 (diff) | |
download | bcm5719-llvm-5036695c32835ad0fb280b9d20f9214f5270dfb0.tar.gz bcm5719-llvm-5036695c32835ad0fb280b9d20f9214f5270dfb0.zip |
Revert r70645 for now; it's causing a variety of regressions.
llvm-svn: 70661
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index fea739cb46b..3b36362bb39 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -178,10 +178,18 @@ bool llvm::isInstructionTriviallyDead(Instruction *I) { return false; } +/// ~ValueDeletionListener - A trivial dtor, defined out of line to give the +/// class a home. +llvm::ValueDeletionListener::~ValueDeletionListener() {} + /// RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a /// trivially dead instruction, delete it. If that makes any of its operands /// trivially dead, delete them too, recursively. -void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) { +/// +/// If a ValueDeletionListener is specified, it is notified of instructions that +/// are actually deleted (before they are actually deleted). +void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V, + ValueDeletionListener *VDL) { Instruction *I = dyn_cast<Instruction>(V); if (!I || !I->use_empty() || !isInstructionTriviallyDead(I)) return; @@ -193,6 +201,10 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) { I = DeadInsts.back(); DeadInsts.pop_back(); + // If the client wanted to know, tell it about deleted instructions. + if (VDL) + VDL->ValueWillBeDeleted(I); + // Null out all of the instruction's operands to see if any operand becomes // dead as we go. for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { @@ -218,8 +230,11 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) { /// either forms a cycle or is terminated by a trivially dead instruction, /// delete it. If that makes any of its operands trivially dead, delete them /// too, recursively. +/// +/// If a ValueDeletionListener is specified, it is notified of instructions that +/// are actually deleted (before they are actually deleted). void -llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) { +llvm::RecursivelyDeleteDeadPHINode(PHINode *PN, ValueDeletionListener *VDL) { // We can remove a PHI if it is on a cycle in the def-use graph // where each node in the cycle has degree one, i.e. only one use, @@ -238,7 +253,7 @@ llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) { if (!PHIs.insert(cast<PHINode>(JP))) { // Break the cycle and delete the PHI and its operands. JP->replaceAllUsesWith(UndefValue::get(JP->getType())); - RecursivelyDeleteTriviallyDeadInstructions(JP); + RecursivelyDeleteTriviallyDeadInstructions(JP, VDL); break; } } |