[PATCH] D52605: [CodeGen] avoid broken successor probability in MBB dump

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 27 05:02:03 PDT 2018


inouehrs created this revision.
inouehrs added reviewers: MatzeB, thegameg.
inouehrs edited the summary of this revision.

When printing successor probabilities for a MBB, a human readble value is somethimes shown as 200%.
The human readble output is based on `getProbabilityIterator`, which returns 0xFFFFFFFF for getNumerator() and 0x80000000 for getDenominator() for unknown BranchProbability.
By using getSuccProbability as we do for the non-human readable part, we can avoid this problem.

Example of broken probability

  bb.1.if.then:
  ; predecessors: %bb.0
    successors: %bb.3(0x80000000); %bb.3(200.00%)


https://reviews.llvm.org/D52605

Files:
  lib/CodeGen/MachineBasicBlock.cpp


Index: lib/CodeGen/MachineBasicBlock.cpp
===================================================================
--- lib/CodeGen/MachineBasicBlock.cpp
+++ lib/CodeGen/MachineBasicBlock.cpp
@@ -362,7 +362,7 @@
       // Print human readable probabilities as comments.
       OS << "; ";
       for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
-        const BranchProbability &BP = *getProbabilityIterator(I);
+        const BranchProbability &BP = getSuccProbability(I);
         if (I != succ_begin())
           OS << ", ";
         OS << printMBBReference(**I) << '('


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52605.167278.patch
Type: text/x-patch
Size: 577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180927/b3745637/attachment.bin>


More information about the llvm-commits mailing list