Skip to content

Commit f95bd62

Browse files
authored
[lld][InstrProf] Add "Separate" irpgo-profile-sort option (#101084)
Add the "Separate" option `--irpgo-profile-sort <profile` instead of just the "Joined" option `--irpgo-profile-sort=<profile>`. This is useful if the path has a `,` for some reason which would break when trying to use `-Wl,--irpgo-profile-sort=<profile-with-comma>`. While I'm here, use `static_cast<>` instead of the C style cast introduced in #100627
1 parent ab91371 commit f95bd62

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lld/MachO/BPSectionOrderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ getRelocHash(const Reloc &reloc,
4848
sectionIdx = sectionIdxIt->getSecond();
4949
std::string kind;
5050
if (isec)
51-
kind = ("Section " + Twine((uint8_t)isec->kind())).str();
51+
kind = ("Section " + Twine(static_cast<uint8_t>(isec->kind()))).str();
5252
if (auto *sym = reloc.referent.dyn_cast<Symbol *>()) {
53-
kind += (" Symbol " + Twine((uint8_t)sym->kind())).str();
53+
kind += (" Symbol " + Twine(static_cast<uint8_t>(sym->kind()))).str();
5454
if (auto *d = dyn_cast<Defined>(sym)) {
5555
if (isa_and_nonnull<CStringInputSection>(isec))
5656
return getRelocHash(kind, 0, isec->getOffset(d->value), reloc.addend);

lld/MachO/Options.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ 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>">,
129+
def irpgo_profile_sort: Separate<["--"], "irpgo-profile-sort">, Group<grp_lld>;
130+
def irpgo_profile_sort_eq: Joined<["--"], "irpgo-profile-sort=">,
131+
Alias<!cast<Separate>(irpgo_profile_sort)>, MetaVarName<"<profile>">,
131132
HelpText<"Read the IRPGO profile at <profile> to order sections to improve startup time">,
132133
Group<grp_lld>;
133134
def compression_sort: Joined<["--"], "compression-sort=">,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# RUN: not %lld -o /dev/null --irpgo-profile-sort %s --call-graph-profile-sort 2>&1 | FileCheck %s --check-prefix=IRPGO-ERR
12
# RUN: not %lld -o /dev/null --irpgo-profile-sort=%s --call-graph-profile-sort 2>&1 | FileCheck %s --check-prefix=IRPGO-ERR
2-
# IRPGO-ERR: --irpgo-profile-sort= is incompatible with --call-graph-profile-sort
3+
# IRPGO-ERR: --irpgo-profile-sort is incompatible with --call-graph-profile-sort
34

45
# RUN: not %lld -o /dev/null --compression-sort=function --call-graph-profile-sort %s 2>&1 | FileCheck %s --check-prefix=COMPRESSION-ERR
56
# COMPRESSION-ERR: --compression-sort= is incompatible with --call-graph-profile-sort

0 commit comments

Comments
 (0)