[llvm] r287368 - [MIRPrinter] Print raw branch probabilities as expected by MIRParser
Geoff Berry via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 18 11:37:24 PST 2016
Author: gberry
Date: Fri Nov 18 13:37:24 2016
New Revision: 287368
URL: http://llvm.org/viewvc/llvm-project?rev=287368&view=rev
Log:
[MIRPrinter] Print raw branch probabilities as expected by MIRParser
Fixes PR28751.
Reviewers: MatzeB, qcolombet
Subscribers: mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D26775
Added:
llvm/trunk/test/CodeGen/MIR/Generic/branch-probabilities.ll
Modified:
llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
llvm/trunk/lib/CodeGen/MIRPrinter.cpp
llvm/trunk/test/CodeGen/MIR/X86/newline-handling.mir
llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir
llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks.mir
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=287368&r1=287367&r2=287368&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Fri Nov 18 13:37:24 2016
@@ -488,7 +488,8 @@ bool MIParser::parseBasicBlockSuccessors
lex();
unsigned Weight = 0;
if (consumeIfPresent(MIToken::lparen)) {
- if (Token.isNot(MIToken::IntegerLiteral))
+ if (Token.isNot(MIToken::IntegerLiteral) &&
+ Token.isNot(MIToken::HexLiteral))
return error("expected an integer literal after '('");
if (getUnsigned(Weight))
return true;
Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=287368&r1=287367&r2=287368&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Fri Nov 18 13:37:24 2016
@@ -32,6 +32,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSlotTracker.h"
#include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
@@ -481,7 +482,9 @@ void MIPrinter::print(const MachineBasic
OS << ", ";
printMBBReference(**I);
if (MBB.hasSuccessorProbabilities())
- OS << '(' << MBB.getSuccProbability(I) << ')';
+ OS << '('
+ << format("0x%08" PRIx32, MBB.getSuccProbability(I).getNumerator())
+ << ')';
}
OS << "\n";
HasLineAttributes = true;
Added: llvm/trunk/test/CodeGen/MIR/Generic/branch-probabilities.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/Generic/branch-probabilities.ll?rev=287368&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/Generic/branch-probabilities.ll (added)
+++ llvm/trunk/test/CodeGen/MIR/Generic/branch-probabilities.ll Fri Nov 18 13:37:24 2016
@@ -0,0 +1,26 @@
+; RUN: llc -stop-after machine-sink %s -o %t.mir
+; RUN: FileCheck %s < %t.mir
+; RUN: llc %t.mir -run-pass machine-sink
+; Check that branch probabilities are printed in a format that can then be parsed.
+
+declare void @foo()
+declare void @bar()
+
+define void @test(i1 %c) {
+; CHECK-LABEL: name: test
+entry:
+ br i1 %c, label %then, label %else
+
+then:
+ call void @foo()
+ br label %end
+; CHECK: successors: %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}}), %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}})
+
+else:
+ call void @bar()
+ br label %end
+; CHECK: successors: %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}})
+
+end:
+ ret void
+}
Modified: llvm/trunk/test/CodeGen/MIR/X86/newline-handling.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/newline-handling.mir?rev=287368&r1=287367&r2=287368&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/newline-handling.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/newline-handling.mir Fri Nov 18 13:37:24 2016
@@ -35,7 +35,7 @@ liveins:
# CHECK-LABEL: name: foo
# CHECK: body: |
# CHECK-NEXT: bb.0.entry:
-# CHECK-NEXT: successors: %bb.1.less(0x40000000 / 0x80000000 = 50.00%), %bb.2.exit(0x40000000 / 0x80000000 = 50.00%)
+# CHECK-NEXT: successors: %bb.1.less(0x40000000), %bb.2.exit(0x40000000)
# CHECK-NEXT: liveins: %edi
# CHECK: CMP32ri8 %edi, 10, implicit-def %eflags
# CHECK-NEXT: JG_1 %bb.2.exit, implicit killed %eflags
@@ -79,7 +79,7 @@ liveins:
# CHECK-LABEL: name: bar
# CHECK: body: |
# CHECK-NEXT: bb.0.entry:
-# CHECK-NEXT: successors: %bb.1.less(0x40000000 / 0x80000000 = 50.00%), %bb.2.exit(0x40000000 / 0x80000000 = 50.00%)
+# CHECK-NEXT: successors: %bb.1.less(0x40000000), %bb.2.exit(0x40000000)
# CHECK-NEXT: liveins: %edi
# CHECK: CMP32ri8 %edi, 10, implicit-def %eflags
# CHECK-NEXT: JG_1 %bb.2.exit, implicit killed %eflags
Modified: llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir?rev=287368&r1=287367&r2=287368&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir Fri Nov 18 13:37:24 2016
@@ -21,7 +21,7 @@
name: foo
body: |
; CHECK-LABEL: bb.0.entry:
- ; CHECK: successors: %bb.1.less({{[0-9a-fx/= ]+}}33.00%), %bb.2.exit({{[0-9a-fx/= ]+}}67.00%)
+ ; CHECK: successors: %bb.1.less(0x2a3d70a4), %bb.2.exit(0x55c28f5c)
; CHECK-LABEL: bb.1.less:
bb.0.entry:
successors: %bb.1.less (33), %bb.2.exit(67)
Modified: llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks.mir?rev=287368&r1=287367&r2=287368&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/successor-basic-blocks.mir Fri Nov 18 13:37:24 2016
@@ -32,7 +32,7 @@
name: foo
body: |
; CHECK-LABEL: bb.0.entry:
- ; CHECK: successors: %bb.1.less(0x40000000 / 0x80000000 = 50.00%), %bb.2.exit(0x40000000 / 0x80000000 = 50.00%)
+ ; CHECK: successors: %bb.1.less(0x40000000), %bb.2.exit(0x40000000)
; CHECK-LABEL: bb.1.less:
bb.0.entry:
successors: %bb.1.less, %bb.2.exit
@@ -58,7 +58,7 @@ body: |
; Verify that we can have multiple lists of successors that will be merged
; into one.
; CHECK-LABEL: bb.0.entry:
- ; CHECK: successors: %bb.1(0x80000000 / 0x80000000 = 100.00%), %bb.2(0x00000000 / 0x80000000 = 0.00%)
+ ; CHECK: successors: %bb.1(0x80000000), %bb.2(0x00000000)
bb.0.entry:
liveins: %edi
successors: %bb.1
More information about the llvm-commits
mailing list