call-graph-profile-section.yaml
6.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
## Test how we dump SHT_LLVM_CALL_GRAPH_PROFILE sections for 32 and 64-bit targets.
## Test we use the "Entries" property when it is possible to dump values correctly.
# RUN: yaml2obj -D BITS=64 -D ENCODE=LSB %s -o %t.le64
# RUN: obj2yaml %t.le64 | FileCheck %s --check-prefix=BASIC
# RUN: yaml2obj -D BITS=64 -D ENCODE=MSB %s -o %t.be64
# RUN: obj2yaml %t.be64 | FileCheck %s --check-prefix=BASIC
# RUN: yaml2obj -D BITS=32 -D ENCODE=LSB %s -o %t.le32
# RUN: obj2yaml %t.le32 | FileCheck %s --check-prefix=BASIC
# RUN: yaml2obj -D BITS=32 -D ENCODE=MSB %s -o %t.be32
# RUN: obj2yaml %t.be32 | FileCheck %s --check-prefix=BASIC
# BASIC: Sections:
# BASIC-NEXT: - Name: .llvm.call-graph-profile
# BASIC-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# BASIC-NEXT: Link: .symtab
# BASIC-NEXT: EntSize: 0x0000000000000010
# BASIC-NEXT: Entries:
# BASIC-NEXT: - From: foo
# BASIC-NEXT: To: bar
# BASIC-NEXT: Weight: 89
# BASIC-NEXT: - From: bar
# BASIC-NEXT: To: foo
# BASIC-NEXT: Weight: 98
# BASIC-NEXT: Symbols:
--- !ELF
FileHeader:
Class: ELFCLASS[[BITS]]
Data: ELFDATA2[[ENCODE]]
Type: ET_DYN
Sections:
- Name: .llvm.call-graph-profile
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Entries:
- From: 1
To: 2
Weight: 89
- From: 2
To: 1
Weight: 98
Symbols:
- Name: foo
- Name: bar
## Check how we handle broken cases.
# RUN: yaml2obj --docnum=2 %s -o %t.invalid
# RUN: obj2yaml %t.invalid | FileCheck %s --check-prefix=INVALID
# INVALID: --- !ELF
# INVALID-NEXT: FileHeader:
# INVALID-NEXT: Class: ELFCLASS32
# INVALID-NEXT: Data: ELFDATA2MSB
# INVALID-NEXT: Type: ET_DYN
# INVALID-NEXT: Sections:
# INVALID-NEXT: - Name: .empty
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: - Name: .multiple.16.valid
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: Entries:
# INVALID-NEXT: - From: foo
# INVALID-NEXT: To: bar
# INVALID-NEXT: Weight: 3
# INVALID-NEXT: - Name: .non.multiple.16
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: Content: '0000000100000002000000000000000300'
# INVALID-NEXT: - Name: .multiple.16.invalid
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: Content: 00112233445566778899AABBCCDDEEFF
# INVALID-NEXT: - Name: .unknown.symbol.1
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: Content: 000000FF000000020000000000000003
# INVALID-NEXT: - Name: .unknown.symbol.2
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: Content: 00000001000000FF0000000000000003
# INVALID-NEXT: - Name: .link.to.symtable
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: Entries:
# INVALID-NEXT: - From: foo
# INVALID-NEXT: To: bar
# INVALID-NEXT: Weight: 0
# INVALID-NEXT: - Name: .link.to.non.symtable.1
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: Content: '00000001000000020000000000000000'
# INVALID-NEXT: - Name: .link.to.non.symtable.2
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .empty
# INVALID-NEXT: EntSize: 0x0000000000000010
# INVALID-NEXT: Content: '00000001000000020000000000000000'
# INVALID-NEXT: - Name: .zero.entry.size
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: Entries:
# INVALID-NEXT: - From: foo
# INVALID-NEXT: To: bar
# INVALID-NEXT: Weight: 0
# INVALID-NEXT: - Name: .invalid.entry.size
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# INVALID-NEXT: Link: .symtab
# INVALID-NEXT: EntSize: 0x0000000000000001
# INVALID-NEXT: Entries:
# INVALID-NEXT: - From: foo
# INVALID-NEXT: To: bar
# INVALID-NEXT: Weight: 0
# INVALID-NEXT: Symbols:
# INVALID-NEXT: - Name: foo
# INVALID-NEXT: - Name: bar
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2MSB
Type: ET_DYN
Sections:
## Case 1: Content is empty.
- Name: .empty
Type: SHT_LLVM_CALL_GRAPH_PROFILE
## Case 2: Check that we use the "Entries" property to dump the data when it
## has a size that is a multiple of 16 and is valid (it is possible to match
## symbol indexes to symbols), but fallback to dumping the whole section
## using the "Content" property otherwise.
## TODO: Teach yaml2obj to accept 'Size' key for SHT_LLVM_CALL_GRAPH_PROFILE
## sections and use Entries for cases below.
- Name: .multiple.16.valid
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Content: "00000001000000020000000000000003"
- Name: .non.multiple.16
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Content: "0000000100000002000000000000000300"
- Name: .multiple.16.invalid
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Content: "00112233445566778899AABBCCDDEEFF"
## Case 3: Check we use the "Content" property when unable to match a
## symbol index to a symbol.
- Name: .unknown.symbol.1
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Entries:
- From: 0xff
To: 2
Weight: 3
- Name: .unknown.symbol.2
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Entries:
- From: 1
To: 0xff
Weight: 3
## Case 4: Check we use the "Content" property when a linked section
## is not a symbol table.
- Name: .link.to.symtable
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Entries:
- From: 1
To: 2
Weight: 0
- Name: .link.to.non.symtable.1
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Link: 0
Entries:
- From: 1
To: 2
Weight: 0
- Name: .link.to.non.symtable.2
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Link: 1
Entries:
- From: 1
To: 2
Weight: 0
## Case 5: Check we can dump a section that has a sh_entsize that is not a multiple of 16.
- Name: .zero.entry.size
Type: SHT_LLVM_CALL_GRAPH_PROFILE
EntSize: 0
Entries:
- From: 1
To: 2
Weight: 0
- Name: .invalid.entry.size
Type: SHT_LLVM_CALL_GRAPH_PROFILE
EntSize: 1
Entries:
- From: 1
To: 2
Weight: 0
Symbols:
- Name: foo
- Name: bar