Index: include/llvm/Support/BranchProbability.h =================================================================== --- include/llvm/Support/BranchProbability.h +++ include/llvm/Support/BranchProbability.h @@ -70,6 +70,7 @@ BranchProbability getCompl() const { return BranchProbability(D - N); } raw_ostream &print(raw_ostream &OS) const; + raw_ostream &printRaw(raw_ostream &OS) const; void dump() const; Index: lib/CodeGen/MIRPrinter.cpp =================================================================== --- lib/CodeGen/MIRPrinter.cpp +++ lib/CodeGen/MIRPrinter.cpp @@ -480,8 +480,11 @@ if (I != MBB.succ_begin()) OS << ", "; printMBBReference(**I); - if (MBB.hasSuccessorProbabilities()) - OS << '(' << MBB.getSuccProbability(I) << ')'; + if (MBB.hasSuccessorProbabilities()) { + OS << '('; + MBB.getSuccProbability(I).printRaw(OS); + OS << ')'; + } } OS << "\n"; HasLineAttributes = true; Index: lib/Support/BranchProbability.cpp =================================================================== --- lib/Support/BranchProbability.cpp +++ lib/Support/BranchProbability.cpp @@ -34,6 +34,10 @@ LLVM_DUMP_METHOD void BranchProbability::dump() const { print(dbgs()) << '\n'; } +raw_ostream &BranchProbability::printRaw(raw_ostream &OS) const { + return OS << N; +} + BranchProbability::BranchProbability(uint32_t Numerator, uint32_t Denominator) { assert(Denominator > 0 && "Denominator cannot be 0!"); assert(Numerator <= Denominator && "Probability cannot be bigger than 1!"); Index: test/CodeGen/MIR/Generic/branch-probabilities.ll =================================================================== --- /dev/null +++ test/CodeGen/MIR/Generic/branch-probabilities.ll @@ -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\-\.]+}}({{[0-9]+}}), %{{[a-z0-9\-\.]+}}({{[0-9]+}}) + +else: + call void @bar() + br label %end +; CHECK: successors: %{{[a-z0-9\-\.]+}}({{[0-9]+}}) + +end: + ret void +} Index: test/CodeGen/MIR/X86/newline-handling.mir =================================================================== --- test/CodeGen/MIR/X86/newline-handling.mir +++ test/CodeGen/MIR/X86/newline-handling.mir @@ -35,7 +35,7 @@ # 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(1073741824), %bb.2.exit(1073741824) # 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 @@ # 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(1073741824), %bb.2.exit(1073741824) # CHECK-NEXT: liveins: %edi # CHECK: CMP32ri8 %edi, 10, implicit-def %eflags # CHECK-NEXT: JG_1 %bb.2.exit, implicit killed %eflags Index: test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir =================================================================== --- test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir +++ test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir @@ -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(708669604), %bb.2.exit(1438814044) ; CHECK-LABEL: bb.1.less: bb.0.entry: successors: %bb.1.less (33), %bb.2.exit(67) Index: test/CodeGen/MIR/X86/successor-basic-blocks.mir =================================================================== --- test/CodeGen/MIR/X86/successor-basic-blocks.mir +++ test/CodeGen/MIR/X86/successor-basic-blocks.mir @@ -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(1073741824), %bb.2.exit(1073741824) ; CHECK-LABEL: bb.1.less: bb.0.entry: successors: %bb.1.less, %bb.2.exit @@ -58,7 +58,7 @@ ; 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(2147483648), %bb.2(0) bb.0.entry: liveins: %edi successors: %bb.1