[llvm] 4d9c083 - [DWARFLinker][NFC] Add None value to the DwarfLinkerAccelTableKind enum.
Alexey Lapshin via llvm-commits
llvm-commits at lists.llvm.org
Tue May 17 02:33:00 PDT 2022
Author: Alexey Lapshin
Date: 2022-05-17T12:32:32+03:00
New Revision: 4d9c083437f729df0c17980cf0ef36f943e9e0bf
URL: https://github.com/llvm/llvm-project/commit/4d9c083437f729df0c17980cf0ef36f943e9e0bf
DIFF: https://github.com/llvm/llvm-project/commit/4d9c083437f729df0c17980cf0ef36f943e9e0bf.diff
LOG: [DWARFLinker][NFC] Add None value to the DwarfLinkerAccelTableKind enum.
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
Added:
Modified:
llvm/docs/CommandGuide/dsymutil.rst
llvm/include/llvm/DWARFLinker/DWARFLinker.h
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/test/tools/dsymutil/X86/accelerator.test
llvm/tools/dsymutil/LinkUtils.h
llvm/tools/dsymutil/Options.td
llvm/tools/dsymutil/dsymutil.cpp
Removed:
################################################################################
diff --git a/llvm/docs/CommandGuide/dsymutil.rst b/llvm/docs/CommandGuide/dsymutil.rst
index 22cab9af5b23c..a640c1456a711 100644
--- a/llvm/docs/CommandGuide/dsymutil.rst
+++ b/llvm/docs/CommandGuide/dsymutil.rst
@@ -21,7 +21,7 @@ OPTIONS
.. 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>
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
index 0637f712f52a5..2a1d31c0e72ad 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
@@ -29,7 +29,8 @@ template <typename T> class SmallVectorImpl;
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.
@@ -293,7 +294,7 @@ class DWARFLinker {
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;
}
@@ -804,7 +805,8 @@ class DWARFLinker {
unsigned Threads = 1;
/// The accelerator table kind
- AccelTableKind TheAccelTableKind = AccelTableKind::Default;
+ DwarfLinkerAccelTableKind TheAccelTableKind =
+ DwarfLinkerAccelTableKind::Default;
/// Prepend path for the clang modules.
std::string PrependPath;
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index de4fa63951d60..7c2b5a7c8b74e 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -1787,16 +1787,19 @@ void DWARFLinker::patchLineTableForUnit(CompileUnit &Unit,
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;
}
@@ -2215,7 +2218,7 @@ uint64_t DWARFLinker::DIECloner::cloneAllCompileUnits(
}
void DWARFLinker::updateAccelKind(DWARFContext &Dwarf) {
- if (Options.TheAccelTableKind != AccelTableKind::Default)
+ if (Options.TheAccelTableKind != DwarfLinkerAccelTableKind::Default)
return;
auto &DwarfObj = Dwarf.getDWARFObj();
@@ -2341,11 +2344,11 @@ bool DWARFLinker::link() {
// 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) {
@@ -2524,19 +2527,22 @@ bool DWARFLinker::link() {
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;
}
diff --git a/llvm/test/tools/dsymutil/X86/accelerator.test b/llvm/test/tools/dsymutil/X86/accelerator.test
index 4e5a2be5bb523..ae7d88479b1e7 100644
--- a/llvm/test/tools/dsymutil/X86/accelerator.test
+++ b/llvm/test/tools/dsymutil/X86/accelerator.test
@@ -1,20 +1,26 @@
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 [
@@ -36,3 +42,13 @@ NAMES-DAG: "inc"
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
diff --git a/llvm/tools/dsymutil/LinkUtils.h b/llvm/tools/dsymutil/LinkUtils.h
index 159eae21813dc..03b9a64b6bec5 100644
--- a/llvm/tools/dsymutil/LinkUtils.h
+++ b/llvm/tools/dsymutil/LinkUtils.h
@@ -56,7 +56,7 @@ struct LinkOptions {
OutputFileType FileType = OutputFileType::Object;
/// The accelerator table kind
- AccelTableKind TheAccelTableKind;
+ DwarfLinkerAccelTableKind TheAccelTableKind;
/// -oso-prepend-path
std::string PrependPath;
diff --git a/llvm/tools/dsymutil/Options.td b/llvm/tools/dsymutil/Options.td
index c187ace3abde2..54f02ff1540b9 100644
--- a/llvm/tools/dsymutil/Options.td
+++ b/llvm/tools/dsymutil/Options.td
@@ -143,7 +143,7 @@ def: Joined<["--", "-"], "arch=">, Alias<arch>;
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>;
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index bf742de5220bb..df50432368471 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -206,23 +206,26 @@ static Error verifyOptions(const DsymutilOptions &Options) {
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) {
@@ -240,7 +243,7 @@ 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;
@@ -282,7 +285,7 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
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();
More information about the llvm-commits
mailing list