1; In the perfscript input, the consecutive branch pairs 0x2017bf/0x201760 and 0x2017d8/0x2017e3 form an invalid execution range [0x2017e3, 0x2017bf].
2; We are testing only the invalid range is dropped to avoid bogus instruction ranges. All other ranges and all branch samples should be kept.
3;
4; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/invalid-range.perfscript --binary=%S/Inputs/noinline-cs-pseudoprobe.perfbin --output=%t1 --skip-symbolization --ignore-stack-samples --use-offset=0
5; RUN: FileCheck %s --input-file %t1 --check-prefix=NOCS
6
7; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/invalid-range.perfscript --binary=%S/Inputs/noinline-cs-pseudoprobe.perfbin --output=%t2 --skip-symbolization --use-offset=0
8; RUN: FileCheck %s --input-file %t2 --check-prefix=CS
9
10
11; NOCS:      4
12; NOCS-NEXT: 201760-20177f:2
13; NOCS-NEXT: 20179e-2017bf:1
14; NOCS-NEXT: 2017c4-2017cf:1
15; NOCS-NEXT: 2017c4-2017d8:1
16; NOCS-NEXT: 4
17; NOCS-NEXT: 20177f->2017c4:2
18; NOCS-NEXT: 2017bf->201760:2
19; NOCS-NEXT: 2017cf->20179e:2
20; NOCS-NEXT: 2017d8->2017e3:1
21
22
23; CS:      []
24; CS-NEXT:  3
25; CS-NEXT:  201760-20177f:1
26; CS-NEXT:  20179e-2017bf:1
27; CS-NEXT:  2017c4-2017d8:1
28; CS-NEXT:  4
29; CS-NEXT:  20177f->2017c4:1
30; CS-NEXT:  2017bf->201760:1
31; CS-NEXT:  2017cf->20179e:1
32; CS-NEXT:  2017d8->2017e3:1
33; CS-NEXT: [0x7f4]
34; CS-NEXT:  1
35; CS-NEXT:  2017c4-2017cf:1
36; CS-NEXT:  2
37; CS-NEXT:  2017bf->201760:1
38; CS-NEXT:  2017cf->20179e:1
39; CS-NEXT: [0x7f4 @ 0x7bf]
40; CS-NEXT:  1
41; CS-NEXT:  201760-20177f:1
42; CS-NEXT:  1
43; CS-NEXT:  20177f->2017c4:1
44
45; clang -O3 -fuse-ld=lld -fpseudo-probe-for-profiling
46; -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Xclang -mdisable-tail-calls
47; -g test.c  -o a.out
48
49#include <stdio.h>
50
51int bar(int x, int y) {
52  if (x % 3) {
53    return x - y;
54  }
55  return x + y;
56}
57
58void foo() {
59  int s, i = 0;
60  while (i++ < 4000 * 4000)
61    if (i % 91) s = bar(i, s); else s += 30;
62  printf("sum is %d\n", s);
63}
64
65int main() {
66  foo();
67  return 0;
68}
69