[llvm-branch-commits] [llvm-branch] r371377 - Merging r371111:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 9 02:08:44 PDT 2019


Author: hans
Date: Mon Sep  9 02:08:44 2019
New Revision: 371377

URL: http://llvm.org/viewvc/llvm-project?rev=371377&view=rev
Log:
Merging r371111:
------------------------------------------------------------------------
r371111 | efriedma | 2019-09-05 22:02:38 +0200 (Thu, 05 Sep 2019) | 17 lines

[IfConversion] Fix diamond conversion with unanalyzable branches.

The code was incorrectly counting the number of identical instructions,
and therefore tried to predicate an instruction which should not have
been predicated.  This could have various effects: a compiler crash,
an assembler failure, a miscompile, or just generating an extra,
unnecessary instruction.

Instead of depending on TargetInstrInfo::removeBranch, which only
works on analyzable branches, just remove all branch instructions.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43121 and
https://bugs.llvm.org/show_bug.cgi?id=41121 .

Differential Revision: https://reviews.llvm.org/D67203


------------------------------------------------------------------------

Added:
    llvm/branches/release_90/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir
      - copied unchanged from r371111, llvm/trunk/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir
Modified:
    llvm/branches/release_90/   (props changed)
    llvm/branches/release_90/lib/CodeGen/IfConversion.cpp

Propchange: llvm/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep  9 02:08:44 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,370720-370721,370753,371048,371088,371095,371262
+/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,370720-370721,370753,371048,371088,371095,371111,371262

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=371377&r1=371376&r2=371377&view=diff
==============================================================================
--- llvm/branches/release_90/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/branches/release_90/lib/CodeGen/IfConversion.cpp Mon Sep  9 02:08:44 2019
@@ -1758,9 +1758,15 @@ bool IfConverter::IfConvertDiamondCommon
   if (!BBI1->IsBrAnalyzable)
     verifySameBranchInstructions(&MBB1, &MBB2);
 #endif
-  BBI1->NonPredSize -= TII->removeBranch(*BBI1->BB);
-  // Remove duplicated instructions.
+  // Remove duplicated instructions from the tail of MBB1: any branch
+  // instructions, and the common instructions counted by NumDups2.
   DI1 = MBB1.end();
+  while (DI1 != MBB1.begin()) {
+    MachineBasicBlock::iterator Prev = std::prev(DI1);
+    if (!Prev->isBranch() && !Prev->isDebugInstr())
+      break;
+    DI1 = Prev;
+  }
   for (unsigned i = 0; i != NumDups2; ) {
     // NumDups2 only counted non-dbg_value instructions, so this won't
     // run off the head of the list.




More information about the llvm-branch-commits mailing list