Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions llvm/test/tools/llvm-ctxprof-util/Inputs/valid.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<BLOCKINFO_BLOCK/>
<Metadata NumWords=30 BlockCodeSize=2>
<Version op0=1/>
<Context NumWords=20 BlockCodeSize=2>
<GUID op0=1000/>
<Counters op0=1 op1=2 op2=3/>
<Context NumWords=5 BlockCodeSize=2>
<GUID op0=-3/>
<CalleeIndex op0=1/>
<Counters op0=6 op1=7 op2=8/>
</Context>
<Context NumWords=3 BlockCodeSize=2>
<GUID op0=2000/>
<CalleeIndex op0=1/>
<Counters op0=4 op1=5/>
</Context>
<Context NumWords=3 BlockCodeSize=2>
<GUID op0=3000/>
<CalleeIndex op0=2/>
<Counters op0=40 op1=50/>
</Context>
</Context>
<Context NumWords=4 BlockCodeSize=2>
<GUID op0=-4/>
<Counters op0=5 op1=9 op2=10/>
</Context>
</Metadata>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: not llvm-ctxprof-util nofile.json 2>&1 | FileCheck %s --check-prefix=NO_CMD
; RUN: not llvm-ctxprof-util invalidCmd --input nofile.json 2>&1 | FileCheck %s --check-prefix=INVALID_CMD
; RUN: not llvm-ctxprof-util fromJSON nofile.json 2>&1 | FileCheck %s --check-prefix=NO_FLAG
; RUN: not llvm-ctxprof-util fromJSON --input nofile.json 2>&1 | FileCheck %s --check-prefix=NO_FILE
; RUN: not llvm-ctxprof-util fromJSON --input %S/Inputs/bad.json 2>&1 | FileCheck %s --check-prefix=BAD_JSON
Expand All @@ -10,6 +11,7 @@
; RUN: not llvm-ctxprof-util fromJSON --input %S/Inputs/valid.json --output %t/output.bitstream 2>&1 | FileCheck %s --check-prefix=NO_DIR

; NO_CMD: Unknown subcommand 'nofile.json'
; INVALID_CMD: Unknown subcommand 'invalidCmd'
; NO_FLAG: Unknown command line argument 'nofile.json'.
; NO_FILE: 'nofile.json': No such file or directory
; BAD_JSON: Expected object key
Expand Down
38 changes: 9 additions & 29 deletions llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,17 @@
; RUN: llvm-bcanalyzer --dump %t/empty.bitstream | FileCheck %s --check-prefix=EMPTY

; RUN: llvm-ctxprof-util fromJSON --input %S/Inputs/valid.json -output %t/valid.bitstream
; RUN: llvm-bcanalyzer --dump %t/valid.bitstream | FileCheck %s --check-prefix=VALID

; For the valid case, check against a reference output.
; Note that uint64_t are printed as signed values by llvm-bcanalyzer:
; * 18446744073709551613 in json is -3 in the output
; * 18446744073709551612 in json 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 | head -27 > %t.valid.in
; RUN: diff %S/Inputs/valid.expected %t.valid.in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer the expected to be inlined here like it was earlier, which will be easier to analyze (and give more meaningful error output) on a mismatch.

Copy link
Member Author

@mtrofin mtrofin Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


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

; Note that uin64_t are printed as signed values by llvm-bcanalyzer

; VALID: <BLOCKINFO_BLOCK/>
; VALID: <Context
; VALID-NEXT: <GUID op0=1000/>
; VALID-NEXT: <Counters op0=1 op1=2 op2=3/>
; VALID-NEXT: <Context

; We have no callee/context at index 0, 2 callsites for index 1, and one for
; index 2

; VALID-NEXT: <GUID op0=-3/>
; VALID-NEXT: <CalleeIndex op0=1/>
; VALID-NEXT: <Counters op0=6 op1=7 op2=8/>
; VALID: </Context>
; VALID-NEXT: <Context
; VALID-NEXT: <GUID op0=2000/>
; VALID-NEXT: <CalleeIndex op0=1/>
; VALID: </Context>
; VALID-NEXT: <Context
; VALID-NEXT: <GUID op0=3000/>
; VALID-NEXT: <CalleeIndex op0=2/>
; VALID-NEXT: <Counters op0=40 op1=50/>
; VALID-NEXT: </Context>
; VALID-NEXT: </Context>
; VALID-NEXT: <Context
; VALID-NEXT: <GUID op0=-4/>