diff options
author | Valentin Churavy <v.churavy@gmail.com> | 2019-12-14 10:33:30 -0500 |
---|---|---|
committer | Valentin Churavy <v.churavy@gmail.com> | 2019-12-16 04:23:32 -0500 |
commit | 5c29e8c65fe372b0239f32b38a0299d9abef3167 (patch) | |
tree | 934ab5083e1d5ecfd74e8d9f5d4359c921c1d3d3 /llvm/lib/CodeGen | |
parent | 049f9672d8566f0d0a115f11e2a53018ea502b10 (diff) | |
download | bcm5719-llvm-5c29e8c65fe372b0239f32b38a0299d9abef3167.tar.gz bcm5719-llvm-5c29e8c65fe372b0239f32b38a0299d9abef3167.zip |
[CodegenPrepare] Guard against degenerate branches
Summary:
Guard against a potential crash observed in https://github.com/JuliaLang/julia/issues/32994#issuecomment-524249628
If two branches are collapsed we can encounter a degenerate conditional branch `TBB==FBB`.
The subsequent code assumes that they differ, so we exit out early.
Reviewers: ributzka, spatel
Subscribers: loladiro, dexonsmith, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66657
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 0f44b8f69b7..f05afd05874 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -7345,6 +7345,10 @@ bool CodeGenPrepare::splitBranchCondition(Function &F, bool &ModifiedDT) { if (Br1->getMetadata(LLVMContext::MD_unpredictable)) continue; + // The merging of mostly empty BB can cause a degenerate branch. + if (TBB == FBB) + continue; + unsigned Opc; Value *Cond1, *Cond2; if (match(LogicOp, m_And(m_OneUse(m_Value(Cond1)), |