this review is extracted from D86539.
1. Rename AccelTableKind to DwarfLinkerAccelTableKind
(to differentiate from AccelTableKind from CodeGen/AsmPrinter/DwarfDebug.h)
2. Add None value to the DwarfLinkerAccelTableKind.
3. added 'None' value for 'accelerator' option of dsymutil.
Differential Revision: https://reviews.llvm.org/D125474
.. option:: --accelerator=<accelerator type>
Specify the desired type of accelerator table. Valid options are 'Apple',
- 'Dwarf' and 'Default'.
+ 'Dwarf', 'Default' and 'None'.
.. option:: --arch <arch>
enum class DwarfLinkerClient { Dsymutil, LLD, General };
/// The kind of accelerator tables we should emit.
-enum class AccelTableKind {
+enum class DwarfLinkerAccelTableKind : uint8_t {
+ None,
Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
Dwarf, ///< DWARF v5 .debug_names.
Default, ///< Dwarf for DWARF5 or later, Apple otherwise.
void setNumThreads(unsigned NumThreads) { Options.Threads = NumThreads; }
/// Set kind of accelerator tables to be generated.
- void setAccelTableKind(AccelTableKind Kind) {
+ void setAccelTableKind(DwarfLinkerAccelTableKind Kind) {
Options.TheAccelTableKind = Kind;
}
unsigned Threads = 1;
/// The accelerator table kind
- AccelTableKind TheAccelTableKind = AccelTableKind::Default;
+ DwarfLinkerAccelTableKind TheAccelTableKind =
+ DwarfLinkerAccelTableKind::Default;
/// Prepend path for the clang modules.
std::string PrependPath;
void DWARFLinker::emitAcceleratorEntriesForUnit(CompileUnit &Unit) {
switch (Options.TheAccelTableKind) {
- case AccelTableKind::Apple:
+ case DwarfLinkerAccelTableKind::None:
+ // Nothing to do.
+ break;
+ case DwarfLinkerAccelTableKind::Apple:
emitAppleAcceleratorEntriesForUnit(Unit);
break;
- case AccelTableKind::Dwarf:
+ case DwarfLinkerAccelTableKind::Dwarf:
emitDwarfAcceleratorEntriesForUnit(Unit);
break;
- case AccelTableKind::Pub:
+ case DwarfLinkerAccelTableKind::Pub:
emitPubAcceleratorEntriesForUnit(Unit);
break;
- case AccelTableKind::Default:
+ case DwarfLinkerAccelTableKind::Default:
llvm_unreachable("The default must be updated to a concrete value.");
break;
}
}
void DWARFLinker::updateAccelKind(DWARFContext &Dwarf) {
- if (Options.TheAccelTableKind != AccelTableKind::Default)
+ if (Options.TheAccelTableKind != DwarfLinkerAccelTableKind::Default)
return;
auto &DwarfObj = Dwarf.getDWARFObj();
// would affect the decision. However, as they're built with the same
// compiler and flags, it is safe to assume that they will follow the
// decision made here.
- if (Options.TheAccelTableKind == AccelTableKind::Default) {
+ if (Options.TheAccelTableKind == DwarfLinkerAccelTableKind::Default) {
if (AtLeastOneDwarfAccelTable && !AtLeastOneAppleAccelTable)
- Options.TheAccelTableKind = AccelTableKind::Dwarf;
+ Options.TheAccelTableKind = DwarfLinkerAccelTableKind::Dwarf;
else
- Options.TheAccelTableKind = AccelTableKind::Apple;
+ Options.TheAccelTableKind = DwarfLinkerAccelTableKind::Apple;
}
for (LinkContext &OptContext : ObjectContexts) {
TheDwarfEmitter->emitAbbrevs(Abbreviations, MaxDwarfVersion);
TheDwarfEmitter->emitStrings(OffsetsStringPool);
switch (Options.TheAccelTableKind) {
- case AccelTableKind::Apple:
+ case DwarfLinkerAccelTableKind::None:
+ // Nothing to do.
+ break;
+ case DwarfLinkerAccelTableKind::Apple:
TheDwarfEmitter->emitAppleNames(AppleNames);
TheDwarfEmitter->emitAppleNamespaces(AppleNamespaces);
TheDwarfEmitter->emitAppleTypes(AppleTypes);
TheDwarfEmitter->emitAppleObjc(AppleObjc);
break;
- case AccelTableKind::Dwarf:
+ case DwarfLinkerAccelTableKind::Dwarf:
TheDwarfEmitter->emitDebugNames(DebugNames);
break;
- case AccelTableKind::Pub:
+ case DwarfLinkerAccelTableKind::Pub:
// Already emitted by emitPubAcceleratorEntriesForUnit.
break;
- case AccelTableKind::Default:
+ case DwarfLinkerAccelTableKind::Default:
llvm_unreachable("Default should have already been resolved.");
break;
}
RUN: dsymutil -accelerator=Dwarf -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -o %t.dwarf.dSYM
RUN: dsymutil -accelerator=Apple -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -o %t.apple.dSYM
+RUN: dsymutil -accelerator=None -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -o %t.none.dSYM
RUN: llvm-dwarfdump -verify %t.dwarf.dSYM
RUN: llvm-dwarfdump -verify %t.apple.dSYM
+RUN: llvm-dwarfdump -verify %t.none.dSYM
RUN: llvm-dwarfdump -debug-names %t.dwarf.dSYM | FileCheck %s -check-prefixes=NAMES,DWARF
RUN: llvm-dwarfdump -apple-names -apple-namespaces -apple-types %t.apple.dSYM | FileCheck %s -check-prefixes=NAMES,APPLE
+RUN: llvm-dwarfdump -a %t.none.dSYM | FileCheck %s -check-prefixes=NONE
RUN: dsymutil -update -accelerator=Dwarf %t.apple.dSYM
RUN: dsymutil -update -accelerator=Apple %t.dwarf.dSYM
+RUN: dsymutil -update -accelerator=None %t.none.dSYM
RUN: llvm-dwarfdump -verify %t.dwarf.dSYM
RUN: llvm-dwarfdump -verify %t.apple.dSYM
+RUN: llvm-dwarfdump -verify %t.none.dSYM
RUN: llvm-dwarfdump -debug-names %t.apple.dSYM | FileCheck %s -check-prefixes=NAMES,DWARF
RUN: llvm-dwarfdump -apple-names -apple-namespaces -apple-types %t.dwarf.dSYM | FileCheck %s -check-prefixes=NAMES,APPLE
+RUN: llvm-dwarfdump -a %t.none.dSYM | FileCheck %s -check-prefixes=NONE
DWARF: .debug_names contents:
DWARF: Compilation Unit offsets [
NAMES-DAG: "val"
NAMES-DAG: "main"
NAMES-DAG: "char"
+
+NONE-NOT: .debug_names
+NONE-NOT: .apple_names
+NONE-NOT: .apple_types
+NONE-NOT: .apple_namespaces
+NONE-NOT: .apple_objc
+NONE-NOT: .debug_pubnames
+NONE-NOT: .debug_types
+NONE-NOT: .debug_gnu_pubnames
+NONE-NOT: .debug_gnu_types
OutputFileType FileType = OutputFileType::Object;
/// The accelerator table kind
- AccelTableKind TheAccelTableKind;
+ DwarfLinkerAccelTableKind TheAccelTableKind;
/// -oso-prepend-path
std::string PrependPath;
def accelerator: Separate<["--", "-"], "accelerator">,
MetaVarName<"<accelerator type>">,
- HelpText<"Specify the desired type of accelerator table. Valid options are 'Apple' (.apple_names, .apple_namespaces, .apple_types, .apple_objc), 'Dwarf' (.debug_names), 'Pub' (.debug_pubnames, .debug_pubtypes) and 'Default'">,
+ HelpText<"Specify the desired type of accelerator table. Valid options are 'Apple' (.apple_names, .apple_namespaces, .apple_types, .apple_objc), 'Dwarf' (.debug_names), 'Pub' (.debug_pubnames, .debug_pubtypes), 'Default' and 'None'">,
Group<grp_general>;
def: Joined<["--", "-"], "accelerator=">, Alias<accelerator>;
return Error::success();
}
-static Expected<AccelTableKind> getAccelTableKind(opt::InputArgList &Args) {
+static Expected<DwarfLinkerAccelTableKind>
+getAccelTableKind(opt::InputArgList &Args) {
if (opt::Arg *Accelerator = Args.getLastArg(OPT_accelerator)) {
StringRef S = Accelerator->getValue();
if (S == "Apple")
- return AccelTableKind::Apple;
+ return DwarfLinkerAccelTableKind::Apple;
if (S == "Dwarf")
- return AccelTableKind::Dwarf;
+ return DwarfLinkerAccelTableKind::Dwarf;
if (S == "Pub")
- return AccelTableKind::Pub;
+ return DwarfLinkerAccelTableKind::Pub;
if (S == "Default")
- return AccelTableKind::Default;
- return make_error<StringError>(
- "invalid accelerator type specified: '" + S +
- "'. Support values are 'Apple', 'Dwarf', 'Pub' and 'Default'.",
- inconvertibleErrorCode());
+ return DwarfLinkerAccelTableKind::Default;
+ if (S == "None")
+ return DwarfLinkerAccelTableKind::None;
+ return make_error<StringError>("invalid accelerator type specified: '" + S +
+ "'. Supported values are 'Apple', "
+ "'Dwarf', 'Pub', 'Default' and 'None'.",
+ inconvertibleErrorCode());
}
- return AccelTableKind::Default;
+ return DwarfLinkerAccelTableKind::Default;
}
static Expected<DWARFVerify> getVerifyKind(opt::InputArgList &Args) {
return DWARFVerify::None;
return make_error<StringError>(
"invalid verify type specified: '" + S +
- "'. Support values are 'input', 'output', 'all' and 'none'.",
+ "'. Supported values are 'input', 'output', 'all' and 'none'.",
inconvertibleErrorCode());
}
return DWARFVerify::None;
if (Args.hasArg(OPT_gen_reproducer))
Options.ReproMode = ReproducerMode::Generate;
- if (Expected<AccelTableKind> AccelKind = getAccelTableKind(Args)) {
+ if (Expected<DwarfLinkerAccelTableKind> AccelKind = getAccelTableKind(Args)) {
Options.LinkOpts.TheAccelTableKind = *AccelKind;
} else {
return AccelKind.takeError();