Skip to content

Commit 503fb68

Browse files
committed
Rename flags
1 parent 010514f commit 503fb68

File tree

6 files changed

+48
-30
lines changed

6 files changed

+48
-30
lines changed

lld/MachO/Config.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,15 @@ struct Configuration {
213213
llvm::StringRef csProfilePath;
214214
bool pgoWarnMismatch;
215215
bool warnThinArchiveMissingMembers;
216-
llvm::StringRef profileGuidedFunctionOrderPath;
217-
bool functionOrderForCompression = false;
218-
bool dataOrderForCompression = false;
219-
bool verboseBpSectionOrderer = false;
220216

221217
bool callGraphProfileSort = false;
222218
llvm::StringRef printSymbolOrder;
223219

220+
llvm::StringRef irpgoProfileSortProfilePath;
221+
bool functionOrderForCompression = false;
222+
bool dataOrderForCompression = false;
223+
bool verboseBpSectionOrderer = false;
224+
224225
SectionRenameMap sectionRenameMap;
225226
SegmentRenameMap segmentRenameMap;
226227

lld/MachO/Driver.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,11 +1735,22 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
17351735
args.hasFlag(OPT_warn_thin_archive_missing_members,
17361736
OPT_no_warn_thin_archive_missing_members, true);
17371737
config->generateUuid = !args.hasArg(OPT_no_uuid);
1738-
config->profileGuidedFunctionOrderPath =
1739-
args.getLastArgValue(OPT_profile_guided_function_order);
1740-
config->functionOrderForCompression =
1741-
args.hasArg(OPT_function_order_for_compression);
1742-
config->dataOrderForCompression = args.hasArg(OPT_data_order_for_compression);
1738+
config->irpgoProfileSortProfilePath =
1739+
args.getLastArgValue(OPT_irpgo_profile_sort);
1740+
if (const Arg *arg = args.getLastArg(OPT_compression_sort)) {
1741+
StringRef compressionSortStr = arg->getValue();
1742+
if (compressionSortStr == "function") {
1743+
config->functionOrderForCompression = true;
1744+
} else if (compressionSortStr == "data") {
1745+
config->dataOrderForCompression = true;
1746+
} else if (compressionSortStr == "both") {
1747+
config->functionOrderForCompression = true;
1748+
config->dataOrderForCompression = true;
1749+
} else if (compressionSortStr != "none") {
1750+
error("unknown value `" + compressionSortStr + "` for " +
1751+
arg->getSpelling());
1752+
}
1753+
}
17431754
config->verboseBpSectionOrderer = args.hasArg(OPT_verbose_bp_section_orderer);
17441755

17451756
for (const Arg *arg : args.filtered(OPT_alias)) {

lld/MachO/Options.td

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ def no_call_graph_profile_sort : Flag<["--"], "no-call-graph-profile-sort">,
126126
def print_symbol_order_eq: Joined<["--"], "print-symbol-order=">,
127127
HelpText<"Print a symbol order specified by --call-graph-profile-sort into the specified file">,
128128
Group<grp_lld>;
129+
def irpgo_profile_sort: Joined<["--"], "irpgo-profile-sort=">,
130+
MetaVarName<"<profile>">,
131+
HelpText<"Read the IRPGO profile at <profile> to order sections to improve startup time">,
132+
Group<grp_lld>;
133+
def compression_sort: Joined<["--"], "compression-sort=">,
134+
MetaVarName<"[none,function,data,both]">,
135+
HelpText<"Order sections to improve compressed size">, Group<grp_lld>;
136+
def verbose_bp_section_orderer: Flag<["--"], "verbose-bp-section-orderer">,
137+
HelpText<"Print information on how many sections were ordered by balanced partitioning and a measure of the expected number of page faults">,
138+
Group<grp_lld>;
129139
def ignore_auto_link_option : Separate<["--"], "ignore-auto-link-option">,
130140
Group<grp_lld>;
131141
def ignore_auto_link_option_eq : Joined<["--"], "ignore-auto-link-option=">,
@@ -156,17 +166,6 @@ defm pgo_warn_mismatch: BB<"pgo-warn-mismatch",
156166
defm warn_thin_archive_missing_members : BB<"warn-thin-archive-missing-members",
157167
"Warn on missing object files referenced by thin archives (default)",
158168
"Do not warn on missing object files referenced by thin archives">, Group<grp_lld>;
159-
def profile_guided_function_order: Joined<["--"], "profile-guided-function-order=">,
160-
MetaVarName<"<profile>">,
161-
HelpText<"Read traces from <profile> to order functions to improve startup time">,
162-
Group<grp_lld>;
163-
def function_order_for_compression: Flag<["--"], "function-order-for-compression">,
164-
HelpText<"Order functions to improve compressed size">, Group<grp_lld>;
165-
def data_order_for_compression: Flag<["--"], "data-order-for-compression">,
166-
HelpText<"Order data to improve compressed size">, Group<grp_lld>;
167-
def verbose_bp_section_orderer : Flag<["--"], "verbose-bp-section-orderer">,
168-
HelpText<"Print information on how many sections were ordered by balanced partitioning and a measure of the expected number of page faults">,
169-
Group<grp_lld>;
170169

171170
// This is a complete Options.td compiled from Apple's ld(1) manpage
172171
// dated 2018-03-07 and cross checked with ld64 source code in repo

lld/MachO/SectionPriorities.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ void macho::PriorityBuilder::parseOrderFile(StringRef path) {
353353
DenseMap<const InputSection *, size_t>
354354
macho::PriorityBuilder::buildInputSectionPriorities() {
355355
DenseMap<const InputSection *, size_t> sectionPriorities;
356-
if (!config->profileGuidedFunctionOrderPath.empty() ||
356+
if (!config->irpgoProfileSortProfilePath.empty() ||
357357
config->functionOrderForCompression || config->dataOrderForCompression) {
358358
TimeTraceScope timeScope("Balanced Partitioning Section Orderer");
359359
sectionPriorities = runBalancedPartitioning(
360-
highestAvailablePriority, config->profileGuidedFunctionOrderPath,
360+
highestAvailablePriority, config->irpgoProfileSortProfilePath,
361361
config->functionOrderForCompression, config->dataOrderForCompression,
362362
config->verboseBpSectionOrderer);
363363
} else if (config->callGraphProfileSort) {

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

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

10-
# RUN: %lld -arch arm64 -lSystem -e _main --icf=all -o - %t.o --profile-guided-function-order=%t.profdata --function-order-for-compression --data-order-for-compression | llvm-nm --numeric-sort --format=just-symbols - > %t.order1.txt
11-
# RUN: %lld -arch arm64 -lSystem -e _main --icf=all -o - %t.o --profile-guided-function-order=%t.profdata --function-order-for-compression --data-order-for-compression | llvm-nm --numeric-sort --format=just-symbols - > %t.order2.txt
10+
# RUN: %lld -arch arm64 -lSystem -e _main --icf=all -o - %t.o --irpgo-profile-sort=%t.profdata --compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - > %t.order1.txt
11+
# RUN: %lld -arch arm64 -lSystem -e _main --icf=all -o - %t.o --irpgo-profile-sort=%t.profdata --compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - > %t.order2.txt
1212
# RUN: diff %t.order1.txt %t.order2.txt
1313

1414
import random

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/a.s -o %t/a.o
55
# RUN: llvm-profdata merge %t/a.proftext -o %t/a.profdata
66

7-
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --profile-guided-function-order=%t/a.profdata --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=STARTUP
8-
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --profile-guided-function-order=%t/a.profdata --verbose-bp-section-orderer --icf=all 2>&1 | FileCheck %s --check-prefix=STARTUP
7+
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --irpgo-profile-sort=%t/a.profdata --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=STARTUP
8+
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --irpgo-profile-sort=%t/a.profdata --verbose-bp-section-orderer --icf=all --compression-sort=none 2>&1 | FileCheck %s --check-prefix=STARTUP
99

10-
# RUN: %lld -arch arm64 -lSystem -e _main -o - %t/a.o --profile-guided-function-order=%t/a.profdata -order_file %t/a.orderfile | llvm-nm --numeric-sort --format=just-symbols - | FileCheck %s --check-prefix=ORDERFILE
10+
# RUN: %lld -arch arm64 -lSystem -e _main -o - %t/a.o --irpgo-profile-sort=%t/a.profdata -order_file %t/a.orderfile | llvm-nm --numeric-sort --format=just-symbols - | FileCheck %s --check-prefix=ORDERFILE
1111

12-
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --function-order-for-compression --data-order-for-compression --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=COMPRESSION
13-
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --profile-guided-function-order=%t/a.profdata --function-order-for-compression --data-order-for-compression --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=COMPRESSION
12+
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --verbose-bp-section-orderer --compression-sort=function 2>&1 | FileCheck %s --check-prefix=COMPRESSION-FUNC
13+
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --verbose-bp-section-orderer --compression-sort=data 2>&1 | FileCheck %s --check-prefix=COMPRESSION-DATA
14+
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --verbose-bp-section-orderer --compression-sort=both 2>&1 | FileCheck %s --check-prefix=COMPRESSION-BOTH
15+
# RUN: %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --verbose-bp-section-orderer --compression-sort=both --irpgo-profile-sort=%t/a.profdata 2>&1 | FileCheck %s --check-prefix=COMPRESSION-BOTH
16+
17+
# RUN: not %lld -arch arm64 -lSystem -e _main -o %t/a.out %t/a.o --compression-sort=malformed 2>&1 | FileCheck %s --check-prefix=COMPRESSION-ERR
18+
# COMPRESSION-ERR: unknown value `malformed` for --compression-sort=
1419

1520

1621
# STARTUP: Ordered 3 sections using balanced partitioning
@@ -22,7 +27,9 @@
2227
# ORDERFILE-DAG: _B
2328
# ORDERFILE-DAG: l_C
2429

25-
# COMPRESSION: Ordered 11 sections using balanced partitioning
30+
# COMPRESSION-FUNC: Ordered 7 sections using balanced partitioning
31+
# COMPRESSION-DATA: Ordered 4 sections using balanced partitioning
32+
# COMPRESSION-BOTH: Ordered 11 sections using balanced partitioning
2633

2734
#--- a.s
2835
.text

0 commit comments

Comments
 (0)