summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHiroshi Inoue <inouehrs@jp.ibm.com>2018-09-28 05:27:32 +0000
committerHiroshi Inoue <inouehrs@jp.ibm.com>2018-09-28 05:27:32 +0000
commit69bfa402006fa7fabe6eaf1660c9ecacb763a966 (patch)
tree97708202b9130d1603ba14586af4eaa90182268a
parent73d18aa028b367ef68c543f15f10427a4d1cb471 (diff)
downloadbcm5719-llvm-69bfa402006fa7fabe6eaf1660c9ecacb763a966.tar.gz
bcm5719-llvm-69bfa402006fa7fabe6eaf1660c9ecacb763a966.zip
[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 llvm-svn: 343297
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp2
-rw-r--r--llvm/test/Other/X86/mbb-dump.ll25
2 files changed, 26 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index c60270559fa..0b9ee462d1a 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -362,7 +362,7 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST,
// 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) << '('
diff --git a/llvm/test/Other/X86/mbb-dump.ll b/llvm/test/Other/X86/mbb-dump.ll
new file mode 100644
index 00000000000..382e8166181
--- /dev/null
+++ b/llvm/test/Other/X86/mbb-dump.ll
@@ -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
+}
OpenPOWER on IntegriCloud