Skip to content

Commit ce75c88

Browse files
committed
Fix tests. Address review comments.
1 parent f1f9f6b commit ce75c88

8 files changed

+38
-96
lines changed

llvm/test/tools/llvm-readobj/ELF/call-graph-info-callgraph-section.test

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# REQUIRES: x86-registered-target
44

55
# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
6-
# RUN: llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --match-full-lines
7-
# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=LLVM
8-
# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=JSON
6+
# RUN: llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t
7+
# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=LLVM
8+
# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=JSON
99

1010

11-
# CHECK: {{.*}}llvm-readelf{{.*}}: warning: '[[FILE]]': .llvm.callgraph section has unknown type id for 2 indirect targets.
11+
# CHECK: warning: '[[FILE]]': .llvm.callgraph section has unknown type id for 2 indirect targets.
1212
# CHECK-EMPTY:
1313
# CHECK-NEXT: Call graph section '.llvm.callgraph' contains 3 entries:
1414
# CHECK-EMPTY:
@@ -35,7 +35,7 @@
3535
# CHECK-NEXT: Direct Callees (0):
3636
# CHECK-NEXT: Indirect Callees by Type ID (0):
3737

38-
# LLVM: {{.*}}llvm-readelf{{.*}}: warning: '[[FILE]]': .llvm.callgraph section has unknown type id for 2 indirect targets.
38+
# LLVM: warning: '[[FILE]]': .llvm.callgraph section has unknown type id for 2 indirect targets.
3939
# LLVM-NEXT: callgraph_info [
4040
# LLVM-NEXT: Function {
4141
# LLVM-NEXT: Offset: 0x2
@@ -81,7 +81,7 @@
8181
# LLVM-NEXT: }
8282
# LLVM-NEXT: ]
8383

84-
# JSON: {{.*}}llvm-readelf{{.*}}: warning: '[[FILE]]': .llvm.callgraph section has unknown type id for 2 indirect targets.
84+
# JSON: warning: '[[FILE]]': .llvm.callgraph section has unknown type id for 2 indirect targets.
8585
# JSON: "callgraph_info": [
8686
# JSON-NEXT: {
8787
# JSON-NEXT: "Function": {
@@ -160,7 +160,7 @@ baz: #< baz is at 10 (a).
160160
qux: #< qux is at 11 (b).
161161
retq
162162

163-
.section .llvm.callgraph,"o",@llvm_call_graph_section,.text
163+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
164164
.byte 0 #< Format version number.
165165
.byte 3 #< Flag IsIndirectTarget true
166166
.quad 0 #< foo()'s entry address.
@@ -182,6 +182,5 @@ qux: #< qux is at 11 (b).
182182
.quad 32 #< Indirect target type id.
183183

184184
# No call graph section entry for qux.
185-
# Technically its "UNKNOWN" type id but will not be printed as such by llvm-readelf.
186185

187186
.text
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
## Tests that --call-graph-info fails if .llvm.callgraph section has invalid
2-
## function kind value.
2+
## value for flags field.
33

44
# REQUIRES: x86-registered-target
55

66
# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
7-
# RUN: not llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
8-
# RUN: not llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
9-
# RUN: not llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
7+
# RUN: not llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
8+
# RUN: not llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
9+
# RUN: not llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
1010

11-
# ERR: {{.*}}llvm-readelf{{.*}}: error: 'While reading call graph info's Flags': Unknown Flags. Expected one of [1, 3, 5, 7] but found [8]
11+
# ERR: error: 'While reading call graph info's Flags': Unknown Flags. Expected a value in the range [0-7] but found [8]
1212

1313
.text
1414
.globl _Z3foov
1515
.type _Z3foov,@function
1616
_Z3foov:
1717
callq _Z3foov@PLT
1818

19-
.section .llvm.callgraph,"o",@llvm_call_graph_section,.text
19+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
2020
.byte 0 #< Format version number.
21-
.byte 8 #< Only valid values are 1,3,5,7
21+
.byte 8 #< Only valid values are 0 to 7
2222
# Missing direct callees info
2323
.text

llvm/test/tools/llvm-readobj/ELF/call-graph-info-err-invalid-format-version.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
# REQUIRES: x86-registered-target
55

66
# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
7-
# RUN: not llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
8-
# RUN: not llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
9-
# RUN: not llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
7+
# RUN: not llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
8+
# RUN: not llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
9+
# RUN: not llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
1010

