diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-27 19:50:45 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-07-27 19:50:54 +0000 |
| commit | 08e8dd7b9db7bb4a9de26d44c1cbfd24e869c014 (patch) | |
| tree | 041e72e32710b1e742516d8c9f1575bf0116d3e3 /llvm/tools | |
| parent | 4b4fe385e49bd883fd183b5f21c1ea486c722e61 (diff) | |
Vendor import of llvm-project main llvmorg-15-init-17826-g1f8ae9d7e7e4,vendor/llvm-project/llvmorg-15-init-17827-gd77882e66779vendor/llvm-project/llvmorg-15-init-17826-g1f8ae9d7e7e4
the last commit before the upstream release/16.x branch was created.
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp | 49 | ||||
| -rw-r--r-- | llvm/tools/llvm-dwarfutil/DebugInfoLinker.h | 4 | ||||
| -rw-r--r-- | llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp | 22 | ||||
| -rw-r--r-- | llvm/tools/llvm-lto/llvm-lto.cpp | 7 | ||||
| -rw-r--r-- | llvm/tools/llvm-mca/CodeRegionGenerator.cpp | 4 | ||||
| -rw-r--r-- | llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | 27 | ||||
| -rw-r--r-- | llvm/tools/llvm-objcopy/ObjcopyOpts.td | 11 | ||||
| -rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 152 | ||||
| -rw-r--r-- | llvm/tools/llvm-profdata/llvm-profdata.cpp | 3 | ||||
| -rw-r--r-- | llvm/tools/llvm-readobj/ELFDumper.cpp | 15 | ||||
| -rw-r--r-- | llvm/tools/llvm-xray/xray-graph.cpp | 9 |
11 files changed, 230 insertions, 73 deletions
diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp index 458a58c12ca7..3e70f460bc58 100644 --- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp +++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp @@ -8,6 +8,7 @@ #include "DebugInfoLinker.h" #include "Error.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/DWARFLinker/DWARFLinker.h" #include "llvm/DWARFLinker/DWARFStreamer.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" @@ -210,8 +211,29 @@ private: const Options &Opts; }; -bool linkDebugInfo(object::ObjectFile &File, const Options &Options, - raw_pwrite_stream &OutStream) { +static bool knownByDWARFUtil(StringRef SecName) { + return llvm::StringSwitch<bool>(SecName) + .Case(".debug_info", true) + .Case(".debug_types", true) + .Case(".debug_abbrev", true) + .Case(".debug_loc", true) + .Case(".debug_loclists", true) + .Case(".debug_frame", true) + .Case(".debug_aranges", true) + .Case(".debug_ranges", true) + .Case(".debug_rnglists", true) + .Case(".debug_line", true) + .Case(".debug_line_str", true) + .Case(".debug_addr", true) + .Case(".debug_macro", true) + .Case(".debug_macinfo", true) + .Case(".debug_str", true) + .Case(".debug_str_offsets", true) + .Default(false); +} + +Error linkDebugInfo(object::ObjectFile &File, const Options &Options, + raw_pwrite_stream &OutStream) { auto ReportWarn = [&](const Twine &Message, StringRef Context, const DWARFDie *Die) { @@ -235,8 +257,11 @@ bool linkDebugInfo(object::ObjectFile &File, const Options &Options, // Create output streamer. DwarfStreamer OutStreamer(OutputFileType::Object, OutStream, nullptr, ReportWarn, ReportWarn); - if (!OutStreamer.init(File.makeTriple(), "")) - return false; + Triple TargetTriple = File.makeTriple(); + if (!OutStreamer.init(TargetTriple, formatv("cannot create a stream for {0}", + TargetTriple.getTriple()) + .str())) + return createStringError(std::errc::invalid_argument, ""); // Create DWARF linker. DWARFLinker DebugInfoLinker(&OutStreamer, DwarfLinkerClient::LLD); @@ -256,6 +281,16 @@ bool linkDebugInfo(object::ObjectFile &File, const Options &Options, std::unique_ptr<DWARFContext> Context = DWARFContext::create(File); + // Unknown debug sections would be removed. Display warning + // for such sections. + for (SectionName Sec : Context->getDWARFObj().getSectionNames()) { + if (isDebugSection(Sec.Name) && !knownByDWARFUtil(Sec.Name)) + warning( + formatv("'{0}' is not currently supported: section will be skipped", + Sec.Name), + Options.InputFileName); + } + // Add object files to the DWARFLinker. AddresssMapForLinking[0] = std::make_unique<ObjFileAddressMap>(*Context, Options, File); @@ -268,9 +303,11 @@ bool linkDebugInfo(object::ObjectFile &File, const Options &Options, DebugInfoLinker.addObjectFile(*ObjectsForLinking[I]); // Link debug info. - DebugInfoLinker.link(); + if (Error Err = DebugInfoLinker.link()) + return Err; + OutStreamer.finish(); - return true; + return Error::success(); } } // end of namespace dwarfutil diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.h b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.h index e95c83cb9609..d9d99ffc8747 100644 --- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.h +++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.h @@ -22,8 +22,8 @@ inline bool isDebugSection(StringRef SecName) { SecName == ".gdb_index"; } -bool linkDebugInfo(object::ObjectFile &file, const Options &Options, - raw_pwrite_stream &OutStream); +Error linkDebugInfo(object::ObjectFile &file, const Options &Options, + raw_pwrite_stream &OutStream); } // end of namespace dwarfutil } // end of namespace llvm diff --git a/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp b/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp index e77c82e0fad9..a6466be37513 100644 --- a/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp +++ b/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp @@ -292,7 +292,7 @@ using DebugInfoBits = SmallString<10000>; static Error addSectionsFromLinkedData(objcopy::ConfigManager &Config, ObjectFile &InputFile, DebugInfoBits &LinkedDebugInfoBits) { - if (dyn_cast<ELFObjectFile<ELF32LE>>(&InputFile)) { + if (isa<ELFObjectFile<ELF32LE>>(&InputFile)) { Expected<ELFObjectFile<ELF32LE>> MemFile = ELFObjectFile<ELF32LE>::create( MemoryBufferRef(LinkedDebugInfoBits, "")); if (!MemFile) @@ -300,7 +300,7 @@ static Error addSectionsFromLinkedData(objcopy::ConfigManager &Config, if (Error Err = setConfigToAddNewDebugSections(Config, *MemFile)) return Err; - } else if (dyn_cast<ELFObjectFile<ELF64LE>>(&InputFile)) { + } else if (isa<ELFObjectFile<ELF64LE>>(&InputFile)) { Expected<ELFObjectFile<ELF64LE>> MemFile = ELFObjectFile<ELF64LE>::create( MemoryBufferRef(LinkedDebugInfoBits, "")); if (!MemFile) @@ -308,7 +308,7 @@ static Error addSectionsFromLinkedData(objcopy::ConfigManager &Config, if (Error Err = setConfigToAddNewDebugSections(Config, *MemFile)) return Err; - } else if (dyn_cast<ELFObjectFile<ELF32BE>>(&InputFile)) { + } else if (isa<ELFObjectFile<ELF32BE>>(&InputFile)) { Expected<ELFObjectFile<ELF32BE>> MemFile = ELFObjectFile<ELF32BE>::create( MemoryBufferRef(LinkedDebugInfoBits, "")); if (!MemFile) @@ -316,7 +316,7 @@ static Error addSectionsFromLinkedData(objcopy::ConfigManager &Config, if (Error Err = setConfigToAddNewDebugSections(Config, *MemFile)) return Err; - } else if (dyn_cast<ELFObjectFile<ELF64BE>>(&InputFile)) { + } else if (isa<ELFObjectFile<ELF64BE>>(&InputFile)) { Expected<ELFObjectFile<ELF64BE>> MemFile = ELFObjectFile<ELF64BE>::create( MemoryBufferRef(LinkedDebugInfoBits, "")); if (!MemFile) @@ -426,16 +426,14 @@ static Error applyCLOptions(const struct Options &Opts, ObjectFile &InputFile) { DebugInfoBits LinkedDebugInfo; raw_svector_ostream OutStream(LinkedDebugInfo); - if (linkDebugInfo(InputFile, Opts, OutStream)) { - if (Error Err = - saveLinkedDebugInfo(Opts, InputFile, std::move(LinkedDebugInfo))) - return Err; + if (Error Err = linkDebugInfo(InputFile, Opts, OutStream)) + return Err; - return Error::success(); - } + if (Error Err = + saveLinkedDebugInfo(Opts, InputFile, std::move(LinkedDebugInfo))) + return Err; - return createStringError(std::errc::invalid_argument, - "possible broken debug info"); + return Error::success(); } else if (Opts.BuildSeparateDebugFile) { if (Error Err = splitDebugIntoSeparateFile(Opts, InputFile)) return Err; diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index c8266616b73d..64c8c1954ec9 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -261,6 +261,10 @@ static cl::opt<bool> cl::desc("Print pass management debugging information"), cl::cat(LTOCategory)); +static cl::opt<bool> + LTOSaveBeforeOpt("lto-save-before-opt", cl::init(false), + cl::desc("Save the IR before running optimizations")); + namespace { struct ModuleInfo { @@ -1069,6 +1073,9 @@ int main(int argc, char **argv) { CodeGen.setFileType(*FT); if (!OutputFilename.empty()) { + if (LTOSaveBeforeOpt) + CodeGen.setSaveIRBeforeOptPath(OutputFilename + ".0.preopt.bc"); + if (SaveLinkedModuleFile) { std::string ModuleFilename = OutputFilename; ModuleFilename += ".linked.bc"; diff --git a/llvm/tools/llvm-mca/CodeRegionGenerator.cpp b/llvm/tools/llvm-mca/CodeRegionGenerator.cpp index cb8e1822ee30..cdecfba9a375 100644 --- a/llvm/tools/llvm-mca/CodeRegionGenerator.cpp +++ b/llvm/tools/llvm-mca/CodeRegionGenerator.cpp @@ -48,8 +48,8 @@ public: : MCStreamer(Context), Regions(R) {} // We only want to intercept the emission of new instructions. - virtual void emitInstruction(const MCInst &Inst, - const MCSubtargetInfo & /* unused */) override { + void emitInstruction(const MCInst &Inst, + const MCSubtargetInfo & /* unused */) override { Regions.addInstruction(Inst); } diff --git a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp index 8a2b4855501b..7db1e79f3e49 100644 --- a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp +++ b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp @@ -719,24 +719,15 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr, } } - if (auto Arg = InputArgs.getLastArg(OBJCOPY_compress_debug_sections, - OBJCOPY_compress_debug_sections_eq)) { - Config.CompressionType = DebugCompressionType::Z; - - if (Arg->getOption().getID() == OBJCOPY_compress_debug_sections_eq) { - Config.CompressionType = - StringSwitch<DebugCompressionType>( - InputArgs.getLastArgValue(OBJCOPY_compress_debug_sections_eq)) - .Case("zlib", DebugCompressionType::Z) - .Default(DebugCompressionType::None); - if (Config.CompressionType == DebugCompressionType::None) - return createStringError( - errc::invalid_argument, - "invalid or unsupported --compress-debug-sections format: %s", - InputArgs.getLastArgValue(OBJCOPY_compress_debug_sections_eq) - .str() - .c_str()); - } + if (const auto *A = InputArgs.getLastArg(OBJCOPY_compress_debug_sections)) { + Config.CompressionType = StringSwitch<DebugCompressionType>(A->getValue()) + .Case("zlib", DebugCompressionType::Z) + .Default(DebugCompressionType::None); + if (Config.CompressionType == DebugCompressionType::None) + return createStringError( + errc::invalid_argument, + "invalid or unsupported --compress-debug-sections format: %s", + A->getValue()); if (!compression::zlib::isAvailable()) return createStringError( errc::invalid_argument, diff --git a/llvm/tools/llvm-objcopy/ObjcopyOpts.td b/llvm/tools/llvm-objcopy/ObjcopyOpts.td index 962028da47a0..d3713b5ec3c3 100644 --- a/llvm/tools/llvm-objcopy/ObjcopyOpts.td +++ b/llvm/tools/llvm-objcopy/ObjcopyOpts.td @@ -29,12 +29,13 @@ defm new_symbol_visibility : Eq<"new-symbol-visibility", "Visibility of " " with --add-symbol unless otherwise" " specified. The default value is 'default'.">; -def compress_debug_sections : Flag<["--"], "compress-debug-sections">; -def compress_debug_sections_eq +def compress_debug_sections : Joined<["--"], "compress-debug-sections=">, - MetaVarName<"[ zlib ]">, - HelpText<"Compress DWARF debug sections using specified style. Supported " - "formats: 'zlib'">; + MetaVarName<"format">, + HelpText<"Compress DWARF debug sections using specified format. Supported " + "formats: zlib">; +def : Flag<["--"], "compress-debug-sections">, Alias<compress_debug_sections>, + AliasArgs<["zlib"]>; def decompress_debug_sections : Flag<["--"], "decompress-debug-sections">, HelpText<"Decompress DWARF debug sections.">; defm split_dwo diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 9e4fa7c0d9dd..fd83dc197fe9 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -466,6 +466,15 @@ static void printRelocation(formatted_raw_ostream &OS, StringRef FileName, OS << format(Fmt.data(), Address) << Name << "\t" << Val; } +static void AlignToInstStartColumn(size_t Start, const MCSubtargetInfo &STI, + raw_ostream &OS) { + // The output of printInst starts with a tab. Print some spaces so that + // the tab has 1 column and advances to the target tab stop. + unsigned TabStop = getInstStartColumn(STI); + unsigned Column = OS.tell() - Start; + OS.indent(Column < TabStop - 1 ? TabStop - 1 - Column : 7 - Column % 8); +} + class PrettyPrinter { public: virtual ~PrettyPrinter() = default; @@ -487,11 +496,7 @@ public: dumpBytes(Bytes, OS); } - // The output of printInst starts with a tab. Print some spaces so that - // the tab has 1 column and advances to the target tab stop. - unsigned TabStop = getInstStartColumn(STI); - unsigned Column = OS.tell() - Start; - OS.indent(Column < TabStop - 1 ? TabStop - 1 - Column : 7 - Column % 8); + AlignToInstStartColumn(Start, STI, OS); if (MI) { // See MCInstPrinter::printInst. On targets where a PC relative immediate @@ -664,6 +669,91 @@ public: }; BPFPrettyPrinter BPFPrettyPrinterInst; +class ARMPrettyPrinter : public PrettyPrinter { +public: + void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef<uint8_t> Bytes, + object::SectionedAddress Address, formatted_raw_ostream &OS, + StringRef Annot, MCSubtargetInfo const &STI, SourcePrinter *SP, + StringRef ObjectFilename, std::vector<RelocationRef> *Rels, + LiveVariablePrinter &LVP) override { + if (SP && (PrintSource || PrintLines)) + SP->printSourceLine(OS, Address, ObjectFilename, LVP); + LVP.printBetweenInsts(OS, false); + + size_t Start = OS.tell(); + if (LeadingAddr) + OS << format("%8" PRIx64 ":", Address.Address); + if (ShowRawInsn) { + size_t Pos = 0, End = Bytes.size(); + if (STI.checkFeatures("+thumb-mode")) { + for (; Pos + 2 <= End; Pos += 2) + OS << ' ' + << format_hex_no_prefix( + llvm::support::endian::read<uint16_t>( + Bytes.data() + Pos, llvm::support::little), + 4); + } else { + for (; Pos + 4 <= End; Pos += 4) + OS << ' ' + << format_hex_no_prefix( + llvm::support::endian::read<uint32_t>( + Bytes.data() + Pos, llvm::support::little), + 8); + } + if (Pos < End) { + OS << ' '; + dumpBytes(Bytes.slice(Pos), OS); + } + } + + AlignToInstStartColumn(Start, STI, OS); + + if (MI) { + IP.printInst(MI, Address.Address, "", STI, OS); + } else + OS << "\t<unknown>"; + } +}; +ARMPrettyPrinter ARMPrettyPrinterInst; + +class AArch64PrettyPrinter : public PrettyPrinter { +public: + void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef<uint8_t> Bytes, + object::SectionedAddress Address, formatted_raw_ostream &OS, + StringRef Annot, MCSubtargetInfo const &STI, SourcePrinter *SP, + StringRef ObjectFilename, std::vector<RelocationRef> *Rels, + LiveVariablePrinter &LVP) override { + if (SP && (PrintSource || PrintLines)) + SP->printSourceLine(OS, Address, ObjectFilename, LVP); + LVP.printBetweenInsts(OS, false); + + size_t Start = OS.tell(); + if (LeadingAddr) + OS << format("%8" PRIx64 ":", Address.Address); + if (ShowRawInsn) { + size_t Pos = 0, End = Bytes.size(); + for (; Pos + 4 <= End; Pos += 4) + OS << ' ' + << format_hex_no_prefix( + llvm::support::endian::read<uint32_t>(Bytes.data() + Pos, + llvm::support::little), + 8); + if (Pos < End) { + OS << ' '; + dumpBytes(Bytes.slice(Pos), OS); + } + } + + AlignToInstStartColumn(Start, STI, OS); + + if (MI) { + IP.printInst(MI, Address.Address, "", STI, OS); + } else + OS << "\t<unknown>"; + } +}; +AArch64PrettyPrinter AArch64PrettyPrinterInst; + PrettyPrinter &selectPrettyPrinter(Triple const &Triple) { switch(Triple.getArch()) { default: @@ -675,6 +765,15 @@ PrettyPrinter &selectPrettyPrinter(Triple const &Triple) { case Triple::bpfel: case Triple::bpfeb: return BPFPrettyPrinterInst; + case Triple::arm: + case Triple::armeb: + case Triple::thumb: + case Triple::thumbeb: + return ARMPrettyPrinterInst; + case Triple::aarch64: + case Triple::aarch64_be: + case Triple::aarch64_32: + return AArch64PrettyPrinterInst; } } } @@ -895,12 +994,14 @@ static uint64_t dumpARMELFData(uint64_t SectionAddr, uint64_t Index, uint64_t End, const ObjectFile &Obj, ArrayRef<uint8_t> Bytes, ArrayRef<MappingSymbolPair> MappingSymbols, - raw_ostream &OS) { + const MCSubtargetInfo &STI, raw_ostream &OS) { support::endianness Endian = Obj.isLittleEndian() ? support::little : support::big; - OS << format("%8" PRIx64 ":\t", SectionAddr + Index); + size_t Start = OS.tell(); + OS << format("%8" PRIx64 ": ", SectionAddr + Index); if (Index + 4 <= End) { dumpBytes(Bytes.slice(Index, 4), OS); + AlignToInstStartColumn(Start, STI, OS); OS << "\t.word\t" << format_hex(support::endian::read32(Bytes.data() + Index, Endian), 10); @@ -908,13 +1009,14 @@ static uint64_t dumpARMELFData(uint64_t SectionAddr, uint64_t Index, } if (Index + 2 <= End) { dumpBytes(Bytes.slice(Index, 2), OS); - OS << "\t\t.short\t" - << format_hex(support::endian::read16(Bytes.data() + Index, Endian), - 6); + AlignToInstStartColumn(Start, STI, OS); + OS << "\t.short\t" + << format_hex(support::endian::read16(Bytes.data() + Index, Endian), 6); return 2; } dumpBytes(Bytes.slice(Index, 1), OS); - OS << "\t\t.byte\t" << format_hex(Bytes[0], 4); + AlignToInstStartColumn(Start, STI, OS); + OS << "\t.byte\t" << format_hex(Bytes[Index], 4); return 1; } @@ -1022,10 +1124,12 @@ static void collectLocalBranchTargets( // Disassemble a real instruction and record function-local branch labels. MCInst Inst; uint64_t Size; - bool Disassembled = DisAsm->getInstruction( - Inst, Size, Bytes.slice(Index - SectionAddr), Index, nulls()); + ArrayRef<uint8_t> ThisBytes = Bytes.slice(Index - SectionAddr); + bool Disassembled = + DisAsm->getInstruction(Inst, Size, ThisBytes, Index, nulls()); if (Size == 0) - Size = 1; + Size = std::min<uint64_t>(ThisBytes.size(), + DisAsm->suggestBytesToSkip(ThisBytes, Index)); if (Disassembled && MIA) { uint64_t Target; @@ -1068,10 +1172,11 @@ static void addSymbolizer( for (size_t Index = 0; Index != Bytes.size();) { MCInst Inst; uint64_t Size; - DisAsm->getInstruction(Inst, Size, Bytes.slice(Index), SectionAddr + Index, - nulls()); + ArrayRef<uint8_t> ThisBytes = Bytes.slice(Index - SectionAddr); + DisAsm->getInstruction(Inst, Size, ThisBytes, Index, nulls()); if (Size == 0) - Size = 1; + Size = std::min<uint64_t>(ThisBytes.size(), + DisAsm->suggestBytesToSkip(ThisBytes, Index)); Index += Size; } ArrayRef<uint64_t> LabelAddrsRef = SymbolizerPtr->getReferencedAddresses(); @@ -1504,7 +1609,7 @@ static void disassembleObject(const Target *TheTarget, ObjectFile &Obj, if (DumpARMELFData) { Size = dumpARMELFData(SectionAddr, Index, End, Obj, Bytes, - MappingSymbols, FOS); + MappingSymbols, *STI, FOS); } else { // When -z or --disassemble-zeroes are given we always dissasemble // them. Otherwise we might want to skip zero bytes we see. @@ -1538,11 +1643,14 @@ static void disassembleObject(const Target *TheTarget, ObjectFile &Obj, // Disassemble a real instruction or a data when disassemble all is // provided MCInst Inst; - bool Disassembled = - DisAsm->getInstruction(Inst, Size, Bytes.slice(Index), - SectionAddr + Index, CommentStream); + ArrayRef<uint8_t> ThisBytes = Bytes.slice(Index); + uint64_t ThisAddr = SectionAddr + Index; + bool Disassembled = DisAsm->getInstruction(Inst, Size, ThisBytes, + ThisAddr, CommentStream); if (Size == 0) - Size = 1; + Size = std::min<uint64_t>( + ThisBytes.size(), + DisAsm->suggestBytesToSkip(ThisBytes, ThisAddr)); LVP.update({Index, Section.getIndex()}, {Index + Size, Section.getIndex()}, Index + Size != End); diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 0c23d7c1435f..3af8f800adcb 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -2200,8 +2200,7 @@ static int showInstrProfile(const std::string &Filename, bool ShowCounts, Builder.addRecord(Func); if (ShowCovered) { - if (std::any_of(Func.Counts.begin(), Func.Counts.end(), - [](uint64_t C) { return C; })) + if (llvm::any_of(Func.Counts, [](uint64_t C) { return C; })) OS << Func.Name << "\n"; continue; } diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index ae2dec5d15fb..ba7bae96ade3 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -1648,6 +1648,15 @@ const EnumEntry<unsigned> ElfHeaderAVRFlags[] = { ENUM_ENT(EF_AVR_LINKRELAX_PREPARED, "relaxable"), }; +const EnumEntry<unsigned> ElfHeaderLoongArchFlags[] = { + ENUM_ENT(EF_LOONGARCH_BASE_ABI_ILP32S, "ILP32, SOFT-FLOAT"), + ENUM_ENT(EF_LOONGARCH_BASE_ABI_ILP32F, "ILP32, SINGLE-FLOAT"), + ENUM_ENT(EF_LOONGARCH_BASE_ABI_ILP32D, "ILP32, DOUBLE-FLOAT"), + ENUM_ENT(EF_LOONGARCH_BASE_ABI_LP64S, "LP64, SOFT-FLOAT"), + ENUM_ENT(EF_LOONGARCH_BASE_ABI_LP64F, "LP64, SINGLE-FLOAT"), + ENUM_ENT(EF_LOONGARCH_BASE_ABI_LP64D, "LP64, DOUBLE-FLOAT"), +}; + const EnumEntry<unsigned> ElfSymOtherFlags[] = { LLVM_READOBJ_ENUM_ENT(ELF, STV_INTERNAL), @@ -3357,6 +3366,9 @@ template <class ELFT> void GNUELFDumper<ELFT>::printFileHeaders() { else if (e.e_machine == EM_AVR) ElfFlags = printFlags(e.e_flags, makeArrayRef(ElfHeaderAVRFlags), unsigned(ELF::EF_AVR_ARCH_MASK)); + else if (e.e_machine == EM_LOONGARCH) + ElfFlags = printFlags(e.e_flags, makeArrayRef(ElfHeaderLoongArchFlags), + unsigned(ELF::EF_LOONGARCH_BASE_ABI_MASK)); Str = "0x" + utohexstr(e.e_flags); if (!ElfFlags.empty()) Str = Str + ", " + ElfFlags; @@ -6507,6 +6519,9 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printFileHeaders() { else if (E.e_machine == EM_AVR) W.printFlags("Flags", E.e_flags, makeArrayRef(ElfHeaderAVRFlags), unsigned(ELF::EF_AVR_ARCH_MASK)); + else if (E.e_machine == EM_LOONGARCH) + W.printFlags("Flags", E.e_flags, makeArrayRef(ElfHeaderLoongArchFlags), + unsigned(ELF::EF_LOONGARCH_BASE_ABI_MASK)); else W.printFlags("Flags", E.e_flags); W.printNumber("HeaderSize", E.e_ehsize); diff --git a/llvm/tools/llvm-xray/xray-graph.cpp b/llvm/tools/llvm-xray/xray-graph.cpp index 39d2c5c153ef..ff47eb64e947 100644 --- a/llvm/tools/llvm-xray/xray-graph.cpp +++ b/llvm/tools/llvm-xray/xray-graph.cpp @@ -232,10 +232,11 @@ Error GraphRenderer::accountRecord(const XRayRecord &Record) { if (!DeduceSiblingCalls) return make_error<StringError>("No matching ENTRY record", make_error_code(errc::invalid_argument)); - auto Parent = std::find_if( - ThreadStack.rbegin(), ThreadStack.rend(), - [&](const FunctionAttr &A) { return A.FuncId == Record.FuncId; }); - if (Parent == ThreadStack.rend()) + bool FoundParent = + llvm::any_of(llvm::reverse(ThreadStack), [&](const FunctionAttr &A) { + return A.FuncId == Record.FuncId; + }); + if (!FoundParent) return make_error<StringError>( "No matching Entry record in stack", make_error_code(errc::invalid_argument)); // There is no matching |
