blob: 8d70e581d5d0b1ca4843bff36f088bf9f2e5cba7 [file] [log] [blame]
;; The test fails on Windows. Fix it before removing the following requirement.
; REQUIRES: x86_64-linux
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/noinline-tailcall-probe.perfscript --binary=%S/Inputs/noinline-tailcall-probe.perfbin --output=%t --profile-summary-hot-count=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0 --infer-missing-frames=0
; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-NOINFER
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/noinline-tailcall-probe.perfscript --binary=%S/Inputs/noinline-tailcall-probe.perfbin --output=%t --profile-summary-hot-count=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0 --infer-missing-frames=1
; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-INFER
; CHECK-NOINFER: [main:5 @ foo]:48:1
; CHECK-NOINFER-NEXT: 1: 1
; CHECK-NOINFER-NEXT: 2: 10
; CHECK-NOINFER-NEXT: 3: 9
; CHECK-NOINFER-NEXT: 4: 9
; CHECK-NOINFER-NEXT: 5: 0
; CHECK-NOINFER-NEXT: 6: 9
; CHECK-NOINFER-NEXT: 7: 1
; CHECK-NOINFER-NEXT: 8: 9 bar:9
; CHECK-NOINFER-NEXT: !CFGChecksum: 281613927302580
; CHECK-NOINFER-NEXT:[main:5 @ foo:8 @ bar]:18:9
; CHECK-NOINFER-NEXT: 1: 9
; CHECK-NOINFER-NEXT: 4: 9
; CHECK-NOINFER-NEXT: !CFGChecksum: 72617220756
; CHECK-NOINFER-NEXT:[main]:3:0
; CHECK-NOINFER-NEXT: 1: 0
; CHECK-NOINFER-NEXT: 2: 1
; CHECK-NOINFER-NEXT: 3: 1
; CHECK-NOINFER-NEXT: 4: 0
; CHECK-NOINFER-NEXT: 5: 1 go:1
; CHECK-NOINFER-NEXT: 6: 0
; CHECK-NOINFER-NEXT: !CFGChecksum: 563022115997000
; CHECK-NOINFER-NEXT:[main:5 @ go]:2:1
; CHECK-NOINFER-NEXT: 1: 1
; CHECK-NOINFER-NEXT: 2: 1 foo:1
; CHECK-NOINFER-NEXT: !CFGChecksum: 281479271677951
; CHECK-INFER: [main:5 @ go:2 @ foo]:48:1
; CHECK-INFER-NEXT: 1: 1
; CHECK-INFER-NEXT: 2: 10
; CHECK-INFER-NEXT: 3: 9
; CHECK-INFER-NEXT: 4: 9
; CHECK-INFER-NEXT: 5: 0
; CHECK-INFER-NEXT: 6: 9
; CHECK-INFER-NEXT: 7: 1
; CHECK-INFER-NEXT: 8: 9 bar:9
; CHECK-INFER-NEXT: !CFGChecksum: 281613927302580
; CHECK-INFER-NEXT:[main:5 @ go:2 @ foo:8 @ bar]:18:9
; CHECK-INFER-NEXT: 1: 9
; CHECK-INFER-NEXT: 4: 9
; CHECK-INFER-NEXT: !CFGChecksum: 72617220756
; CHECK-INFER-NEXT:[main]:3:0
; CHECK-INFER-NEXT: 1: 0
; CHECK-INFER-NEXT: 2: 1
; CHECK-INFER-NEXT: 3: 1
; CHECK-INFER-NEXT: 4: 0
; CHECK-INFER-NEXT: 5: 1 go:1
; CHECK-INFER-NEXT: 6: 0
; CHECK-INFER-NEXT: !CFGChecksum: 563022115997000
; CHECK-INFER-NEXT:[main:5 @ go]:2:1
; CHECK-INFER-NEXT: 1: 1
; CHECK-INFER-NEXT: 2: 1 foo:1
; CHECK-INFER-NEXT: !CFGChecksum: 281479271677951
; original code:
; clang -O3 -fexperimental-new-pass-manager -fuse-ld=lld -fpseudo-probe-for-profiling
; -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g test.c -o a.out
#include <stdio.h>
int s;
int bar(int x, int y) {
if (x % 3) {
return x - y;
}
return x + y;
}
int foo() {
int i = 0;
while (i++ < 4000)
if (i % 91) s = bar(i, s); else s += 30;
return 0;
}
void go() {
foo();
}
int main() {
int i = 0;
while (i++ < 4000)
go();
printf("sum is %d\n", s);
return 0;
}