11-
# ERR: {{.*}}llvm-readelf{{.*}}: error: 'Unknown value': Unknown format version value [1] in .llvm.callgraph section.
11+
# ERR: error: 'Unknown value': Unknown format version value [1] in .llvm.callgraph section.
1212

1313
.text
1414
.globl _Z3foov
1515
.type _Z3foov,@function
1616
_Z3foov:
1717
callq _Z3foov@PLT
1818

19-
.section .llvm.callgraph,"o",@llvm_call_graph_section,.text
20-
.quad 1 #< Invalid format version number: the only supported version is 0.
19+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
20+
.byte 1 #< Invalid format version number: the only supported version is 0.
2121
.text

llvm/test/tools/llvm-readobj/ELF/call-graph-info-err-malformed-callgraph-section.test

Lines changed: 0 additions & 25 deletions
This file was deleted.

llvm/test/tools/llvm-readobj/ELF/call-graph-info-err-malformed-callgraph-section3.test

Lines changed: 0 additions & 27 deletions
This file was deleted.

llvm/test/tools/llvm-readobj/ELF/call-graph-info-err-missing-directs.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
## Tests that --call-graph-info fails if .llvm.callgraph section has invalid
2-
## function kind value.
1+
## Tests that --call-graph-info fails if .llvm.callgraph section has flags
2+
## that indicate there are direct calls but the direct call info is missing.
33

44
# REQUIRES: x86-registered-target
55

66
# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
7-
# RUN: not llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
8-
# RUN: not llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
9-
# RUN: not llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
7+
# RUN: not llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
8+
# RUN: not llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
9+
# RUN: not llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
1010

11-
# ERR: {{.*}}llvm-readelf{{.*}}: error: 'While reading call graph info's [number of direct callsites] for function at [0x0]': unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
11+
# ERR: error: 'While reading call graph info's [number of direct callsites] for function at [0x0]': unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
1212

1313
.text
1414
.globl _Z3foov
1515
.type _Z3foov,@function
1616
_Z3foov:
1717
callq _Z3foov@PLT
1818

19-
.section .llvm.callgraph,"o",@llvm_call_graph_section,.text
19+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
2020
.byte 0 #< Format version number.
2121
.byte 3 #< Flag IsIndirectTarget true and has direct calls
2222
.quad 0 #< Function entry address.
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@
44
# REQUIRES: x86-registered-target
55

66
# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
7-
# RUN: not llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
8-
# RUN: not llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
9-
# RUN: not llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=ERR
7+
# RUN: not llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
8+
# RUN: not llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
9+
# RUN: not llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
1010

11-
# ERR: {{.*}}llvm-readelf{{.*}}: error: 'While reading call graph info's [indirect target type id] for function at [0x0]': unexpected end of data at offset 0x20 while reading [0x20, 0x28)
11+
# ERR: error: 'While reading call graph info's [indirect type ID] for function at [0x0]': unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
1212

1313
.text
1414
.globl _Z3foov
1515
.type _Z3foov,@function
1616
_Z3foov:
1717
callq _Z3foov@PLT
1818

19-
.section .callgraph,"o",@progbits,.text
20-
.quad 0 #< Format version number.
19+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
20+
.byte 0 #< Format version number.
21+
.byte 4 #< Flags
2122
.quad 0 #< Function entry address.
22-
.quad 0 #< Function kind.
23-
.quad 1 #< Indirect call site count that follows.
23+
.quad 0 #< Type ID
24+
.byte 1 #< Indirect call site count that follows.
2425
#< Missing indirect call entries here.
2526
.text

llvm/tools/llvm-readobj/ELFDumper.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5377,15 +5377,9 @@ template <class ELFT> bool ELFDumper<ELFT>::processCallGraphSection() {
53775377
if (CGSectionErr)
53785378
reportError(std::move(CGSectionErr),
53795379
"While reading call graph info's Flags");
5380-
switch (Flags) {
5381-
case 1:
5382-
case 3:
5383-
case 5:
5384-
case 7:
5385-
break;
5386-
default:
5380+
if (Flags > 7) {
53875381
Error FlagsErr = createError(
5388-
"Unknown Flags. Expected one of [1, 3, 5, 7] but found [" +
5382+
"Unknown Flags. Expected a value in the range [0-7] but found [" +
53895383
std::to_string(Flags) + "]");
53905384
reportError(std::move(FlagsErr), "While reading call graph info's Flags");
53915385
}

0 commit comments

Comments
 (0)