summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorMikael Holmen <mikael.holmen@ericsson.com>2017-12-01 12:30:49 +0000
committerMikael Holmen <mikael.holmen@ericsson.com>2017-12-01 12:30:49 +0000
commit9f047795fbf0e9ed760e78c496179cb9552865d7 (patch)
treeb400f3a5e2e589d10c1d8a3f698181b734eabf8d /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent11edb4eeef299452b8e83d96e3c042b001ec803e (diff)
downloadbcm5719-llvm-9f047795fbf0e9ed760e78c496179cb9552865d7.tar.gz
bcm5719-llvm-9f047795fbf0e9ed760e78c496179cb9552865d7.zip
Bail out of a SimplifyCFG switch table opt at undef values.
Summary: A true or false result is expected from a comparison, but it seems the possibility of undef was overlooked, which could lead to a failed assert. This is fixed by this patch by bailing out if we encounter undef. The bug is old and the assert has been there since the end of 2014, so it seems this is unusual enough to forego optimization. Patch by: JesperAntonsson Reviewers: spatel, eeckstein, hans Reviewed By: hans Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40639 llvm-svn: 319537
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 8f1626a149a..394c951630c 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -5174,7 +5174,7 @@ static void reuseTableCompare(
for (auto ValuePair : Values) {
Constant *CaseConst = ConstantExpr::getICmp(CmpInst->getPredicate(),
ValuePair.second, CmpOp1, true);
- if (!CaseConst || CaseConst == DefaultConst)
+ if (!CaseConst || CaseConst == DefaultConst || isa<UndefValue>(CaseConst))
return;
assert((CaseConst == TrueConst || CaseConst == FalseConst) &&
"Expect true or false as compare result.");
OpenPOWER on IntegriCloud