[llvm] r255638 - Improve the successor list update in TailDuplication.cpp.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 02:10:40 PST 2015


Author: conghou
Date: Tue Dec 15 04:10:40 2015
New Revision: 255638

URL: http://llvm.org/viewvc/llvm-project?rev=255638&view=rev
Log:
Improve the successor list update in TailDuplication.cpp.

This patch improves a temporary fix in r255530 so that we can normalize
successor list without trigger assertion failures in tail duplication pass.


Modified:
    llvm/trunk/lib/CodeGen/TailDuplication.cpp
    llvm/trunk/test/CodeGen/ARM/taildup-branch-weight.ll

Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=255638&r1=255637&r2=255638&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Tue Dec 15 04:10:40 2015
@@ -745,12 +745,12 @@ TailDuplicatePass::duplicateSimpleBB(Mac
     if (PredTBB)
       TII->InsertBranch(*PredBB, PredTBB, PredFBB, PredCond, DebugLoc());
 
-    auto Prob = MBPI->getEdgeProbability(PredBB, TailBB);
-    PredBB->removeSuccessor(TailBB);
-    unsigned NumSuccessors = PredBB->succ_size();
-    assert(NumSuccessors <= 1);
-    if (NumSuccessors == 0 || *PredBB->succ_begin() != NewTarget)
-      PredBB->addSuccessor(NewTarget, Prob);
+    if (!PredBB->isSuccessor(NewTarget))
+      PredBB->replaceSuccessor(TailBB, NewTarget);
+    else {
+      PredBB->removeSuccessor(TailBB, 0);
+      assert(PredBB->succ_size() <= 1);
+    }
 
     TDBBs.push_back(PredBB);
   }

Modified: llvm/trunk/test/CodeGen/ARM/taildup-branch-weight.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/taildup-branch-weight.ll?rev=255638&r1=255637&r2=255638&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/taildup-branch-weight.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/taildup-branch-weight.ll Tue Dec 15 04:10:40 2015
@@ -30,7 +30,7 @@ B4:
 !0 = !{!"branch_weights", i32 4, i32 124}
 
 ; CHECK: Machine code for function test1:
-; CHECK: Successors according to CFG: BB#1({{[0-9a-fx/= ]+}}3.12%) BB#2({{[0-9a-fx/= ]+}}96.88%)
+; CHECK: Successors according to CFG: BB#2(0x7c000000 / 0x80000000 = 96.88%) BB#1(0x04000000 / 0x80000000 = 3.12%)
 
 @g0 = common global i32 0, align 4
 




More information about the llvm-commits mailing list