summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2018-01-09 20:12:42 +0000
committerDaniel Berlin <dberlin@dberlin.org>2018-01-09 20:12:42 +0000
commit56cca7437c1a4c7a8f697e97d9f8b98576b7a97e (patch)
tree18f4b0d65f484f624422fe000765c5622e2d37c7 /llvm/lib/Transforms
parent55662a8e9ffe0de5dc4af244caa1e1a22659aeb9 (diff)
downloadbcm5719-llvm-56cca7437c1a4c7a8f697e97d9f8b98576b7a97e.tar.gz
bcm5719-llvm-56cca7437c1a4c7a8f697e97d9f8b98576b7a97e.zip
NewGVN: Fix PR/33367, which was causing us to delete non-copy intrinsics accidentally in some rare cases
llvm-svn: 322115
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/NewGVN.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 9ebf2d76935..5e6b58055ec 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -4058,7 +4058,8 @@ bool NewGVN::eliminateInstructions(Function &F) {
Value *DominatingLeader = EliminationStack.back();
auto *II = dyn_cast<IntrinsicInst>(DominatingLeader);
- if (II && II->getIntrinsicID() == Intrinsic::ssa_copy)
+ bool isSSACopy = II && II->getIntrinsicID() == Intrinsic::ssa_copy;
+ if (isSSACopy)
DominatingLeader = II->getOperand(0);
// Don't replace our existing users with ourselves.
@@ -4081,7 +4082,9 @@ bool NewGVN::eliminateInstructions(Function &F) {
// It's about to be alive again.
if (LeaderUseCount == 0 && isa<Instruction>(DominatingLeader))
ProbablyDead.erase(cast<Instruction>(DominatingLeader));
- if (LeaderUseCount == 0 && II)
+ // Copy instructions, however, are still dead beacuse we use their
+ // operand as the leader.
+ if (LeaderUseCount == 0 && isSSACopy)
ProbablyDead.insert(II);
++LeaderUseCount;
AnythingReplaced = true;
OpenPOWER on IntegriCloud