summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-02-21 17:32:05 +0000
committerDuncan Sands <baldrick@free.fr>2011-02-21 17:32:05 +0000
commitecbbf0825b874c0605517f621adb8ee635a74ea1 (patch)
tree77e10333d67cdd4f139b2539a8a3bb4712b5aad8 /llvm/lib/Transforms/Utils
parentf5bfc46c95a3a91efc27f811d13257b405b15a6f (diff)
downloadbcm5719-llvm-ecbbf0825b874c0605517f621adb8ee635a74ea1.tar.gz
bcm5719-llvm-ecbbf0825b874c0605517f621adb8ee635a74ea1.zip
If the phi node was used by an unreachable instruction that ends up using
itself without going via a phi node then we could return false here in spite of making a change. Also, tweak the comment because this method can (and always could) return true without deleting the original phi node. For example, if the phi node was used by a read-only invoke instruction which is used by another phi node phi2 which is only used by and only uses the invoke, then phi2 would be deleted but not the invoke instruction and not the original phi node. llvm-svn: 126129
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 40a56b0c99a..3f789fa8658 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -282,7 +282,7 @@ static bool areAllUsesEqual(Instruction *I) {
/// dead PHI node, due to being a def-use chain of single-use nodes that
/// 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. Return true if the PHI node is actually deleted.
+/// too, recursively. Return true if a change was made.
bool llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) {
SmallPtrSet<Instruction*, 4> Visited;
for (Instruction *I = PN; areAllUsesEqual(I) && !I->mayHaveSideEffects();
@@ -295,7 +295,8 @@ bool llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) {
if (!Visited.insert(I)) {
// Break the cycle and delete the instruction and its operands.
I->replaceAllUsesWith(UndefValue::get(I->getType()));
- return RecursivelyDeleteTriviallyDeadInstructions(I);
+ (void)RecursivelyDeleteTriviallyDeadInstructions(I);
+ return true;
}
}
return false;
OpenPOWER on IntegriCloud