From e3b557809604d036af6e00c60f012c2025b59a5e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 11 Feb 2023 13:38:04 +0100 Subject: Vendor import of llvm-project main llvmorg-16-init-18548-gb0daacf58f41, the last commit before the upstream release/17.x branch was created. --- llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp | 32 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp') diff --git a/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp b/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp index a6466be37513..74b6104bc668 100644 --- a/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp +++ b/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp @@ -40,11 +40,14 @@ enum ID { #undef OPTION }; -#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE; +#define PREFIX(NAME, VALUE) \ + static constexpr StringLiteral NAME##_init[] = VALUE; \ + static constexpr ArrayRef NAME(NAME##_init, \ + std::size(NAME##_init) - 1); #include "Options.inc" #undef PREFIX -const opt::OptTable::Info InfoTable[] = { +static constexpr opt::OptTable::Info InfoTable[] = { #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ HELPTEXT, METAVAR, VALUES) \ { \ @@ -56,9 +59,9 @@ const opt::OptTable::Info InfoTable[] = { #undef OPTION }; -class DwarfutilOptTable : public opt::OptTable { +class DwarfutilOptTable : public opt::GenericOptTable { public: - DwarfutilOptTable() : OptTable(InfoTable) {} + DwarfutilOptTable() : opt::GenericOptTable(InfoTable) {} }; } // namespace @@ -120,6 +123,19 @@ static Error validateAndSetOptions(opt::InputArgList &Args, Options &Options) { formatv("unknown tombstone value: '{0}'", S).str().c_str()); } + if (opt::Arg *BuildAccelerator = Args.getLastArg(OPT_build_accelerator)) { + StringRef S = BuildAccelerator->getValue(); + + if (S == "none") + Options.AccelTableKind = DwarfUtilAccelKind::None; + else if (S == "DWARF") + Options.AccelTableKind = DwarfUtilAccelKind::DWARF; + else + return createStringError( + std::errc::invalid_argument, + formatv("unknown build-accelerator value: '{0}'", S).str().c_str()); + } + if (Options.Verbose) { if (Options.NumThreads != 1 && Args.hasArg(OPT_threads)) warning("--num-threads set to 1 because verbose mode is specified"); @@ -420,8 +436,9 @@ static Error saveCopyOfFile(const Options &Opts, ObjectFile &InputFile) { } static Error applyCLOptions(const struct Options &Opts, ObjectFile &InputFile) { - if (Opts.DoGarbageCollection) { - verbose("Do garbage collection for debug info ...", Opts.Verbose); + if (Opts.DoGarbageCollection || + Opts.AccelTableKind != DwarfUtilAccelKind::None) { + verbose("Do debug info linking...", Opts.Verbose); DebugInfoBits LinkedDebugInfo; raw_svector_ostream OutStream(LinkedDebugInfo); @@ -458,7 +475,7 @@ int main(int Argc, char const *Argv[]) { DwarfutilOptTable T; unsigned MAI; unsigned MAC; - ArrayRef ArgsArr = makeArrayRef(Argv + 1, Argc - 1); + ArrayRef ArgsArr = ArrayRef(Argv + 1, Argc - 1); opt::InputArgList Args = T.ParseArgs(ArgsArr, MAI, MAC); if (Args.hasArg(OPT_help) || Args.size() == 0) { @@ -481,7 +498,6 @@ int main(int Argc, char const *Argv[]) { InitializeAllTargetMCs(); InitializeAllTargetInfos(); InitializeAllAsmPrinters(); - InitializeAllAsmParsers(); ErrorOr> BuffOrErr = MemoryBuffer::getFileOrSTDIN(Opts.InputFileName); -- cgit v1.2.3