Author: hans Date: Tue Sep 10 00:31:55 2019 New Revision: 371490 URL: http://llvm.org/viewvc/llvm-project?rev=371490&view=rev Log: 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 ------------------------------------------------------------------------ Modified: llvm/branches/release_90/ (props changed) llvm/branches/release_90/lib/CodeGen/IfConversion.cpp llvm/branches/release_90/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir Propchange: llvm/branches/release_90/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Sep 10 00:31:55 2019 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,366431,366447,366481,366487,366527,366570,366660,366868,366925,367019,367030,367062,367084,367124,367215,367292,367304,367306,367314,367340-367341,367394,367396,367398,367403,367412,367417,367429,367580,367662,367750,367753,367846-367847,367898,367941,368004,368164,368230,368300,368315,368324,368477-368478,368517-368519,368554,368572,368873,369011,369026,369084,369095,369097,369168,369199,369310,369426,369443,369886,370036,370176,370204,370271,370355,370404,370426,370430,370592,370720-370721,370753,371048,371088,371095,371111,371221,371224,371262,371305,371307 +/llvm/trunk:155241,366431,366447,366481,366487,366527,366570,366660,366868,366925,367019,367030,367062,367084,367124,367215,367292,367304,367306,367314,367340-367341,367394,367396,367398,367403,367412,367417,367429,367580,367662,367750,367753,367846-367847,367898,367941,368004,368164,368230,368300,368315,368324,368477-368478,368517-368519,368554,368572,368873,369011,369026,369084,369095,369097,369168,369199,369310,369426,369443,369886,370036,370176,370204,370271,370355,370404,370426,370430,370592,370720-370721,370753,371048,371088,371095,371111,371221,371224,371262,371305,371307,371434 Modified: llvm/branches/release_90/lib/CodeGen/IfConversion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/lib/CodeGen/IfConversion.cpp?rev=371490&r1=371489&r2=371490&view=diff ============================================================================== --- llvm/branches/release_90/lib/CodeGen/IfConversion.cpp (original) +++ llvm/branches/release_90/lib/CodeGen/IfConversion.cpp Tue Sep 10 00:31:55 2019 @@ -912,6 +912,12 @@ void IfConverter::AnalyzeBranches(BBInfo 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); Modified: llvm/branches/release_90/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir?rev=371490&r1=371489&r2=371490&view=diff ============================================================================== --- llvm/branches/release_90/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir (original) +++ llvm/branches/release_90/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir Tue Sep 10 00:31:55 2019 @@ -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 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits