llvm.org GIT mirror llvm / 181c24a
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287368 91177308-0d34-0410-b5e6-96231b3b80d8 Geoff Berry 3 years ago
6 changed file(s) with 37 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
487487 lex();
488488 unsigned Weight = 0;
489489 if (consumeIfPresent(MIToken::lparen)) {
490 if (Token.isNot(MIToken::IntegerLiteral))
490 if (Token.isNot(MIToken::IntegerLiteral) &&
491 Token.isNot(MIToken::HexLiteral))
491492 return error("expected an integer literal after '('");
492493 if (getUnsigned(Weight))
493494 return true;
3131 #include "llvm/IR/Module.h"
3232 #include "llvm/IR/ModuleSlotTracker.h"
3333 #include "llvm/MC/MCSymbol.h"
34 #include "llvm/Support/Format.h"
3435 #include "llvm/Support/MemoryBuffer.h"
3536 #include "llvm/Support/YAMLTraits.h"
3637 #include "llvm/Support/raw_ostream.h"
480481 OS << ", ";
481482 printMBBReference(**I);
482483 if (MBB.hasSuccessorProbabilities())
483 OS << '(' << MBB.getSuccProbability(I) << ')';
484 OS << '('
485 << format("0x%08" PRIx32, MBB.getSuccProbability(I).getNumerator())
486 << ')';
484487 }
485488 OS << "\n";
486489 HasLineAttributes = true;
0 ; RUN: llc -stop-after machine-sink %s -o %t.mir
1 ; RUN: FileCheck %s < %t.mir
2 ; RUN: llc %t.mir -run-pass machine-sink
3 ; Check that branch probabilities are printed in a format that can then be parsed.
4
5 declare void @foo()
6 declare void @bar()
7
8 define void @test(i1 %c) {
9 ; CHECK-LABEL: name: test
10 entry:
11 br i1 %c, label %then, label %else
12
13 then:
14 call void @foo()
15 br label %end
16 ; CHECK: successors: %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}}), %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}})
17
18 else:
19 call void @bar()
20 br label %end
21 ; CHECK: successors: %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}})
22
23 end:
24 ret void
25 }
3434 # CHECK-LABEL: name: foo
3535 # CHECK: body: |
3636 # CHECK-NEXT: bb.0.entry:
37 # CHECK-NEXT: successors: %bb.1.less(0x40000000 / 0x80000000 = 50.00%), %bb.2.exit(0x40000000 / 0x80000000 = 50.00%)
37 # CHECK-NEXT: successors: %bb.1.less(0x40000000), %bb.2.exit(0x40000000)
3838 # CHECK-NEXT: liveins: %edi
3939 # CHECK: CMP32ri8 %edi, 10, implicit-def %eflags
4040 # CHECK-NEXT: JG_1 %bb.2.exit, implicit killed %eflags
7878 # CHECK-LABEL: name: bar
7979 # CHECK: body: |
8080 # CHECK-NEXT: bb.0.entry:
81 # CHECK-NEXT: successors: %bb.1.less(0x40000000 / 0x80000000 = 50.00%), %bb.2.exit(0x40000000 / 0x80000000 = 50.00%)
81 # CHECK-NEXT: successors: %bb.1.less(0x40000000), %bb.2.exit(0x40000000)
8282 # CHECK-NEXT: liveins: %edi
8383 # CHECK: CMP32ri8 %edi, 10, implicit-def %eflags
8484 # CHECK-NEXT: JG_1 %bb.2.exit, implicit killed %eflags
2020 name: foo
2121 body: |
2222 ; CHECK-LABEL: bb.0.entry:
23 ; CHECK: successors: %bb.1.less({{[0-9a-fx/= ]+}}33.00%), %bb.2.exit({{[0-9a-fx/= ]+}}67.00%)
23 ; CHECK: successors: %bb.1.less(0x2a3d70a4), %bb.2.exit(0x55c28f5c)
2424 ; CHECK-LABEL: bb.1.less:
2525 bb.0.entry:
2626 successors: %bb.1.less (33), %bb.2.exit(67)
3131 name: foo
3232 body: |
3333 ; CHECK-LABEL: bb.0.entry:
34 ; CHECK: successors: %bb.1.less(0x40000000 / 0x80000000 = 50.00%), %bb.2.exit(0x40000000 / 0x80000000 = 50.00%)
34 ; CHECK: successors: %bb.1.less(0x40000000), %bb.2.exit(0x40000000)
3535 ; CHECK-LABEL: bb.1.less:
3636 bb.0.entry:
3737 successors: %bb.1.less, %bb.2.exit
5757 ; Verify that we can have multiple lists of successors that will be merged
5858 ; into one.
5959 ; CHECK-LABEL: bb.0.entry:
60 ; CHECK: successors: %bb.1(0x80000000 / 0x80000000 = 100.00%), %bb.2(0x00000000 / 0x80000000 = 0.00%)
60 ; CHECK: successors: %bb.1(0x80000000), %bb.2(0x00000000)
6161 bb.0.entry:
6262 liveins: %edi
6363 successors: %bb.1