File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments