diff options
author | Cong Hou <congh@google.com> | 2015-12-01 00:55:42 +0000 |
---|---|---|
committer | Cong Hou <congh@google.com> | 2015-12-01 00:55:42 +0000 |
commit | 1ccca9e6731d9b18c5901abd0ebc0b5d5f71d84a (patch) | |
tree | 6144edab422d813ef8ddb94c04d211b36f1e463d /llvm/lib/CodeGen | |
parent | 242b948817a0dc6456d7f9711b152608aa39f603 (diff) | |
download | bcm5719-llvm-1ccca9e6731d9b18c5901abd0ebc0b5d5f71d84a.tar.gz bcm5719-llvm-1ccca9e6731d9b18c5901abd0ebc0b5d5f71d84a.zip |
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.
llvm-svn: 254356
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index ddddd483e80..fcddf346cf6 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -423,9 +423,13 @@ MachineBlockPlacement::selectBestSuccessor(MachineBasicBlock *BB, 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 |