diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-09-10 07:31:55 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-09-10 07:31:55 +0000 |
commit | 5647fc5a2dd7b99ac7e87cb2bb78a15293916ec0 (patch) | |
tree | 0269a5854a8dbbadbe06fff81613f64adbf96266 | |
parent | e29983e04407b9fabc807120319474a8729abb52 (diff) | |
download | llvm-5647fc5a2dd7b99ac7e87cb2bb78a15293916ec0.tar.gz |
Merging r371434:
------------------------------------------------------------------------
r371434 | efriedma | 2019-09-09 20:29:27 +0200 (Mon, 09 Sep 2019) | 15 lines
[IfConversion] Correctly handle cases where analyzeBranch fails.
If analyzeBranch fails, on some targets, the out parameters point to
some blocks in the function. But we can't use that information, so make
sure to clear it out. (In some places in IfConversion, we assume that
any block with a TrueBB is analyzable.)
The change to the testcase makes it trigger a bug on builds without this
fix: IfConvertDiamond tries to perform a followup "merge" operation,
which isn't legal, and we somehow end up with a branch to a deleted MBB.
I'm not sure how this doesn't crash the compiler.
Differential Revision: https://reviews.llvm.org/D67306
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_90@371490 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/IfConversion.cpp | 6 | ||||
-rw-r--r-- | test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp index fde3c152e9d9..af556e2c856e 100644 --- a/lib/CodeGen/IfConversion.cpp +++ b/lib/CodeGen/IfConversion.cpp @@ -912,6 +912,12 @@ void IfConverter::AnalyzeBranches(BBInfo &BBI) { BBI.BrCond.clear(); BBI.IsBrAnalyzable = !TII->analyzeBranch(*BBI.BB, BBI.TrueBB, BBI.FalseBB, BBI.BrCond); + if (!BBI.IsBrAnalyzable) { + BBI.TrueBB = nullptr; + BBI.FalseBB = nullptr; + BBI.BrCond.clear(); + } + SmallVector<MachineOperand, 4> RevCond(BBI.BrCond.begin(), BBI.BrCond.end()); BBI.IsBrReversible = (RevCond.size() == 0) || !TII->reverseBranchCondition(RevCond); diff --git a/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir b/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir index 576362184031..a2218b149f1b 100644 --- a/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir +++ b/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir @@ -1,4 +1,4 @@ -# RUN: llc %s -o - -run-pass=if-converter | FileCheck %s +# RUN: llc %s -o - -run-pass=if-converter -verify-machineinstrs | FileCheck %s # Make sure we correctly if-convert blocks containing an INLINEASM_BR. # CHECK: t2CMPri killed renamable $r2, 34 # CHECK-NEXT: $r0 = t2MOVi 2, 1, $cpsr, $noreg @@ -48,9 +48,8 @@ body: | t2B %bb.3, 14, $noreg bb.3: - successors: %bb.4(0x80000000) - INLINEASM &"", 1 + $sp = t2LDMIA_RET $sp, 14, $noreg, def $r4, def $pc bb.4.l_yes (address-taken): $sp = t2LDMIA_RET $sp, 14, $noreg, def $r4, def $pc |