diff options
Diffstat (limited to 'llvm/include/llvm')
22 files changed, 147 insertions, 149 deletions
diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index a683229..39136bc 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -101,6 +101,9 @@ /* Define if LLVM is using tflite */ #cmakedefine LLVM_HAVE_TFLITE +/* Define if we want to check profile consistency in lit tests */ +#cmakedefine LLVM_ENABLE_PROFCHECK + /* Define to 1 if you have the <sysexits.h> header file. */ #cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H} diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h index 71da048..6c12cd3 100644 --- a/llvm/include/llvm/MC/MCAsmInfo.h +++ b/llvm/include/llvm/MC/MCAsmInfo.h @@ -35,6 +35,7 @@ class MCStreamer; class MCSubtargetInfo; class MCSymbol; class MCValue; +class Triple; class raw_ostream; namespace WinEH { @@ -485,6 +486,9 @@ public: /// syntactically correct. virtual bool isValidUnquotedName(StringRef Name) const; + virtual void printSwitchToSection(const MCSection &, uint32_t Subsection, + const Triple &, raw_ostream &) const {} + /// Return true if the .section directive should be omitted when /// emitting \p SectionName. For example: /// @@ -494,6 +498,10 @@ public: /// returns true => .text virtual bool shouldOmitSectionDirective(StringRef SectionName) const; + // Return true if a .align directive should use "optimized nops" to fill + // instead of 0s. + virtual bool useCodeAlign(const MCSection &Sec) const { return false; } + bool usesSunStyleELFSectionSwitchSyntax() const { return SunStyleELFSectionSwitchSyntax; } diff --git a/llvm/include/llvm/MC/MCAsmInfoCOFF.h b/llvm/include/llvm/MC/MCAsmInfoCOFF.h index 1dfb475..dc7832c 100644 --- a/llvm/include/llvm/MC/MCAsmInfoCOFF.h +++ b/llvm/include/llvm/MC/MCAsmInfoCOFF.h @@ -15,6 +15,9 @@ namespace llvm { class MCAsmInfoCOFF : public MCAsmInfo { virtual void anchor(); + void printSwitchToSection(const MCSection &, uint32_t, const Triple &, + raw_ostream &) const final; + bool useCodeAlign(const MCSection &Sec) const final; protected: explicit MCAsmInfoCOFF(); diff --git a/llvm/include/llvm/MC/MCAsmInfoDarwin.h b/llvm/include/llvm/MC/MCAsmInfoDarwin.h index 4ca62b3..12bc3e9 100644 --- a/llvm/include/llvm/MC/MCAsmInfoDarwin.h +++ b/llvm/include/llvm/MC/MCAsmInfoDarwin.h @@ -21,6 +21,9 @@ namespace llvm { class MCAsmInfoDarwin : public MCAsmInfo { public: explicit MCAsmInfoDarwin(); + void printSwitchToSection(const MCSection &, uint32_t, const Triple &, + raw_ostream &) const final; + bool useCodeAlign(const MCSection &Sec) const final; /// True if the section is atomized using the symbols in it. /// This is false if the section is atomized based on its contents (MachO' __TEXT,__cstring for diff --git a/llvm/include/llvm/MC/MCAsmInfoELF.h b/llvm/include/llvm/MC/MCAsmInfoELF.h index 408d4df..c05e4ad 100644 --- a/llvm/include/llvm/MC/MCAsmInfoELF.h +++ b/llvm/include/llvm/MC/MCAsmInfoELF.h @@ -16,6 +16,9 @@ namespace llvm { class MCAsmInfoELF : public MCAsmInfo { virtual void anchor(); MCSection *getNonexecutableStackSection(MCContext &Ctx) const final; + void printSwitchToSection(const MCSection &, uint32_t, const Triple &, + raw_ostream &) const final; + bool useCodeAlign(const MCSection &Sec) const final; protected: MCAsmInfoELF(); diff --git a/llvm/include/llvm/MC/MCAsmInfoGOFF.h b/llvm/include/llvm/MC/MCAsmInfoGOFF.h index 1f3b263..e62d2ae 100644 --- a/llvm/include/llvm/MC/MCAsmInfoGOFF.h +++ b/llvm/include/llvm/MC/MCAsmInfoGOFF.h @@ -19,7 +19,8 @@ namespace llvm { class MCAsmInfoGOFF : public MCAsmInfo { - virtual void anchor(); + void printSwitchToSection(const MCSection &, uint32_t, const Triple &, + raw_ostream &) const final; protected: MCAsmInfoGOFF(); diff --git a/llvm/include/llvm/MC/MCAsmInfoWasm.h b/llvm/include/llvm/MC/MCAsmInfoWasm.h index 3afc610..d98de6c 100644 --- a/llvm/include/llvm/MC/MCAsmInfoWasm.h +++ b/llvm/include/llvm/MC/MCAsmInfoWasm.h @@ -13,7 +13,8 @@ namespace llvm { class MCAsmInfoWasm : public MCAsmInfo { - virtual void anchor(); + void printSwitchToSection(const MCSection &, uint32_t, const Triple &, + raw_ostream &) const final; protected: MCAsmInfoWasm(); diff --git a/llvm/include/llvm/MC/MCAsmInfoXCOFF.h b/llvm/include/llvm/MC/MCAsmInfoXCOFF.h index 5483899..fd1ae82 100644 --- a/llvm/include/llvm/MC/MCAsmInfoXCOFF.h +++ b/llvm/include/llvm/MC/MCAsmInfoXCOFF.h @@ -14,10 +14,11 @@ namespace llvm { class MCAsmInfoXCOFF : public MCAsmInfo { - virtual void anchor(); - protected: MCAsmInfoXCOFF(); + void printSwitchToSection(const MCSection &, uint32_t, const Triple &, + raw_ostream &) const final; + bool useCodeAlign(const MCSection &Sec) const final; public: // Return true only when C is an acceptable character inside a diff --git a/llvm/include/llvm/MC/MCMachObjectWriter.h b/llvm/include/llvm/MC/MCMachObjectWriter.h index 51e4df5..170e2e7 100644 --- a/llvm/include/llvm/MC/MCMachObjectWriter.h +++ b/llvm/include/llvm/MC/MCMachObjectWriter.h @@ -16,7 +16,7 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCLinkerOptimizationHint.h" #include "llvm/MC/MCObjectWriter.h" -#include "llvm/MC/MCSection.h" +#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/StringTableBuilder.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/EndianStream.h" @@ -276,7 +276,7 @@ public: uint64_t SectionDataSize, uint32_t MaxProt, uint32_t InitProt); - void writeSection(const MCAssembler &Asm, const MCSection &Sec, + void writeSection(const MCAssembler &Asm, const MCSectionMachO &Sec, uint64_t VMAddr, uint64_t FileOffset, unsigned Flags, uint64_t RelocationsStart, unsigned NumRelocations); diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h index e9a9cd7..7989310 100644 --- a/llvm/include/llvm/MC/MCSection.h +++ b/llvm/include/llvm/MC/MCSection.h @@ -540,17 +540,6 @@ public: friend class MCFragment; static constexpr unsigned NonUniqueID = ~0U; - enum SectionVariant { - SV_COFF = 0, - SV_ELF, - SV_GOFF, - SV_MachO, - SV_Wasm, - SV_XCOFF, - SV_SPIRV, - SV_DXContainer, - }; - struct iterator { MCFragment *F = nullptr; iterator() = default; @@ -606,12 +595,8 @@ private: protected: // TODO Make Name private when possible. StringRef Name; - SectionVariant Variant; - MCSection(SectionVariant V, StringRef Name, bool IsText, bool IsBss, - MCSymbol *Begin); - // Protected non-virtual dtor prevents destroy through a base class pointer. - ~MCSection() {} + MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin); public: MCSection(const MCSection &) = delete; @@ -620,8 +605,6 @@ public: StringRef getName() const { return Name; } bool isText() const { return IsText; } - SectionVariant getVariant() const { return Variant; } - MCSymbol *getBeginSymbol() { return Begin; } const MCSymbol *getBeginSymbol() const { return const_cast<MCSection *>(this)->getBeginSymbol(); @@ -663,14 +646,6 @@ public: void dump(DenseMap<const MCFragment *, SmallVector<const MCSymbol *, 0>> *FragToSyms = nullptr) const; - virtual void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, - raw_ostream &OS, - uint32_t Subsection) const = 0; - - /// Return true if a .align directive should use "optimized nops" to fill - /// instead of 0s. - virtual bool useCodeAlign() const = 0; - /// Check whether this section is "virtual", that is has no actual object /// file contents. bool isBssSection() const { return IsBss; } diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h b/llvm/include/llvm/MC/MCSectionCOFF.h index 58ed2c4..71efc41 100644 --- a/llvm/include/llvm/MC/MCSectionCOFF.h +++ b/llvm/include/llvm/MC/MCSectionCOFF.h @@ -51,11 +51,12 @@ class MCSectionCOFF final : public MCSection { private: friend class MCContext; + friend class MCAsmInfoCOFF; // The storage of Name is owned by MCContext's COFFUniquingMap. MCSectionCOFF(StringRef Name, unsigned Characteristics, MCSymbol *COMDATSymbol, int Selection, unsigned UniqueID, MCSymbol *Begin) - : MCSection(SV_COFF, Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE, + : MCSection(Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE, Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA, Begin), Characteristics(Characteristics), COMDATSymbol(COMDATSymbol), @@ -67,7 +68,7 @@ private: public: /// Decides whether a '.section' directive should be printed before the /// section name - bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const; + bool shouldOmitSectionDirective(StringRef Name) const; unsigned getCharacteristics() const { return Characteristics; } MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; } @@ -78,11 +79,6 @@ public: bool isUnique() const { return UniqueID != NonUniqueID; } unsigned getUniqueID() const { return UniqueID; } - void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, - raw_ostream &OS, - uint32_t Subsection) const override; - bool useCodeAlign() const override; - unsigned getOrAssignWinCFISectionID(unsigned *NextID) const { if (WinCFISectionID == ~0U) WinCFISectionID = (*NextID)++; diff --git a/llvm/include/llvm/MC/MCSectionDXContainer.h b/llvm/include/llvm/MC/MCSectionDXContainer.h index 723b477..7d8e0c5 100644 --- a/llvm/include/llvm/MC/MCSectionDXContainer.h +++ b/llvm/include/llvm/MC/MCSectionDXContainer.h @@ -24,13 +24,7 @@ class MCSectionDXContainer final : public MCSection { friend class MCContext; MCSectionDXContainer(StringRef Name, SectionKind K, MCSymbol *Begin) - : MCSection(SV_DXContainer, Name, K.isText(), /*IsVirtual=*/false, - Begin) {} - -public: - void printSwitchToSection(const MCAsmInfo &, const Triple &, raw_ostream &, - uint32_t) const override; - bool useCodeAlign() const override { return false; } + : MCSection(Name, K.isText(), /*IsVirtual=*/false, Begin) {} }; } // end namespace llvm diff --git a/llvm/include/llvm/MC/MCSectionELF.h b/llvm/include/llvm/MC/MCSectionELF.h index 5565298..f089dd9 100644 --- a/llvm/include/llvm/MC/MCSectionELF.h +++ b/llvm/include/llvm/MC/MCSectionELF.h @@ -52,14 +52,15 @@ class MCSectionELF final : public MCSection { private: friend class MCContext; + friend class MCAsmInfoELF; // The storage of Name is owned by MCContext's ELFUniquingMap. MCSectionELF(StringRef Name, unsigned type, unsigned flags, unsigned entrySize, const MCSymbolELF *group, bool IsComdat, unsigned UniqueID, MCSymbol *Begin, const MCSymbolELF *LinkedToSym) - : MCSection(SV_ELF, Name, flags & ELF::SHF_EXECINSTR, - type == ELF::SHT_NOBITS, Begin), + : MCSection(Name, flags & ELF::SHF_EXECINSTR, type == ELF::SHT_NOBITS, + Begin), Type(type), Flags(flags), UniqueID(UniqueID), EntrySize(entrySize), Group(group, IsComdat), LinkedToSym(LinkedToSym) { assert((!(Flags & ELF::SHF_GROUP) || Group.getPointer()) && @@ -69,10 +70,6 @@ private: } public: - /// Decides whether a '.section' directive should be printed before the - /// section name - bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const; - unsigned getType() const { return Type; } unsigned getFlags() const { return Flags; } unsigned getEntrySize() const { return EntrySize; } @@ -80,11 +77,6 @@ public: const MCSymbolELF *getGroup() const { return Group.getPointer(); } bool isComdat() const { return Group.getInt(); } - void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, - raw_ostream &OS, - uint32_t Subsection) const override; - bool useCodeAlign() const override; - bool isUnique() const { return UniqueID != NonUniqueID; } unsigned getUniqueID() const { return UniqueID; } diff --git a/llvm/include/llvm/MC/MCSectionGOFF.h b/llvm/include/llvm/MC/MCSectionGOFF.h index b166397..2136148 100644 --- a/llvm/include/llvm/MC/MCSectionGOFF.h +++ b/llvm/include/llvm/MC/MCSectionGOFF.h @@ -52,36 +52,28 @@ class LLVM_ABI MCSectionGOFF final : public MCSection { mutable unsigned Emitted : 1; friend class MCContext; + friend class MCAsmInfoGOFF; friend class MCSymbolGOFF; MCSectionGOFF(StringRef Name, SectionKind K, bool IsVirtual, GOFF::SDAttr SDAttributes, MCSectionGOFF *Parent) - : MCSection(SV_GOFF, Name, K.isText(), IsVirtual, nullptr), - Parent(Parent), SDAttributes(SDAttributes), - SymbolType(GOFF::ESD_ST_SectionDefinition), IsBSS(K.isBSS()), - RequiresNonZeroLength(0), Emitted(0) {} + : MCSection(Name, K.isText(), IsVirtual, nullptr), Parent(Parent), + SDAttributes(SDAttributes), SymbolType(GOFF::ESD_ST_SectionDefinition), + IsBSS(K.isBSS()), RequiresNonZeroLength(0), Emitted(0) {} MCSectionGOFF(StringRef Name, SectionKind K, bool IsVirtual, GOFF::EDAttr EDAttributes, MCSectionGOFF *Parent) - : MCSection(SV_GOFF, Name, K.isText(), IsVirtual, nullptr), - Parent(Parent), EDAttributes(EDAttributes), - SymbolType(GOFF::ESD_ST_ElementDefinition), IsBSS(K.isBSS()), - RequiresNonZeroLength(0), Emitted(0) {} + : MCSection(Name, K.isText(), IsVirtual, nullptr), Parent(Parent), + EDAttributes(EDAttributes), SymbolType(GOFF::ESD_ST_ElementDefinition), + IsBSS(K.isBSS()), RequiresNonZeroLength(0), Emitted(0) {} MCSectionGOFF(StringRef Name, SectionKind K, bool IsVirtual, GOFF::PRAttr PRAttributes, MCSectionGOFF *Parent) - : MCSection(SV_GOFF, Name, K.isText(), IsVirtual, nullptr), - Parent(Parent), PRAttributes(PRAttributes), - SymbolType(GOFF::ESD_ST_PartReference), IsBSS(K.isBSS()), - RequiresNonZeroLength(0), Emitted(0) {} + : MCSection(Name, K.isText(), IsVirtual, nullptr), Parent(Parent), + PRAttributes(PRAttributes), SymbolType(GOFF::ESD_ST_PartReference), + IsBSS(K.isBSS()), RequiresNonZeroLength(0), Emitted(0) {} public: - void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, - raw_ostream &OS, - uint32_t Subsection) const override; - - bool useCodeAlign() const override { return false; } - // Return the parent section. MCSectionGOFF *getParent() const { return Parent; } @@ -123,8 +115,6 @@ public: bool requiresNonZeroLength() const { return RequiresNonZeroLength; } void setName(StringRef SectionName) { Name = SectionName; } - - static bool classof(const MCSection *S) { return S->getVariant() == SV_GOFF; } }; } // end namespace llvm diff --git a/llvm/include/llvm/MC/MCSectionMachO.h b/llvm/include/llvm/MC/MCSectionMachO.h index 4312175..a65d7e0 100644 --- a/llvm/include/llvm/MC/MCSectionMachO.h +++ b/llvm/include/llvm/MC/MCSectionMachO.h @@ -23,6 +23,8 @@ namespace llvm { /// This represents a section on a Mach-O system (used by Mac OS X). On a Mac /// system, these are also described in /usr/include/mach-o/loader.h. class LLVM_ABI MCSectionMachO final : public MCSection { + friend class MCContext; + friend class MCAsmInfoDarwin; char SegmentName[16]; // Not necessarily null terminated! /// This is the SECTION_TYPE and SECTION_ATTRIBUTES field of a section, drawn @@ -42,7 +44,6 @@ class LLVM_ABI MCSectionMachO final : public MCSection { MCSectionMachO(StringRef Segment, StringRef Section, unsigned TAA, unsigned reserved2, SectionKind K, MCSymbol *Begin); - friend class MCContext; public: StringRef getSegmentName() const { @@ -76,21 +77,12 @@ public: bool &TAAParsed, // Out. unsigned &StubSize); // Out. - void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, - raw_ostream &OS, - uint32_t Subsection) const override; - bool useCodeAlign() const override; - void allocAtoms(); const MCSymbol *getAtom(size_t I) const; void setAtom(size_t I, const MCSymbol *Sym); unsigned getLayoutOrder() const { return LayoutOrder; } void setLayoutOrder(unsigned Value) { LayoutOrder = Value; } - - static bool classof(const MCSection *S) { - return S->getVariant() == SV_MachO; - } }; } // end namespace llvm diff --git a/llvm/include/llvm/MC/MCSectionSPIRV.h b/llvm/include/llvm/MC/MCSectionSPIRV.h index 091114a..6850965 100644 --- a/llvm/include/llvm/MC/MCSectionSPIRV.h +++ b/llvm/include/llvm/MC/MCSectionSPIRV.h @@ -18,22 +18,13 @@ namespace llvm { -class MCSymbol; - class MCSectionSPIRV final : public MCSection { friend class MCContext; MCSectionSPIRV() - : MCSection(SV_SPIRV, "", /*IsText=*/true, /*IsVirtual=*/false, + : MCSection("", /*IsText=*/true, /*IsVirtual=*/false, /*Begin=*/nullptr) {} // TODO: Add StringRef Name to MCSectionSPIRV. - -public: - ~MCSectionSPIRV() = default; - void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, - raw_ostream &OS, - uint32_t Subsection) const override {} - bool useCodeAlign() const override { return false; } }; } // end namespace llvm diff --git a/llvm/include/llvm/MC/MCSectionWasm.h b/llvm/include/llvm/MC/MCSectionWasm.h index 4523818..5ec01ed 100644 --- a/llvm/include/llvm/MC/MCSectionWasm.h +++ b/llvm/include/llvm/MC/MCSectionWasm.h @@ -49,26 +49,18 @@ class MCSectionWasm final : public MCSection { // The storage of Name is owned by MCContext's WasmUniquingMap. friend class MCContext; + friend class MCAsmInfoWasm; MCSectionWasm(StringRef Name, SectionKind K, unsigned SegmentFlags, const MCSymbolWasm *Group, unsigned UniqueID, MCSymbol *Begin) - : MCSection(SV_Wasm, Name, K.isText(), /*IsVirtual=*/false, Begin), + : MCSection(Name, K.isText(), /*IsVirtual=*/false, Begin), UniqueID(UniqueID), Group(Group), IsWasmData(K.isReadOnly() || K.isWriteable()), IsMetadata(K.isMetadata()), SegmentFlags(SegmentFlags) {} public: - /// Decides whether a '.section' directive should be printed before the - /// section name - bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const; - const MCSymbolWasm *getGroup() const { return Group; } unsigned getSegmentFlags() const { return SegmentFlags; } - void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, - raw_ostream &OS, - uint32_t Subsection) const override; - bool useCodeAlign() const override; - bool isWasmData() const { return IsWasmData; } bool isMetadata() const { return IsMetadata; } @@ -89,7 +81,6 @@ public: assert(isWasmData()); IsPassive = V; } - static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; } }; } // end namespace llvm diff --git a/llvm/include/llvm/MC/MCSectionXCOFF.h b/llvm/include/llvm/MC/MCSectionXCOFF.h index 499df6b5..0571f95 100644 --- a/llvm/include/llvm/MC/MCSectionXCOFF.h +++ b/llvm/include/llvm/MC/MCSectionXCOFF.h @@ -31,6 +31,7 @@ namespace llvm { // implemented yet. class MCSectionXCOFF final : public MCSection { friend class MCContext; + friend class MCAsmInfoXCOFF; std::optional<XCOFF::CsectProperties> CsectProp; MCSymbolXCOFF *const QualName; @@ -46,7 +47,7 @@ class MCSectionXCOFF final : public MCSection { XCOFF::SymbolType ST, SectionKind K, MCSymbolXCOFF *QualName, MCSymbol *Begin, StringRef SymbolTableName, bool MultiSymbolsAllowed) - : MCSection(SV_XCOFF, Name, K.isText(), + : MCSection(Name, K.isText(), /*IsVirtual=*/ST == XCOFF::XTY_CM && SMC != XCOFF::XMC_TD, Begin), CsectProp(XCOFF::CsectProperties(SMC, ST)), QualName(QualName), @@ -77,7 +78,7 @@ class MCSectionXCOFF final : public MCSection { XCOFF::DwarfSectionSubtypeFlags DwarfSubtypeFlags, MCSymbol *Begin, StringRef SymbolTableName, bool MultiSymbolsAllowed) - : MCSection(SV_XCOFF, Name, K.isText(), /*IsVirtual=*/false, Begin), + : MCSection(Name, K.isText(), /*IsVirtual=*/false, Begin), QualName(QualName), SymbolTableName(SymbolTableName), DwarfSubtypeFlags(DwarfSubtypeFlags), MultiSymbolsAllowed(MultiSymbolsAllowed), Kind(K) { @@ -95,10 +96,6 @@ class MCSectionXCOFF final : public MCSection { public: ~MCSectionXCOFF(); - static bool classof(const MCSection *S) { - return S->getVariant() == SV_XCOFF; - } - XCOFF::StorageMappingClass getMappingClass() const { assert(isCsect() && "Only csect section has mapping class property!"); return CsectProp->MappingClass; @@ -115,10 +112,6 @@ public: } MCSymbolXCOFF *getQualNameSymbol() const { return QualName; } - void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, - raw_ostream &OS, - uint32_t Subsection) const override; - bool useCodeAlign() const override; StringRef getSymbolTableName() const { return SymbolTableName; } void setSymbolTableName(StringRef STN) { SymbolTableName = STN; } bool isMultiSymbolsAllowed() const { return MultiSymbolsAllowed; } diff --git a/llvm/include/llvm/MC/MCSymbolELF.h b/llvm/include/llvm/MC/MCSymbolELF.h index eba9964..7c271e7 100644 --- a/llvm/include/llvm/MC/MCSymbolELF.h +++ b/llvm/include/llvm/MC/MCSymbolELF.h @@ -13,6 +13,7 @@ namespace llvm { class MCSymbolELF : public MCSymbol { + friend class MCAsmInfoELF; /// An expression describing how to calculate the size of a symbol. If a /// symbol has no size this field will be NULL. const MCExpr *SymbolSize = nullptr; diff --git a/llvm/include/llvm/Support/DebugLog.h b/llvm/include/llvm/Support/DebugLog.h index 3e53944..19d3098 100644 --- a/llvm/include/llvm/Support/DebugLog.h +++ b/llvm/include/llvm/Support/DebugLog.h @@ -26,35 +26,107 @@ namespace llvm { // << "] " << "Bitset contains: " << Bitset << "\n"); #define LDBG() DEBUGLOG_WITH_STREAM_AND_TYPE(llvm::dbgs(), DEBUG_TYPE) -#define DEBUGLOG_WITH_STREAM_AND_TYPE(STREAM, TYPE) \ +#define DEBUGLOG_WITH_STREAM_TYPE_AND_FILE(STREAM, TYPE, FILE) \ for (bool _c = (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)); _c; \ _c = false) \ - ::llvm::impl::LogWithNewline(TYPE, __FILE__, __LINE__, (STREAM)) + ::llvm::impl::raw_ldbg_ostream{ \ + ::llvm::impl::computePrefix(TYPE, FILE, __LINE__), (STREAM)} \ + .asLvalue() +// When __SHORT_FILE__ is not defined, the File is the full path, +// otherwise __SHORT_FILE__ is defined in CMake to provide the file name +// without the path prefix. +#if defined(__SHORT_FILE__) +#define DEBUGLOG_WITH_STREAM_AND_TYPE(STREAM, TYPE) \ + DEBUGLOG_WITH_STREAM_TYPE_AND_FILE(STREAM, TYPE, __SHORT_FILE__) +#else +#define DEBUGLOG_WITH_STREAM_AND_TYPE(STREAM, TYPE) \ + DEBUGLOG_WITH_STREAM_TYPE_AND_FILE( \ + STREAM, TYPE, ::llvm::impl::LogWithNewline::getShortFileName(__FILE__)) +#endif namespace impl { -class LogWithNewline { + +/// A raw_ostream that tracks `\n` and print the prefix. +class LLVM_ABI raw_ldbg_ostream final : public raw_ostream { + std::string Prefix; + raw_ostream &Os; + bool HasPendingNewline = true; + + /// Split the line on newlines and insert the prefix before each newline. + /// Forward everything to the underlying stream. + void write_impl(const char *Ptr, size_t Size) final { + auto Str = StringRef(Ptr, Size); + // Handle the initial prefix. + if (!Str.empty()) + writeWithPrefix(StringRef()); + + auto Eol = Str.find('\n'); + while (Eol != StringRef::npos) { + StringRef Line = Str.take_front(Eol + 1); + if (!Line.empty()) + writeWithPrefix(Line); + HasPendingNewline = true; + Str = Str.drop_front(Eol + 1); + Eol = Str.find('\n'); + } + if (!Str.empty()) + writeWithPrefix(Str); + } + void emitPrefix() { Os.write(Prefix.c_str(), Prefix.size()); } + void writeWithPrefix(StringRef Str) { + if (HasPendingNewline) { + emitPrefix(); + HasPendingNewline = false; + } + Os.write(Str.data(), Str.size()); + } + public: - LogWithNewline(const char *debug_type, const char *file, int line, - raw_ostream &os) - : os(os) { - if (debug_type) - os << "[" << debug_type << "] "; - os << file << ":" << line << " "; + explicit raw_ldbg_ostream(std::string Prefix, raw_ostream &Os) + : Prefix(std::move(Prefix)), Os(Os) { + SetUnbuffered(); + } + ~raw_ldbg_ostream() final { + flushEol(); + Os << '\n'; } - ~LogWithNewline() { os << '\n'; } - template <typename T> raw_ostream &operator<<(const T &t) && { - return os << t; + void flushEol() { + if (HasPendingNewline) { + emitPrefix(); + HasPendingNewline = false; + } } - // Prevent copying, as this class manages newline responsibility and is - // intended for use as a temporary. - LogWithNewline(const LogWithNewline &) = delete; - LogWithNewline &operator=(const LogWithNewline &) = delete; - LogWithNewline &operator=(LogWithNewline &&) = delete; + /// Forward the current_pos method to the underlying stream. + uint64_t current_pos() const final { return Os.tell(); } -private: - raw_ostream &os; + /// Some of the `<<` operators expect an lvalue, so we trick the type system. + raw_ldbg_ostream &asLvalue() { return *this; } }; + +/// Remove the path prefix from the file name. +static LLVM_ATTRIBUTE_UNUSED constexpr const char * +getShortFileName(const char *path) { + const char *filename = path; + for (const char *p = path; *p != '\0'; ++p) { + if (*p == '/' || *p == '\\') + filename = p + 1; + } + return filename; +} + +/// Compute the prefix for the debug log in the form of: +/// "[DebugType] File:Line " +/// Where the File is the file name without the path prefix. +static LLVM_ATTRIBUTE_UNUSED std::string +computePrefix(const char *DebugType, const char *File, int Line) { + std::string Prefix; + raw_string_ostream OsPrefix(Prefix); + if (DebugType) + OsPrefix << "[" << DebugType << "] "; + OsPrefix << File << ":" << Line << " "; + return OsPrefix.str(); +} } // end namespace impl #else // As others in Debug, When compiling without assertions, the -debug-* options diff --git a/llvm/include/llvm/Support/ThreadPool.h b/llvm/include/llvm/Support/ThreadPool.h index 9272760..c26681c 100644 --- a/llvm/include/llvm/Support/ThreadPool.h +++ b/llvm/include/llvm/Support/ThreadPool.h @@ -149,10 +149,6 @@ public: /// number of threads! unsigned getMaxConcurrency() const override { return MaxThreadCount; } - // TODO: Remove, misleading legacy name warning! - LLVM_DEPRECATED("Use getMaxConcurrency instead", "getMaxConcurrency") - unsigned getThreadCount() const { return MaxThreadCount; } - /// Returns true if the current thread is a worker thread of this thread pool. bool isWorkerThread() const; @@ -233,10 +229,6 @@ public: /// Returns always 1: there is no concurrency. unsigned getMaxConcurrency() const override { return 1; } - // TODO: Remove, misleading legacy name warning! - LLVM_DEPRECATED("Use getMaxConcurrency instead", "getMaxConcurrency") - unsigned getThreadCount() const { return 1; } - /// Returns true if the current thread is a worker thread of this thread pool. bool isWorkerThread() const; diff --git a/llvm/include/llvm/Transforms/ObjCARC.h b/llvm/include/llvm/Transforms/ObjCARC.h index c927513..c4b4c4f 100644 --- a/llvm/include/llvm/Transforms/ObjCARC.h +++ b/llvm/include/llvm/Transforms/ObjCARC.h @@ -35,10 +35,6 @@ struct ObjCARCContractPass : public PassInfoMixin<ObjCARCContractPass> { LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; -struct ObjCARCAPElimPass : public PassInfoMixin<ObjCARCAPElimPass> { - LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); -}; - struct ObjCARCExpandPass : public PassInfoMixin<ObjCARCExpandPass> { LLVM_ABI PreservedAnalyses run(Function &M, FunctionAnalysisManager &AM); }; |