[llvm] r254356 - Fix a bug in MachineBlockPlacement that may cause assertion failure during BranchProbability construction.
Cong Hou via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 30 16:55:42 PST 2015
Author: conghou
Date: Mon Nov 30 18:55:42 2015
New Revision: 254356
URL: http://llvm.org/viewvc/llvm-project?rev=254356&view=rev
Log:
Fix a bug in MachineBlockPlacement that may cause assertion failure during BranchProbability construction.
The root cause is the rounding behavior in BranchProbability construction. We may consider to use truncation instead in the future.
Modified:
llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
Modified: llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp?rev=254356&r1=254355&r2=254356&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp Mon Nov 30 18:55:42 2015
@@ -423,9 +423,13 @@ MachineBlockPlacement::selectBestSuccess
DEBUG(dbgs() << "Attempting merge from: " << getBlockName(BB) << "\n");
for (MachineBasicBlock *Succ : Successors) {
- BranchProbability SuccProb(
- MBPI->getEdgeProbability(BB, Succ).getNumerator(),
- AdjustedSumProb.getNumerator());
+ BranchProbability SuccProb;
+ uint32_t SuccProbN = MBPI->getEdgeProbability(BB, Succ).getNumerator();
+ uint32_t SuccProbD = AdjustedSumProb.getNumerator();
+ if (SuccProbN >= SuccProbD)
+ SuccProb = BranchProbability::getOne();
+ else
+ SuccProb = BranchProbability(SuccProbN, SuccProbD);
// If we outline optional branches, look whether Succ is unavoidable, i.e.
// dominates all terminators of the MachineFunction. If it does, other
More information about the llvm-commits
mailing list