summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-04-10 22:25:36 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-04-10 22:25:36 +0000
commitb4bf14ceaad62093878999a02409ac6a94b82b01 (patch)
tree4bbeb999840b9735041c50db83eb2ab7022a190f
parentf66d73708bace05a5436985d8954da027068982f (diff)
downloadbcm5719-llvm-b4bf14ceaad62093878999a02409ac6a94b82b01.tar.gz
bcm5719-llvm-b4bf14ceaad62093878999a02409ac6a94b82b01.zip
[CodeGenPrepare] Report all changes made during instruction sinking
r234638 chained another transform below which was tripping over the deleted instruction. Use after free found by asan in many regression tests. llvm-svn: 234654
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index d101f52b6ec..937b9261120 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -693,11 +693,11 @@ static bool SinkCast(CastInst *CI) {
InsertedCast =
CastInst::Create(CI->getOpcode(), CI->getOperand(0), CI->getType(), "",
InsertPt);
- MadeChange = true;
}
// Replace a use of the cast with a use of the new cast.
TheUse = InsertedCast;
+ MadeChange = true;
++NumCastUses;
}
@@ -834,17 +834,19 @@ static bool SinkCmpExpression(CmpInst *CI) {
CmpInst::Create(CI->getOpcode(),
CI->getPredicate(), CI->getOperand(0),
CI->getOperand(1), "", InsertPt);
- MadeChange = true;
}
// Replace a use of the cmp with a use of the new cmp.
TheUse = InsertedCmp;
+ MadeChange = true;
++NumCmpUses;
}
// If we removed all uses, nuke the cmp.
- if (CI->use_empty())
+ if (CI->use_empty()) {
CI->eraseFromParent();
+ MadeChange = true;
+ }
return MadeChange;
}
OpenPOWER on IntegriCloud