diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/DWARFLinker.h --- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h +++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h @@ -29,7 +29,8 @@ 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. @@ -300,7 +301,7 @@ 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; } @@ -811,7 +812,8 @@ 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 --- a/llvm/lib/DWARFLinker/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp @@ -1789,16 +1789,19 @@ 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; } @@ -2217,7 +2220,7 @@ } void DWARFLinker::updateAccelKind(DWARFContext &Dwarf) { - if (Options.TheAccelTableKind != AccelTableKind::Default) + if (Options.TheAccelTableKind != DwarfLinkerAccelTableKind::Default) return; auto &DwarfObj = Dwarf.getDWARFObj(); @@ -2343,11 +2346,11 @@ // 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) { @@ -2526,19 +2529,22 @@ 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/tools/dsymutil/LinkUtils.h b/llvm/tools/dsymutil/LinkUtils.h --- a/llvm/tools/dsymutil/LinkUtils.h +++ b/llvm/tools/dsymutil/LinkUtils.h @@ -56,7 +56,7 @@ OutputFileType FileType = OutputFileType::Object; /// The accelerator table kind - AccelTableKind TheAccelTableKind; + DwarfLinkerAccelTableKind TheAccelTableKind; /// -oso-prepend-path std::string PrependPath; diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -206,23 +206,24 @@ return Error::success(); } -static Expected getAccelTableKind(opt::InputArgList &Args) { +static Expected +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 DwarfLinkerAccelTableKind::Default; return make_error( "invalid accelerator type specified: '" + S + "'. Support values are 'Apple', 'Dwarf', 'Pub' and 'Default'.", inconvertibleErrorCode()); } - return AccelTableKind::Default; + return DwarfLinkerAccelTableKind::Default; } static Expected getVerifyKind(opt::InputArgList &Args) { @@ -282,7 +283,7 @@ if (Args.hasArg(OPT_gen_reproducer)) Options.ReproMode = ReproducerMode::Generate; - if (Expected AccelKind = getAccelTableKind(Args)) { + if (Expected AccelKind = getAccelTableKind(Args)) { Options.LinkOpts.TheAccelTableKind = *AccelKind; } else { return AccelKind.takeError();