Skip to content

Commit 78ed4a6

Browse files
committed
Ignore callGraphProfile when BP orderer is used, update test
1 parent 4f9853b commit 78ed4a6

File tree

3 files changed

+30
-32
lines changed

3 files changed

+30
-32
lines changed

lld/ELF/BPSectionOrderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct BPOrdererELF : lld::BPOrderer<BPOrdererELF> {
7474
};
7575
} // namespace
7676

77-
DenseMap<const InputSectionBase *, int> lld::elf::runBalancedPartitioning(
77+
DenseMap<const InputSectionBase *, int> elf::runBalancedPartitioning(
7878
Ctx &ctx, StringRef profilePath, bool forFunctionCompression,
7979
bool forDataCompression, bool compressionSortStartupFunctions,
8080
bool verbose) {

lld/ELF/Writer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,9 +1092,9 @@ static DenseMap<const InputSectionBase *, int> buildSectionOrder(Ctx &ctx) {
10921092
ctx.arg.bpDataOrderForCompression,
10931093
ctx.arg.bpCompressionSortStartupFunctions,
10941094
ctx.arg.bpVerboseSectionOrderer);
1095-
}
1096-
if (!ctx.arg.callGraphProfile.empty())
1095+
} else if (!ctx.arg.callGraphProfile.empty()) {
10971096
sectionOrder = computeCallGraphProfileOrder(ctx);
1097+
}
10981098

10991099
if (ctx.arg.symbolOrderingFile.empty())
11001100
return sectionOrder;

lld/test/ELF/bp-section-orderer.s

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# REQUIRES: aarch64
2-
32
# RUN: rm -rf %t && split-file %s %t && cd %t
43

54
## Check for incompatible cases
@@ -19,37 +18,37 @@
1918

2019
# RUN: llvm-mc -filetype=obj -triple=aarch64 a.s -o a.o
2120
# RUN: llvm-profdata merge a.proftext -o a.profdata
22-
# RUN: ld.lld -o a.out a.o --irpgo-profile=a.profdata --bp-startup-sort=function --verbose-bp-section-orderer --icf=all 2>&1 | FileCheck %s --check-prefix=STARTUP-FUNC-ORDER
21+
# RUN: ld.lld a.o --irpgo-profile=a.profdata --bp-startup-sort=function --verbose-bp-section-orderer --icf=all 2>&1 | FileCheck %s --check-prefix=STARTUP-FUNC-ORDER
2322

2423
# STARTUP-FUNC-ORDER: Ordered 3 sections using balanced partitioning
2524

2625
# RUN: ld.lld -o - a.o --symbol-ordering-file a.orderfile --irpgo-profile=a.profdata --bp-startup-sort=function | llvm-nm --numeric-sort --format=just-symbols - | FileCheck %s --check-prefix=ORDERFILE
2726
# RUN: ld.lld -o - a.o --symbol-ordering-file a.orderfile --bp-compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - | FileCheck %s --check-prefix=ORDERFILE
2827

2928
## Rodata
30-
# ORDERFILE: s2
31-
# ORDERFILE: s1
32-
# ORDERFILE-DAG: s3
29+
# ORDERFILE: s2
30+
# ORDERFILE-NEXT: s1
31+
# ORDERFILE-NEXT: s3
3332

3433
## Functions
35-
# ORDERFILE: A
36-
# ORDERFILE: F
37-
# ORDERFILE: E
38-
# ORDERFILE: D
39-
# ORDERFILE-DAG: _start
40-
# ORDERFILE-DAG: B
41-
# ORDERFILE-DAG: C
34+
# ORDERFILE-NEXT: A
35+
# ORDERFILE-NEXT: F
36+
# ORDERFILE-NEXT: E
37+
# ORDERFILE-NEXT: D
38+
# ORDERFILE-NEXT: B
39+
# ORDERFILE-NEXT: C
40+
# ORDERFILE-NEXT: _start
4241

4342
## Data
44-
# ORDERFILE: r3
45-
# ORDERFILE: r2
46-
# ORDERFILE-DAG: r1
47-
# ORDERFILE-DAG: r4
43+
# ORDERFILE-NEXT: r3
44+
# ORDERFILE-NEXT: r2
45+
# ORDERFILE-NEXT: r1
46+
# ORDERFILE-NEXT: r4
4847

