[llvm] r343297 - [CodeGen] fix broken successor probability in MBB dump
Hiroshi Inoue via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 27 22:27:33 PDT 2018
Author: inouehrs
Date: Thu Sep 27 22:27:32 2018
New Revision: 343297
URL: http://llvm.org/viewvc/llvm-project?rev=343297&view=rev
Log:
[CodeGen] fix broken successor probability in MBB dump
When printing successor probabilities for a MBB, a human readable value is sometimes shown as 200.0%.
The human readable 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.
Differential Revision: https://reviews.llvm.org/D52605
Added:
llvm/trunk/test/Other/X86/mbb-dump.ll
Modified:
llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=343297&r1=343296&r2=343297&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Thu Sep 27 22:27:32 2018
@@ -362,7 +362,7 @@ void MachineBasicBlock::print(raw_ostrea
// 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) << '('
Added: llvm/trunk/test/Other/X86/mbb-dump.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/X86/mbb-dump.ll?rev=343297&view=auto
==============================================================================
--- llvm/trunk/test/Other/X86/mbb-dump.ll (added)
+++ llvm/trunk/test/Other/X86/mbb-dump.ll Thu Sep 27 22:27:32 2018
@@ -0,0 +1,25 @@
+; RUN: llc < %s 2>&1 -print-after=machine-scheduler -mtriple=x86_64-unknown-unknown | FileCheck %s
+
+; expected MBB dump output
+; # *** IR Dump After Machine Instruction Scheduler ***:
+; # Machine code for function foo: NoPHIs, TracksLiveness
+;
+; 0B bb.0 (%ir-block.0):
+; successors: %bb.1(0x80000000); %bb.1(100.00%)
+;
+; 16B bb.1.next:
+; ; predecessors: %bb.0
+
+; previously, it was broken as
+; successors: %bb.1(0x80000000); %bb.1(200.00%)
+
+define void @foo(){
+; CHECK: IR Dump After Machine Instruction Scheduler
+; CHECK: bb.0
+; CHECK: 100.0
+; CHECK: bb.1
+ br label %next
+
+next:
+ ret void
+}
More information about the llvm-commits
mailing list