Skip to content

Commit

Permalink
[lld][InstrProf] Add "Separate" irpgo-profile-sort option (#101084)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ellishg authored Aug 1, 2024
1 parent ab91371 commit f95bd62
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lld/MachO/BPSectionOrderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ getRelocHash(const Reloc &reloc,
sectionIdx = sectionIdxIt->getSecond();
std::string kind;
if (isec)
kind = ("Section " + Twine((uint8_t)isec->kind())).str();
kind = ("Section " + Twine(static_cast<uint8_t>(isec->kind()))).str();
if (auto *sym = reloc.referent.dyn_cast<Symbol *>()) {
kind += (" Symbol " + Twine((uint8_t)sym->kind())).str();
kind += (" Symbol " + Twine(static_cast<uint8_t>(sym->kind()))).str();
if (auto *d = dyn_cast<Defined>(sym)) {
if (isa_and_nonnull<CStringInputSection>(isec))
return getRelocHash(kind, 0, isec->getOffset(d->value), reloc.addend);
Expand Down
5 changes: 3 additions & 2 deletions lld/MachO/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ def no_call_graph_profile_sort : Flag<["--"], "no-call-graph-profile-sort">,
def print_symbol_order_eq: Joined<["--"], "print-symbol-order=">,
HelpText<"Print a symbol order specified by --call-graph-profile-sort into the specified file">,
Group<grp_lld>;
def irpgo_profile_sort: Joined<["--"], "irpgo-profile-sort=">,
MetaVarName<"<profile>">,
def irpgo_profile_sort: Separate<["--"], "irpgo-profile-sort">, Group<grp_lld>;
def irpgo_profile_sort_eq: Joined<["--"], "irpgo-profile-sort=">,
Alias<!cast<Separate>(irpgo_profile_sort)>, MetaVarName<"<profile>">,
HelpText<"Read the IRPGO profile at <profile> to order sections to improve startup time">,
Group<grp_lld>;
def compression_sort: Joined<["--"], "compression-sort=">,
Expand Down
3 changes: 2 additions & 1 deletion lld/test/MachO/bp-section-orderer-errs.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RUN: not %lld -o /dev/null --irpgo-profile-sort %s --call-graph-profile-sort 2>&1 | FileCheck %s --check-prefix=IRPGO-ERR
# RUN: not %lld -o /dev/null --irpgo-profile-sort=%s --call-graph-profile-sort 2>&1 | FileCheck %s --check-prefix=IRPGO-ERR
# IRPGO-ERR: --irpgo-profile-sort= is incompatible with --call-graph-profile-sort
# IRPGO-ERR: --irpgo-profile-sort is incompatible with --call-graph-profile-sort

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

0 comments on commit f95bd62

Please sign in to comment.