Skip to content

Commit 144687c

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
1 parent ad9f15a commit 144687c

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

bolt/lib/Core/BinaryFunctionCallGraph.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ buildCallGraph(BinaryContext &BC, CgFilterFunction Filter, bool CgFromPerfData,
252252

253253
for (MCInst &Inst : *BB) {
254254
// Find call instructions and extract target symbols from each one.
255-
if (BC.MIB->isCall(Inst)) {
255+
if (BC.MIB->isCall(Inst) ||
256+
BC.MIB->hasAnnotation(Inst, "CallProfile")) {
256257
const CallInfoTy CallInfo = getCallInfo(BB, Inst);
257258

258259
if (!CallInfo.empty()) {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
## Check that indirect jumps with unknown control flow and set call profile are
2+
## handled in call graph construction.
3+
4+
# RUN: split-file %s %t
5+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/src -o %t.o
6+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
7+
# RUN: llvm-bolt %t.exe -o %t.out --lite=0 -print-cfg -data %t/yaml \
8+
# RUN: --print-only=main --reorder-functions=cdsort --dump-cg=%t.dot \
9+
# RUN: --profile-ignore-hash | FileCheck %s
10+
# RUN: FileCheck --input-file %t.dot --check-prefix=CHECK-CG %s
11+
# CHECK-CG: digraph g {
12+
# CHECK-CG-NEXT: f0 [label="main
13+
# CHECK-CG-NEXT: f1 [label="foo
14+
# CHECK-CG-NEXT: f0 -> f1 [label="normWgt=0.000,weight=1000,callOffset=0.0"];
15+
# CHECK-CG-NEXT: }
16+
#--- src
17+
.globl main
18+
.type main, %function
19+
.p2align 2
20+
main:
21+
jmpq *%rax
22+
# CHECK: jmpq *%rax # UNKNOWN CONTROL FLOW # CallProfile: 1000 (0 misses) :
23+
# CHECK-NEXT: { foo: 1000 (0 misses) }
24+
jmpq *%rbx
25+
.size main, .-main
26+
27+
.globl foo
28+
.type foo, %function
29+
.p2align 2
30+
foo:
31+
ud2
32+
.size foo, .-foo
33+
.reloc 0, R_X86_64_NONE
34+
#--- yaml
35+
---
36+
header:
37+
profile-version: 1
38+
binary-name: 'test'
39+
binary-build-id: 0
40+
profile-flags: [ lbr ]
41+
profile-origin: perf data aggregator
42+
profile-events: ''
43+
dfs-order: false
44+
hash-func: xxh3
45+
functions:
46+
- name: main
47+
fid: 1
48+
hash: 0x1
49+
exec: 1000
50+
nblocks: 1
51+
blocks:
52+
- bid: 0
53+
insns: 1
54+
hash: 0x1
55+
exec: 1000
56+
calls: [ { off: 0x0, fid: 2, cnt: 1000 } ]
57+
- name: foo
58+
fid: 2
59+
hash: 0x2
60+
exec: 1000
61+
nblocks: 1
62+
blocks:
63+
- bid: 0
64+
insns: 1
65+
hash: 0x1
66+
exec: 1000
67+
...

0 commit comments

Comments
 (0)