# REQUIRES: system-linux
# RUN: llvm-bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin --print-pseudo-probes=all -o %t.bolt --lite=0 --enable-bat 2>&1 | FileCheck %s
# PREAGG: B X:0 #foo# 1 0
# PREAGG: B X:0 #bar# 1 0
# PREAGG: B X:0 #main# 1 0
## Check pseudo-probes in regular YAML profile (non-BOLTed binary)
# RUN: link_fdata %s %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin %t.preagg PREAGG
# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata --profile-use-pseudo-probes
# RUN: FileCheck --input-file %t.yaml %s --check-prefix CHECK-YAML
## Check pseudo-probes in BAT YAML profile (BOLTed binary)
# RUN: link_fdata %s %t.bolt %t.preagg2 PREAGG
# RUN: perf2bolt %t.bolt -p %t.preagg2 --pa -w %t.yaml2 -o %t.fdata2 --profile-use-pseudo-probes
# RUN: FileCheck --input-file %t.yaml2 %s --check-prefix CHECK-YAML
# CHECK-YAML: name: bar
# CHECK-YAML: - bid: 0
# CHECK-YAML: pseudo_probes: [ { guid: 0xE413754A191DB537, id: 1, type: 0 }, { guid: 0xE413754A191DB537, id: 4, type: 0 } ]
# CHECK-YAML: guid: 0xE413754A191DB537
# CHECK-YAML: pseudo_probe_desc_hash: 0x10E852DA94
#
# CHECK-YAML: name: foo
# CHECK-YAML: - bid: 0
# CHECK-YAML: pseudo_probes: [ { guid: 0x5CF8C24CDB18BDAC, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 2, type: 0 } ]
# CHECK-YAML: guid: 0x5CF8C24CDB18BDAC
# CHECK-YAML: pseudo_probe_desc_hash: 0x200205A19C5B4
#
# CHECK-YAML: name: main
# CHECK-YAML: - bid: 0
# CHECK-YAML: pseudo_probes: [ { guid: 0xDB956436E78DD5FA, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 2, type: 0 } ]
# CHECK-YAML: guid: 0xDB956436E78DD5FA
# CHECK-YAML: pseudo_probe_desc_hash: 0x10000FFFFFFFF
#
## Check that without --profile-use-pseudo-probes option, no pseudo probes are
## generated
# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata
# RUN: FileCheck --input-file %t.yaml %s --check-prefix CHECK-NO-OPT
# CHECK-NO-OPT-NOT: pseudo_probes
# CHECK-NO-OPT-NOT: guid
# CHECK-NO-OPT-NOT: pseudo_probe_desc_hash
CHECK: Report of decoding input pseudo probe binaries
CHECK-NEXT: Pseudo Probe Desc:
CHECK-NEXT: GUID: 6699318081062747564 Name: foo
CHECK-NEXT: Hash: 563088904013236
CHECK-NEXT: GUID: 15822663052811949562 Name: main
CHECK-NEXT: Hash: 281479271677951
CHECK-NEXT: GUID: 16434608426314478903 Name: bar
CHECK-NEXT: Hash: 72617220756
CHECK: [Probe]: FUNC: bar Index: 1 Type: Block
CHECK: [Probe]: FUNC: bar Index: 4 Type: Block
CHECK: [Probe]: FUNC: foo Index: 1 Type: Block
CHECK: [Probe]: FUNC: foo Index: 2 Type: Block
CHECK: [Probe]: FUNC: foo Index: 5 Type: Block
CHECK: [Probe]: FUNC: foo Index: 6 Type: Block
CHECK: [Probe]: FUNC: foo Index: 2 Type: Block
CHECK: [Probe]: FUNC: foo Index: 3 Type: Block
CHECK: [Probe]: FUNC: foo Index: 4 Type: Block
CHECK: [Probe]: FUNC: bar Index: 1 Type: Block Inlined: @ foo:8
CHECK: [Probe]: FUNC: bar Index: 4 Type: Block Inlined: @ foo:8
CHECK: [Probe]: FUNC: foo Index: 6 Type: Block
CHECK: [Probe]: FUNC: foo Index: 2 Type: Block
CHECK: [Probe]: FUNC: foo Index: 7 Type: Block
CHECK: [Probe]: FUNC: foo Index: 9 Type: DirectCall
CHECK: [Probe]: FUNC: main Index: 1 Type: Block
CHECK: [Probe]: FUNC: foo Index: 1 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 5 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 6 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 3 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 4 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: bar Index: 1 Type: Block Inlined: @ main:2 @ foo:8
CHECK: [Probe]: FUNC: bar Index: 4 Type: Block Inlined: @ main:2 @ foo:8
CHECK: [Probe]: FUNC: foo Index: 6 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 7 Type: Block Inlined: @ main:2
CHECK: [Probe]: FUNC: foo Index: 9 Type: DirectCall Inlined: @ main:2
CHECK: Pseudo Probe Address Conversion results:
CHECK: Address: 0x201750 FUNC: bar Index: 1 Type: Block
CHECK: Address: 0x201750 FUNC: bar Index: 4 Type: Block
CHECK: Address: 0x201770 FUNC: foo Index: 1 Type: Block
CHECK: Address: 0x201770 FUNC: foo Index: 2 Type: Block
CHECK: Address: 0x20177d FUNC: foo Index: 5 Type: Block
CHECK: Address: 0x20177d FUNC: foo Index: 6 Type: Block
CHECK: Address: 0x20177d FUNC: foo Index: 2 Type: Block
CHECK: Address: 0x20178b FUNC: foo Index: 3 Type: Block
CHECK: Address: 0x2017aa FUNC: foo Index: 4 Type: Block
CHECK: Address: 0x2017aa FUNC: bar Index: 1 Type: Block Inlined: @ foo:8
CHECK: Address: 0x2017aa FUNC: bar Index: 4 Type: Block Inlined: @ foo:8
CHECK: Address: 0x2017aa FUNC: foo Index: 6 Type: Block
CHECK: Address: 0x2017aa FUNC: foo Index: 2 Type: Block
CHECK: Address: 0x2017d7 FUNC: foo Index: 7 Type: Block
CHECK: Address: 0x2017e2 FUNC: foo Index: 9 Type: DirectCall
CHECK: Address: 0x2017f0 FUNC: main Index: 1 Type: Block
CHECK: Address: 0x2017f0 FUNC: foo Index: 1 Type: Block Inlined: @ main:2
CHECK: Address: 0x2017f0 FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK: Address: 0x2017fd FUNC: foo Index: 5 Type: Block Inlined: @ main:2
CHECK: Address: 0x2017fd FUNC: foo Index: 6 Type: Block Inlined: @ main:2
CHECK: Address: 0x2017fd FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK: Address: 0x20180b FUNC: foo Index: 3 Type: Block Inlined: @ main:2
CHECK: Address: 0x20182a FUNC: foo Index: 4 Type: Block Inlined: @ main:2
CHECK: Address: 0x20182a FUNC: bar Index: 1 Type: Block Inlined: @ main:2 @ foo:8
CHECK: Address: 0x20182a FUNC: bar Index: 4 Type: Block Inlined: @ main:2 @ foo:8
CHECK: Address: 0x20182a FUNC: foo Index: 6 Type: Block Inlined: @ main:2
CHECK: Address: 0x20182a FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK: Address: 0x201857 FUNC: foo Index: 7 Type: Block Inlined: @ main:2
CHECK: Address: 0x201862 FUNC: foo Index: 9 Type: DirectCall Inlined: @ main:2
CHECK: Address: 2103120
CHECK-NEXT: [Probe]: FUNC: bar Index: 1 Type: Block
CHECK-NEXT: [Probe]: FUNC: bar Index: 4 Type: Block
CHECK-NEXT: Address: 2103152
CHECK-NEXT: [Probe]: FUNC: foo Index: 1 Type: Block
CHECK-NEXT: [Probe]: FUNC: foo Index: 2 Type: Block
CHECK-NEXT: Address: 2103165
CHECK-NEXT: [Probe]: FUNC: foo Index: 5 Type: Block
CHECK-NEXT: [Probe]: FUNC: foo Index: 6 Type: Block
CHECK-NEXT: [Probe]: FUNC: foo Index: 2 Type: Block
CHECK-NEXT: Address: 2103179
CHECK-NEXT: [Probe]: FUNC: foo Index: 3 Type: Block
CHECK-NEXT: Address: 2103210
CHECK-NEXT: [Probe]: FUNC: foo Index: 4 Type: Block
CHECK-NEXT: [Probe]: FUNC: foo Index: 6 Type: Block
CHECK-NEXT: [Probe]: FUNC: foo Index: 2 Type: Block
CHECK-NEXT: [Probe]: FUNC: bar Index: 1 Type: Block Inlined: @ foo:8
CHECK-NEXT: [Probe]: FUNC: bar Index: 4 Type: Block Inlined: @ foo:8
CHECK-NEXT: Address: 2103255
CHECK-NEXT: [Probe]: FUNC: foo Index: 7 Type: Block
CHECK-NEXT: Address: 2103266
CHECK-NEXT: [Probe]: FUNC: foo Index: 9 Type: DirectCall
CHECK-NEXT: Address: 2103280
CHECK-NEXT: [Probe]: FUNC: main Index: 1 Type: Block
CHECK-NEXT: [Probe]: FUNC: foo Index: 1 Type: Block Inlined: @ main:2
CHECK-NEXT: [Probe]: FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK-NEXT: Address: 2103293
CHECK-NEXT: [Probe]: FUNC: foo Index: 5 Type: Block Inlined: @ main:2
CHECK-NEXT: [Probe]: FUNC: foo Index: 6 Type: Block Inlined: @ main:2
CHECK-NEXT: [Probe]: FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK-NEXT: Address: 2103307
CHECK-NEXT: [Probe]: FUNC: foo Index: 3 Type: Block Inlined: @ main:2
CHECK-NEXT: Address: 2103338
CHECK-NEXT: [Probe]: FUNC: foo Index: 4 Type: Block Inlined: @ main:2
CHECK-NEXT: [Probe]: FUNC: foo Index: 6 Type: Block Inlined: @ main:2
CHECK-NEXT: [Probe]: FUNC: foo Index: 2 Type: Block Inlined: @ main:2
CHECK-NEXT: [Probe]: FUNC: bar Index: 1 Type: Block Inlined: @ main:2 @ foo:8
CHECK-NEXT: [Probe]: FUNC: bar Index: 4 Type: Block Inlined: @ main:2 @ foo:8
CHECK-NEXT: Address: 2103383
CHECK-NEXT: [Probe]: FUNC: foo Index: 7 Type: Block Inlined: @ main:2
CHECK-NEXT: Address: 2103394
CHECK-NEXT: [Probe]: FUNC: foo Index: 9 Type: DirectCall Inlined: @ main:2