Skip to content

Commit 6823c6d

Browse files
committed
add test
1 parent 07c7188 commit 6823c6d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

bolt/test/X86/dwarf4-dwp.test

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# REQUIRES: system-linux
2+
3+
# RUN: rm -rf %t && mkdir -p %t && cd %t
4+
# RUN: split-file %s %t
5+
# RUN: %clangxx -g -gdwarf-4 -gsplit-dwarf %t/main.cpp %t/callee.cpp -o main.exe
6+
# RUN: llvm-dwp -e %t/main.exe -o %t/main.exe.dwp
7+
# RUN: llvm-bolt %t/main.exe -o %t/main.exe.bolt -update-debug-sections 2>&1 | FileCheck %s
8+
9+
# CHECK-NOT: Assertion
10+
11+
12+
#--- main.cpp
13+
int hotFunction(int x);
14+
15+
int main(int argc, char **argv) {
16+
int sum = 0;
17+
for (int i = 0; i < 50000000; ++i) { // 让运行时间更久
18+
sum += hotFunction(i);
19+
}
20+
if (sum)
21+
return 0;
22+
else
23+
return 1;
24+
}
25+
26+
#--- callee.cpp
27+
int hotFunction(int x) {
28+
if ((x & 1) == 0) {
29+
x = x * 3 + 1;
30+
if (x % 5 == 0) {
31+
x += 7;
32+
}
33+
} else {
34+
x = x * x;
35+
if (x % 3 == 0) {
36+
x -= 4;
37+
}
38+
}
39+
return x;
40+
}
41+

0 commit comments

Comments
 (0)