aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util.test
blob: 428f1db06cfd119993c478c5bd54b00e4eb63cf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
; REQUIRES: x86_64-linux

; RUN: mkdir -p %t
; RUN: llvm-ctxprof-util fromYAML --input %S/Inputs/empty.yaml -output %t/empty.bitstream
; RUN: llvm-bcanalyzer --dump %t/empty.bitstream | FileCheck %s --check-prefix=EMPTY

; RUN: llvm-ctxprof-util fromYAML -input %S/Inputs/valid.yaml -output %t/valid.bitstream
; RUN: llvm-ctxprof-util toYAML -input %t/valid.bitstream -output %t/valid2.yaml
; RUN: diff %t/valid2.yaml %S/Inputs/valid.yaml


; RUN: llvm-ctxprof-util fromYAML -input %S/Inputs/valid-ctx-only.yaml -output %t/valid-ctx-only.bitstream
; RUN: llvm-ctxprof-util toYAML -input %t/valid-ctx-only.bitstream -output %t/valid-ctx-only.yaml
; RUN: diff %t/valid-ctx-only.yaml %S/Inputs/valid-ctx-only.yaml

; RUN: llvm-ctxprof-util fromYAML -input %S/Inputs/valid-flat-only.yaml -output %t/valid-flat-only.bitstream
; RUN: llvm-ctxprof-util toYAML -input %t/valid-flat-only.bitstream -output %t/valid-flat-only.yaml
; RUN: diff %t/valid-flat-only.yaml %S/Inputs/valid-flat-only.yaml

; This case is the "valid.yaml" case but with the flat profile first.
; The output, though, should match valid.yaml
; RUN: llvm-ctxprof-util fromYAML -input %S/Inputs/valid-flat-first.yaml -output %t/valid-flat-first.bitstream
; RUN: llvm-ctxprof-util toYAML -input %t/valid-flat-first.bitstream -output %t/valid-flat-first.yaml
; RUN: diff %t/valid-flat-first.yaml %S/Inputs/valid.yaml

; A variant with unhandled contexts:
; RUN: llvm-ctxprof-util fromYAML -input %S/Inputs/valid-with-unhandled.yaml -output %t/valid-with-unhandled.bitstream
; RUN: llvm-ctxprof-util toYAML -input %t/valid-with-unhandled.bitstream -output %t/valid-with-unhandled.yaml
; RUN: diff %t/valid-with-unhandled.yaml %S/Inputs/valid-with-unhandled.yaml

; For the valid case, check against a reference output.
; Note that uint64_t are printed as signed values by llvm-bcanalyzer:
;  * 18446744073709551613 in yaml is -3 in the output
;  * 18446744073709551612 in yaml is -4 in the output
; Also we have no callee/context at index 0, 2 callsites for index 1, and one for
; index 2.
; RUN: llvm-bcanalyzer --dump %t/valid.bitstream | FileCheck %s --check-prefix=VALID

; EMPTY: <BLOCKINFO_BLOCK/>
; EMPTY-NEXT: <Metadata NumWords=1 BlockCodeSize=2>
; EMPTY-NEXT:   <Version op0=4/>
; EMPTY-NEXT: </Metadata>

; VALID:      <BLOCKINFO_BLOCK/>
; VALID-NEXT: <Metadata NumWords=53 BlockCodeSize=2>
; VALID-NEXT:   <Version op0=4/>
; VALID-NEXT:   <Contexts NumWords=37 BlockCodeSize=2>
; VALID-NEXT:     <Root NumWords=23 BlockCodeSize=2>
; VALID-NEXT:       <GUID op0=1000/>
; VALID-NEXT:       <TotalRootEntryCount op0=5/>
; VALID-NEXT:       <Counters op0=1 op1=2 op2=3/>
; VALID-NEXT:       <Unhandled NumWords=1 BlockCodeSize=2>
; VALID-NEXT:       </Unhandled>
; VALID-NEXT:       <Context NumWords=5 BlockCodeSize=2>
; VALID-NEXT:         <GUID op0=-3/>
; VALID-NEXT:         <CalleeIndex op0=1/>
; VALID-NEXT:         <Counters op0=6 op1=7 op2=8/>
; VALID-NEXT:       </Context>
; VALID-NEXT:       <Context NumWords=3 BlockCodeSize=2>
; VALID-NEXT:         <GUID op0=2000/>
; VALID-NEXT:         <CalleeIndex op0=1/>
; VALID-NEXT:         <Counters op0=4 op1=5/>
; VALID-NEXT:       </Context>
; VALID-NEXT:       <Context NumWords=3 BlockCodeSize=2>
; VALID-NEXT:         <GUID op0=3000/>
; VALID-NEXT:         <CalleeIndex op0=2/>
; VALID-NEXT:         <Counters op0=40 op1=50/>
; VALID-NEXT:       </Context>
; VALID-NEXT:     </Root>
; VALID-NEXT:     <Root NumWords=9 BlockCodeSize=2>
; VALID-NEXT:       <GUID op0=-4/>
; VALID-NEXT:       <TotalRootEntryCount op0=45/>
; VALID-NEXT:       <Counters op0=5 op1=9 op2=10/>
; VALID-NEXT:       <Unhandled NumWords=1 BlockCodeSize=2>
; VALID-NEXT:       </Unhandled>
; VALID-NEXT:     </Root>
; VALID-NEXT:   </Contexts>
; VALID-NEXT:   <FlatProfiles NumWords=10 BlockCodeSize=2>
; VALID-NEXT:       <Flat NumWords=3 BlockCodeSize=2>
; VALID-NEXT:         <GUID op0=1234/>
; VALID-NEXT:         <Counters op0=5 op1=6 op2=7/>
; VALID-NEXT:       </Flat>
; VALID-NEXT:       <Flat NumWords=2 BlockCodeSize=2>
; VALID-NEXT:         <GUID op0=5555/>
; VALID-NEXT:         <Counters op0=1/>
; VALID-NEXT:       </Flat>
; VALID-NEXT:   </FlatProfiles>
; VALID-NEXT: </Metadata>