49-
# RUN: ld.lld -o a.out a.o --verbose-bp-section-orderer --bp-compression-sort=function 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-FUNC
50-
# RUN: ld.lld -o a.out a.o --verbose-bp-section-orderer --bp-compression-sort=data 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-DATA
51-
# RUN: ld.lld -o a.out a.o --verbose-bp-section-orderer --bp-compression-sort=both 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-BOTH
52-
# RUN: ld.lld -o a.out a.o --verbose-bp-section-orderer --bp-compression-sort=both --irpgo-profile=a.profdata --bp-startup-sort=function 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-BOTH
48+
# RUN: ld.lld a.o --verbose-bp-section-orderer --bp-compression-sort=function 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-FUNC
49+
# RUN: ld.lld a.o --verbose-bp-section-orderer --bp-compression-sort=data 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-DATA
50+
# RUN: ld.lld a.o --verbose-bp-section-orderer --bp-compression-sort=both 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-BOTH
51+
# RUN: ld.lld a.o --verbose-bp-section-orderer --bp-compression-sort=both --irpgo-profile=a.profdata --bp-startup-sort=function 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-BOTH
5352

5453
# BP-COMPRESSION-FUNC: Ordered 7 sections using balanced partitioning
5554
# BP-COMPRESSION-DATA: Ordered 7 sections using balanced partitioning
@@ -137,16 +136,15 @@ int F(int a) { return C(a + 3); }
137136
int _start() { return 0; }
138137

139138
#--- gen
140-
clang --target=aarch64-linux-gnu -O0 -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti -fno-asynchronous-unwind-tables -S a.c -o -
139+
clang --target=aarch64-linux-gnu -O0 -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -S a.c -o -
141140
;--- a.s
142-
.text
143141
.file "a.c"
144142
.section .text.A,"ax",@progbits
145143
.globl A // -- Begin function A
146144
.p2align 2
147145
.type A,@function
148146
A: // @A
149-
// %bb.0:
147+
// %bb.0: // %entry
150148
ret
151149
.Lfunc_end0:
152150
.size A, .Lfunc_end0-A
@@ -156,7 +154,7 @@ A: // @A
156154
.p2align 2
157155
.type B,@function
158156
B: // @B
159-
// %bb.0:
157+
// %bb.0: // %entry
160158
sub sp, sp, #32
161159
stp x29, x30, [sp, #16] // 16-byte Folded Spill
162160
add x29, sp, #16
@@ -175,7 +173,7 @@ B: // @B
175173
.p2align 2
176174
.type C,@function
177175
C: // @C
178-
// %bb.0:
176+
// %bb.0: // %entry
179177
sub sp, sp, #32
180178
stp x29, x30, [sp, #16] // 16-byte Folded Spill
181179
add x29, sp, #16
@@ -194,7 +192,7 @@ C: // @C
194192
.p2align 2
195193
.type D,@function
196194
D: // @D
197-
// %bb.0:
195+
// %bb.0: // %entry
198196
sub sp, sp, #32
199197
stp x29, x30, [sp, #16] // 16-byte Folded Spill
200198
add x29, sp, #16
@@ -213,7 +211,7 @@ D: // @D
213211
.p2align 2
214212
.type E,@function
215213
E: // @E
216-
// %bb.0:
214+
// %bb.0: // %entry
217215
sub sp, sp, #32
218216
stp x29, x30, [sp, #16] // 16-byte Folded Spill
219217
add x29, sp, #16
@@ -232,7 +230,7 @@ E: // @E
232230
.p2align 2
233231
.type F,@function
234232
F: // @F
235-
// %bb.0:
233+
// %bb.0: // %entry
236234
sub sp, sp, #32
237235
stp x29, x30, [sp, #16] // 16-byte Folded Spill
238236
add x29, sp, #16
@@ -251,7 +249,7 @@ F: // @F
251249
.p2align 2
252250
.type _start,@function
253251
_start: // @_start
254-
// %bb.0:
252+
// %bb.0: // %entry
255253
mov w0, wzr
256254
ret
257255
.Lfunc_end6:

0 commit comments

Comments
 (0)