xref: /llvm-project/bolt/test/runtime/X86/fdata-escape-chars.ll (revision 224e4cc516c747b4096fdbe4f2c8d46005eaaa65)
1@var = dso_local global i32 0, align 4
2
3; Function Attrs: noinline nounwind optnone uwtable
4define dso_local void @symb_w_whitespace() #0 {
5  store volatile i32 1, i32* @var, align 4
6  ret void
7}
8
9; Function Attrs: noinline nounwind optnone uwtable
10define dso_local void @symb_backslash_b() #0 {
11  call void @symb_w_whitespace()
12  store volatile i32 2, i32* @var, align 4
13  ret void
14}
15
16; Function Attrs: noinline nounwind optnone uwtable
17define dso_local i32 @main() #0 {
18  %1 = alloca i32, align 4
19  %2 = alloca i32, align 4
20  store i32 0, i32* %1, align 4
21  call void @static_symb_backslash_b()
22  call void @symb_w_whitespace()
23  store i32 0, i32* %2, align 4
24  br label %3
25
263:                                                ; preds = %7, %0
27  %4 = load i32, i32* %2, align 4
28  %5 = icmp slt i32 %4, 2
29  br i1 %5, label %6, label %10
30
316:                                                ; preds = %3
32  call void @symb_backslash_b()
33  br label %7
34
357:                                                ; preds = %6
36  %8 = load i32, i32* %2, align 4
37  %9 = add nsw i32 %8, 1
38  store i32 %9, i32* %2, align 4
39  br label %3
40
4110:                                               ; preds = %3
42  %11 = load i32, i32* %1, align 4
43  ret i32 %11
44}
45
46; Function Attrs: noinline nounwind optnone uwtable
47define internal void @static_symb_backslash_b() #0 {
48  call void @symb_w_whitespace()
49  store volatile i32 3, i32* @var, align 4
50  ret void
51}
52
53; REQUIRES: system-linux,bolt-runtime
54
55; RUN: llc %s -o %t.s
56; RUN: %clang %cflags -O0 %t.s -o %t.exe -Wl,-q
57; RUN: llvm-objcopy --redefine-syms=%p/Inputs/fdata-escape-chars-syms.txt %t.exe
58;
59; RUN: llvm-bolt %t.exe -o %t.exe.instrumented --instrument  \
60; RUN:   --instrumentation-file=%t.fdata
61; RUN: %t.exe.instrumented
62; RUN: cat %t.fdata | \
63; RUN:   FileCheck --check-prefix="FDATA_CHECK" %s
64; RUN: llvm-bolt %t.exe -o %t.fdata.exe --data %t.fdata --print-finalized | \
65; RUN:   FileCheck --check-prefix="INSTR_CHECK" %s
66;
67; RUN: link_fdata %p/Inputs/fdata-escape-chars.txt %t.exe %t.pre "PREAGR"
68; RUN: perf2bolt %t.exe -o %t.pre.fdata -pa -p %t.pre
69; RUN: cat %t.pre.fdata | FileCheck --check-prefix="PREAGR_FDATA_CHECK" %s
70; RUN: llvm-bolt %t.exe -o %t.pre.fdata.exe --data %t.pre.fdata --print-finalized | \
71; RUN:   FileCheck --check-prefix="PREAGR_CHECK" %s
72
73; FDATA_CHECK: 1 symb\ backslash\\ {{([[:xdigit:]]+)}} 1 symb\ whitespace 0 0 2
74; FDATA_CHECK: 1 main {{([[:xdigit:]]+)}} 1 symb\ whitespace 0 0 1
75; FDATA_CHECK: 1 main {{([[:xdigit:]]+)}} 1 symb\ backslash\\ 0 0 2
76
77; INSTR_CHECK: Binary Function "symb whitespace"
78; INSTR_CHECK: Exec Count  : 4
79; INSTR_CHECK: Binary Function "symb backslash\"
80; INSTR_CHECK: Exec Count  : 2
81; INSTR_CHECK: {{([[:xdigit:]]+)}}:   callq   "symb whitespace" # Count: 2
82; INSTR_CHECK: Binary Function "main"
83; INSTR_CHECK: Exec Count  : 1
84; INSTR_CHECK: {{([[:xdigit:]]+)}}:   callq   "symb whitespace" # Count: 1
85; INSTR_CHECK: {{([[:xdigit:]]+)}}:   callq   "symb backslash\" # Count: 2
86; INSTR_CHECK: Binary Function "static symb backslash\/1(*2)"
87; INSTR_CHECK: Exec Count  : 1
88; INSTR_CHECK: {{([[:xdigit:]]+)}}:   callq   "symb whitespace" # Count: 1
89
90; PREAGR_FDATA_CHECK: 1 main 0 1 static\ symb\ backslash\\/1 0 0 1
91; PREAGR_FDATA_CHECK: 1 main 0 1 symb\ backslash\\ 0 0 2
92; PREAGR_FDATA_CHECK: 1 main 0 1 symb\ whitespace 0 0 1
93; PREAGR_FDATA_CHECK: 1 static\ symb\ backslash\\/1 0 1 symb\ whitespace 0 0 1
94; PREAGR_FDATA_CHECK: 1 symb\ backslash\\ 0 1 symb\ whitespace 0 0 2
95
96; PREAGR_CHECK: Binary Function "symb whitespace"
97; PREAGR_CHECK-DAG: Exec Count  : 4
98; PREAGR_CHECK: Binary Function "symb backslash\"
99; PREAGR_CHECK-DAG: Exec Count  : 2
100; PREAGR_CHECK: Binary Function "static symb backslash\/1(*2)"
101; PREAGR_CHECK-DAG: Exec Count  : 1
102