Skip to content

Commit ddba036

Browse files
authored
[LLD] Track cg_profile from combination of obj and ordering file (#121324)
Add tests to track section reordering when both cg_profile section and call-graph-ordering-file were given.
1 parent a774adb commit ddba036

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

lld/test/COFF/cgprofile-obj.s

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-win32 %s -o %t
44
# RUN: lld-link /subsystem:console /entry:A %t /out:%t2 /debug:symtab
5-
# RUN: llvm-nm --numeric-sort %t2 | FileCheck %s
5+
# RUN: llvm-nm --numeric-sort %t2 | FileCheck %s --check-prefix=CG-OBJ
66
# RUN: lld-link /call-graph-profile-sort:no /subsystem:console /entry:A %t /out:%t3 /debug:symtab
77
# RUN: llvm-nm --numeric-sort %t3 | FileCheck %s --check-prefix=NO-CG
8+
# RUN: echo "D A 200" > %t.call_graph
9+
# RUN: lld-link /subsystem:console /entry:A %t /out:%t4 /debug:symtab /call-graph-ordering-file:%t.call_graph
10+
# RUN: llvm-nm --numeric-sort %t4 | FileCheck %s --check-prefix=CG-OBJ-OF
811

912
.section .text,"ax", one_only, D
1013
D:
@@ -33,13 +36,17 @@ Aa:
3336
.cg_profile B, C, 30
3437
.cg_profile C, D, 90
3538

36-
# CHECK: 140001000 T A
37-
# CHECK: 140001001 T B
38-
# CHECK: 140001002 T C
39-
# CHECK: 140001003 t D
40-
39+
# CG-OBJ: 140001000 T A
40+
# CG-OBJ: 140001001 T B
41+
# CG-OBJ: 140001002 T C
42+
# CG-OBJ: 140001003 t D
4143

4244
# NO-CG: 140001000 t D
4345
# NO-CG: 140001001 T C
4446
# NO-CG: 140001002 T B
4547
# NO-CG: 140001003 T A
48+
49+
# CG-OBJ-OF: 140001000 T C
50+
# CG-OBJ-OF: 140001001 t D
51+
# CG-OBJ-OF: 140001002 T A
52+
# CG-OBJ-OF: 140001003 T B

lld/test/ELF/cgprofile-obj.s

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
44
# RUN: ld.lld -e A %t.o -o %t
5-
# RUN: llvm-nm --no-sort %t | FileCheck %s
5+
# RUN: llvm-nm --no-sort %t | FileCheck %s --check-prefix=CG-OBJ
66
# RUN: ld.lld --call-graph-profile-sort=none -e A %t.o -o %t
77
# RUN: llvm-nm --no-sort %t | FileCheck %s --check-prefix=NO-CG
88
## --no-call-graph-profile-sort is an alias for --call-graph-profile-sort=none.
99
# RUN: ld.lld --no-call-graph-profile-sort -e A %t.o -o %t1
1010
# RUN: cmp %t %t1
11+
# RUN: echo "D A 200" > %t.call_graph
12+
# RUN: ld.lld -e A %t.o -call-graph-ordering-file=%t.call_graph -o %t2
13+
# RUN: llvm-nm --no-sort %t2 | FileCheck %s --check-prefix=CG-OBJ-OF
1114

1215
.section .text.D,"ax",@progbits
1316
D:
@@ -36,12 +39,17 @@ Aa:
3639
.cg_profile B, C, 30
3740
.cg_profile C, D, 90
3841

39-
# CHECK: 0000000000201123 t D
40-
# CHECK: 0000000000201122 T C
41-
# CHECK: 0000000000201121 T B
42-
# CHECK: 0000000000201120 T A
42+
# CG-OBJ: 0000000000201123 t D
43+
# CG-OBJ: 0000000000201122 T C
44+
# CG-OBJ: 0000000000201121 T B
45+
# CG-OBJ: 0000000000201120 T A
4346

4447
# NO-CG: 0000000000201120 t D
4548
# NO-CG: 0000000000201121 T C
4649
# NO-CG: 0000000000201122 T B
4750
# NO-CG: 0000000000201123 T A
51+
52+
# CG-OBJ-OF: 0000000000201121 t D
53+
# CG-OBJ-OF: 0000000000201120 T C
54+
# CG-OBJ-OF: 0000000000201123 T B
55+
# CG-OBJ-OF: 0000000000201122 T A

0 commit comments

Comments
 (0)