Skip to content

Commit d01984f

Browse files
ColibrowMaskRay
authored andcommitted
fix: address code review feedback
1 parent dac737e commit d01984f

File tree

5 files changed

+22
-30
lines changed

5 files changed

+22
-30
lines changed

lld/ELF/BPSectionOrderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct BPOrdererELF : lld::BPOrderer<BPOrdererELF> {
4242
}
4343

4444
std::optional<StringRef> static getResolvedLinkageName(llvm::StringRef name) {
45-
return name;
45+
return {};
4646
}
4747

4848
static void

lld/ELF/BPSectionOrderer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ class InputSectionBase;
2424
/// Run Balanced Partitioning to find the optimal function and data order to
2525
/// improve startup time and compressed size.
2626
///
27-
/// It is important that .subsections_via_symbols is used to ensure functions
28-
/// and data are in their own sections and thus can be reordered.
27+
/// It is important that -ffunction-sections and -fdata-sections compiler flags
28+
/// are used to ensure functions and data are in their own sections and thus
29+
/// can be reordered.
2930
llvm::DenseMap<const InputSectionBase *, int>
3031
runBalancedPartitioning(Ctx &ctx, llvm::StringRef profilePath,
3132
bool forFunctionCompression, bool forDataCompression,

lld/ELF/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def call_graph_profile_sort: JJ<"call-graph-profile-sort=">,
141141
def : FF<"no-call-graph-profile-sort">, Alias<call_graph_profile_sort>, AliasArgs<["none"]>,
142142
Flags<[HelpHidden]>;
143143

144-
defm irpgo_profile: Eq<"irpgo-profile",
144+
defm irpgo_profile: EEq<"irpgo-profile",
145145
"Read the IRPGO profile for use with -bp-startup-sort and other profile-guided optimizations">;
146146

147147
def bp_startup_sort: JJ<"bp-startup-sort=">,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
# RUN: llvm-mc -filetype=obj -triple=aarch64 %t.s -o %t.o
88
# RUN: llvm-profdata merge %t.proftext -o %t.profdata
99

10-
# RUN: ld.lld --icf=all -o - %t.o --irpgo-profile=%t.profdata --bp-startup-sort=function --bp-compression-sort-startup-functions --bp-compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - > %t.order1.txt
11-
# RUN: ld.lld --icf=all -o - %t.o --irpgo-profile=%t.profdata --bp-startup-sort=function --bp-compression-sort-startup-functions --bp-compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - > %t.order2.txt
12-
# RUN: diff %t.order1.txt %t.order2.txt
10+
# RUN: ld.lld --icf=all -o %t1.o %t.o --irpgo-profile=%t.profdata --bp-startup-sort=function --bp-compression-sort-startup-functions --bp-compression-sort=both
11+
# RUN: ld.lld --icf=all -o %t2.o %t.o --irpgo-profile=%t.profdata --bp-startup-sort=function --bp-compression-sort-startup-functions --bp-compression-sort=both
12+
# RUN: cmp %t1.o %t2.o
1313

1414
import random
1515
import sys

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

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -110,39 +110,30 @@ r2
110110
const char s1[] = "hello world";
111111
const char s2[] = "i am a string";
112112
const char s3[] = "this is s3";
113-
const char* r1 = s1;
114-
const char** r2 = &r1;
115-
const char*** r3 = &r2;
116-
const char* r4 = s2;
117-
void A() {
118-
return;
119-
}
113+
const char *r1 = s1;
114+
const char **r2 = &r1;
115+
const char ***r3 = &r2;
116+
const char *r4 = s2;
117+
void A() { return; }
120118

121119
int B(int a) {
122-
A();
123-
return a + 1;
120+
A();
121+
return a + 1;
124122
}
125123

126124
int C(int a) {
127-
A();
128-
return a + 2;
125+
A();
126+
return a + 2;
129127
}
130128

131-
int D(int a) {
132-
return B(a + 2);
133-
}
129+
int D(int a) { return B(a + 2); }
134130

135-
int E(int a) {
136-
return C(a + 2);
137-
}
131+
int E(int a) { return C(a + 2); }
138132

139-
int F(int a) {
140-
return C(a + 3);
141-
}
133+
int F(int a) { return C(a + 3); }
134+
135+
int _start() { return 0; }
142136

143-
int _start() {
144-
return 0;
145-
}
146137
#--- gen
147138
clang --target=aarch64-linux-gnu -O0 -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti -fno-asynchronous-unwind-tables -S a.c -o -
148139
;--- a.s

0 commit comments

Comments
 (0)