diff options
Diffstat (limited to 'llvm/include/llvm')
74 files changed, 643 insertions, 327 deletions
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h index 9e2dc1a..956dcbc 100644 --- a/llvm/include/llvm/Analysis/DXILResource.h +++ b/llvm/include/llvm/Analysis/DXILResource.h @@ -359,6 +359,8 @@ public: std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size); } bool overlapsWith(const ResourceBinding &RHS) const { + if (Size == UINT32_MAX) + return LowerBound < RHS.LowerBound; return Space == RHS.Space && LowerBound + Size - 1 >= RHS.LowerBound; } }; diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h index d87457c..17f4112 100644 --- a/llvm/include/llvm/Analysis/IR2Vec.h +++ b/llvm/include/llvm/Analysis/IR2Vec.h @@ -153,6 +153,7 @@ class Vocabulary { static_cast<unsigned>(OperandKind::MaxOperandKind), "OperandKindNames array size must match MaxOperandKind"); +public: /// Vocabulary layout constants #define LAST_OTHER_INST(NUM) static constexpr unsigned MaxOpcodes = NUM; #include "llvm/IR/Instruction.def" @@ -162,39 +163,38 @@ class Vocabulary { static constexpr unsigned MaxOperandKinds = static_cast<unsigned>(OperandKind::MaxOperandKind); -public: Vocabulary() = default; - Vocabulary(VocabVector &&Vocab); + LLVM_ABI Vocabulary(VocabVector &&Vocab); - bool isValid() const; - unsigned getDimension() const; - size_t size() const; + LLVM_ABI bool isValid() const; + LLVM_ABI unsigned getDimension() const; + LLVM_ABI size_t size() const; static size_t expectedSize() { return MaxOpcodes + MaxTypeIDs + MaxOperandKinds; } /// Helper function to get vocabulary key for a given Opcode - static StringRef getVocabKeyForOpcode(unsigned Opcode); + LLVM_ABI static StringRef getVocabKeyForOpcode(unsigned Opcode); /// Helper function to get vocabulary key for a given TypeID - static StringRef getVocabKeyForTypeID(Type::TypeID TypeID); + LLVM_ABI static StringRef getVocabKeyForTypeID(Type::TypeID TypeID); /// Helper function to get vocabulary key for a given OperandKind - static StringRef getVocabKeyForOperandKind(OperandKind Kind); + LLVM_ABI static StringRef getVocabKeyForOperandKind(OperandKind Kind); /// Helper function to classify an operand into OperandKind - static OperandKind getOperandKind(const Value *Op); + LLVM_ABI static OperandKind getOperandKind(const Value *Op); /// Helpers to return the IDs of a given Opcode, TypeID, or OperandKind - static unsigned getNumericID(unsigned Opcode); - static unsigned getNumericID(Type::TypeID TypeID); - static unsigned getNumericID(const Value *Op); + LLVM_ABI static unsigned getNumericID(unsigned Opcode); + LLVM_ABI static unsigned getNumericID(Type::TypeID TypeID); + LLVM_ABI static unsigned getNumericID(const Value *Op); /// Accessors to get the embedding for a given entity. - const ir2vec::Embedding &operator[](unsigned Opcode) const; - const ir2vec::Embedding &operator[](Type::TypeID TypeId) const; - const ir2vec::Embedding &operator[](const Value *Arg) const; + LLVM_ABI const ir2vec::Embedding &operator[](unsigned Opcode) const; + LLVM_ABI const ir2vec::Embedding &operator[](Type::TypeID TypeId) const; + LLVM_ABI const ir2vec::Embedding &operator[](const Value *Arg) const; /// Const Iterator type aliases using const_iterator = VocabVector::const_iterator; @@ -221,13 +221,13 @@ public: /// Returns the string key for a given index position in the vocabulary. /// This is useful for debugging or printing the vocabulary. Do not use this /// for embedding generation as string based lookups are inefficient. - static StringRef getStringKey(unsigned Pos); + LLVM_ABI static StringRef getStringKey(unsigned Pos); /// Create a dummy vocabulary for testing purposes. - static VocabVector createDummyVocabForTest(unsigned Dim = 1); + LLVM_ABI static VocabVector createDummyVocabForTest(unsigned Dim = 1); - bool invalidate(Module &M, const PreservedAnalyses &PA, - ModuleAnalysisManager::Invalidator &Inv) const; + LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA, + ModuleAnalysisManager::Invalidator &Inv) const; }; /// Embedder provides the interface to generate embeddings (vector diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h b/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h index 09e3945..bff7707 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h @@ -160,6 +160,12 @@ m_scev_ZExt(const Op0_t &Op0) { return m_scev_Unary<SCEVZeroExtendExpr>(Op0); } +template <typename Op0_t> +inline SCEVUnaryExpr_match<SCEVPtrToIntExpr, Op0_t> +m_scev_PtrToInt(const Op0_t &Op0) { + return SCEVUnaryExpr_match<SCEVPtrToIntExpr, Op0_t>(Op0); +} + /// Match a binary SCEV. template <typename SCEVTy, typename Op0_t, typename Op1_t> struct SCEVBinaryExpr_match { diff --git a/llvm/include/llvm/Analysis/VectorUtils.h b/llvm/include/llvm/Analysis/VectorUtils.h index 9a2773c..b55c4e0 100644 --- a/llvm/include/llvm/Analysis/VectorUtils.h +++ b/llvm/include/llvm/Analysis/VectorUtils.h @@ -177,12 +177,6 @@ LLVM_ABI bool isVectorIntrinsicWithStructReturnOverloadAtField( LLVM_ABI Intrinsic::ID getVectorIntrinsicIDForCall(const CallInst *CI, const TargetLibraryInfo *TLI); -/// Returns the corresponding llvm.vector.interleaveN intrinsic for factor N. -LLVM_ABI Intrinsic::ID getInterleaveIntrinsicID(unsigned Factor); - -/// Returns the corresponding llvm.vector.deinterleaveN intrinsic for factor N. -LLVM_ABI Intrinsic::ID getDeinterleaveIntrinsicID(unsigned Factor); - /// Returns the corresponding factor of llvm.vector.interleaveN intrinsics. LLVM_ABI unsigned getInterleaveIntrinsicFactor(Intrinsic::ID ID); diff --git a/llvm/include/llvm/BinaryFormat/COFF.h b/llvm/include/llvm/BinaryFormat/COFF.h index f3b5d5e..64fe216 100644 --- a/llvm/include/llvm/BinaryFormat/COFF.h +++ b/llvm/include/llvm/BinaryFormat/COFF.h @@ -694,7 +694,24 @@ enum DLLCharacteristics : unsigned { enum ExtendedDLLCharacteristics : unsigned { /// Image is CET compatible - IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT = 0x0001 + IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT = 0x0001, + /// Image is CET compatible in strict mode + IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT_STRICT_MODE = 0x0002, + /// Image is CET compatible in such a way that context IP validation is + /// relaxed + IMAGE_DLL_CHARACTERISTICS_EX_CET_SET_CONTEXT_IP_VALIDATION_RELAXED_MODE = + 0x0004, + /// Image is CET compatible in such a way that the use of + /// dynamic APIs is restricted to processes only + IMAGE_DLL_CHARACTERISTICS_EX_CET_DYNAMIC_APIS_ALLOW_IN_PROC_ONLY = 0x0008, + /// Reserved for future use. Not used by MSVC link.exe + IMAGE_DLL_CHARACTERISTICS_EX_CET_RESERVED_1 = 0x0010, + /// Reserved for future use. Not used by MSVC link.exe + IMAGE_DLL_CHARACTERISTICS_EX_CET_RESERVED_2 = 0x0020, + /// Image is CFI compatible. + IMAGE_DLL_CHARACTERISTICS_EX_FORWARD_CFI_COMPAT = 0x0040, + /// Image is hotpatch compatible. + IMAGE_DLL_CHARACTERISTICS_EX_HOTPATCH_COMPATIBLE = 0x0080, }; enum DebugType : unsigned { diff --git a/llvm/include/llvm/BinaryFormat/SFrame.h b/llvm/include/llvm/BinaryFormat/SFrame.h index 98dbe38..0c6c4d1 100644 --- a/llvm/include/llvm/BinaryFormat/SFrame.h +++ b/llvm/include/llvm/BinaryFormat/SFrame.h @@ -17,6 +17,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitmaskEnum.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Endian.h" @@ -49,29 +50,27 @@ enum class ABI : uint8_t { /// SFrame FRE Types. Bits 0-3 of FuncDescEntry.Info. enum class FREType : uint8_t { - Addr1 = 0, - Addr2 = 1, - Addr4 = 2, +#define HANDLE_SFRAME_FRE_TYPE(CODE, NAME) NAME = CODE, +#include "llvm/BinaryFormat/SFrameConstants.def" }; /// SFrame FDE Types. Bit 4 of FuncDescEntry.Info. enum class FDEType : uint8_t { - PCInc = 0, - PCMask = 1, +#define HANDLE_SFRAME_FDE_TYPE(CODE, NAME) NAME = CODE, +#include "llvm/BinaryFormat/SFrameConstants.def" }; /// Speficies key used for signing return addresses. Bit 5 of /// FuncDescEntry.Info. enum class AArch64PAuthKey : uint8_t { - A = 0, - B = 1, +#define HANDLE_SFRAME_AARCH64_PAUTH_KEY(CODE, NAME) NAME = CODE, +#include "llvm/BinaryFormat/SFrameConstants.def" }; -/// Size of stack offsets. Bits 5-6 of FREInfo.Info. +/// Size of stack offsets. Bits 6-7 of FREInfo.Info. enum class FREOffset : uint8_t { - B1 = 0, - B2 = 1, - B4 = 2, +#define HANDLE_SFRAME_FRE_OFFSET(CODE, NAME) NAME = CODE, +#include "llvm/BinaryFormat/SFrameConstants.def" }; /// Stack frame base register. Bit 0 of FREInfo.Info. @@ -163,9 +162,13 @@ template <endianness E> using FrameRowEntryAddr1 = FrameRowEntry<uint8_t, E>; template <endianness E> using FrameRowEntryAddr2 = FrameRowEntry<uint16_t, E>; template <endianness E> using FrameRowEntryAddr4 = FrameRowEntry<uint32_t, E>; -ArrayRef<EnumEntry<Version>> getVersions(); -ArrayRef<EnumEntry<Flags>> getFlags(); -ArrayRef<EnumEntry<ABI>> getABIs(); +LLVM_ABI ArrayRef<EnumEntry<Version>> getVersions(); +LLVM_ABI ArrayRef<EnumEntry<Flags>> getFlags(); +LLVM_ABI ArrayRef<EnumEntry<ABI>> getABIs(); +LLVM_ABI ArrayRef<EnumEntry<FREType>> getFRETypes(); +LLVM_ABI ArrayRef<EnumEntry<FDEType>> getFDETypes(); +LLVM_ABI ArrayRef<EnumEntry<AArch64PAuthKey>> getAArch64PAuthKeys(); +LLVM_ABI ArrayRef<EnumEntry<FREOffset>> getFREOffsets(); } // namespace sframe } // namespace llvm diff --git a/llvm/include/llvm/BinaryFormat/SFrameConstants.def b/llvm/include/llvm/BinaryFormat/SFrameConstants.def index 643b15f..fddd440 100644 --- a/llvm/include/llvm/BinaryFormat/SFrameConstants.def +++ b/llvm/include/llvm/BinaryFormat/SFrameConstants.def @@ -6,8 +6,11 @@ // //===----------------------------------------------------------------------===// -#if !(defined(HANDLE_SFRAME_VERSION) || defined(HANDLE_SFRAME_FLAG) || \ - defined(HANDLE_SFRAME_ABI)) +#if !(defined(HANDLE_SFRAME_VERSION) || defined(HANDLE_SFRAME_FLAG) || \ + defined(HANDLE_SFRAME_ABI) || defined(HANDLE_SFRAME_FRE_TYPE) || \ + defined(HANDLE_SFRAME_FDE_TYPE) || \ + defined(HANDLE_SFRAME_AARCH64_PAUTH_KEY) || \ + defined(HANDLE_SFRAME_FRE_OFFSET)) #error "Missing HANDLE_SFRAME definition" #endif @@ -23,6 +26,22 @@ #define HANDLE_SFRAME_ABI(CODE, NAME) #endif +#ifndef HANDLE_SFRAME_FRE_TYPE +#define HANDLE_SFRAME_FRE_TYPE(CODE, NAME) +#endif + +#ifndef HANDLE_SFRAME_FDE_TYPE +#define HANDLE_SFRAME_FDE_TYPE(CODE, NAME) +#endif + +#ifndef HANDLE_SFRAME_AARCH64_PAUTH_KEY +#define HANDLE_SFRAME_AARCH64_PAUTH_KEY(CODE, NAME) +#endif + +#ifndef HANDLE_SFRAME_FRE_OFFSET +#define HANDLE_SFRAME_FRE_OFFSET(CODE, NAME) +#endif + HANDLE_SFRAME_VERSION(0x01, V1) HANDLE_SFRAME_VERSION(0x02, V2) @@ -34,6 +53,24 @@ HANDLE_SFRAME_ABI(0x01, AArch64EndianBig) HANDLE_SFRAME_ABI(0x02, AArch64EndianLittle) HANDLE_SFRAME_ABI(0x03, AMD64EndianLittle) +HANDLE_SFRAME_FRE_TYPE(0x00, Addr1) +HANDLE_SFRAME_FRE_TYPE(0x01, Addr2) +HANDLE_SFRAME_FRE_TYPE(0x02, Addr4) + +HANDLE_SFRAME_FDE_TYPE(0, PCInc) +HANDLE_SFRAME_FDE_TYPE(1, PCMask) + +HANDLE_SFRAME_AARCH64_PAUTH_KEY(0, A) +HANDLE_SFRAME_AARCH64_PAUTH_KEY(1, B) + +HANDLE_SFRAME_FRE_OFFSET(0, B1) +HANDLE_SFRAME_FRE_OFFSET(1, B2) +HANDLE_SFRAME_FRE_OFFSET(2, B4) + #undef HANDLE_SFRAME_VERSION #undef HANDLE_SFRAME_FLAG #undef HANDLE_SFRAME_ABI +#undef HANDLE_SFRAME_FRE_TYPE +#undef HANDLE_SFRAME_FDE_TYPE +#undef HANDLE_SFRAME_AARCH64_PAUTH_KEY +#undef HANDLE_SFRAME_FRE_OFFSET diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h index aefdb53..d500e94 100644 --- a/llvm/include/llvm/CodeGen/CommandFlags.h +++ b/llvm/include/llvm/CodeGen/CommandFlags.h @@ -133,6 +133,8 @@ LLVM_ABI bool getEnableStackSizeSection(); LLVM_ABI bool getEnableAddrsig(); +LLVM_ABI bool getEnableCallGraphSection(); + LLVM_ABI bool getEmitCallSiteInfo(); LLVM_ABI bool getEnableMachineFunctionSplitter(); diff --git a/llvm/include/llvm/CodeGen/GCMetadata.h b/llvm/include/llvm/CodeGen/GCMetadata.h index 33f5301..5b9ee28 100644 --- a/llvm/include/llvm/CodeGen/GCMetadata.h +++ b/llvm/include/llvm/CodeGen/GCMetadata.h @@ -101,12 +101,12 @@ private: // are live per safe point (1.5% on 64-bit hosts). public: - GCFunctionInfo(const Function &F, GCStrategy &S); - ~GCFunctionInfo(); + LLVM_ABI GCFunctionInfo(const Function &F, GCStrategy &S); + LLVM_ABI ~GCFunctionInfo(); /// Handle invalidation explicitly. - bool invalidate(Function &F, const PreservedAnalyses &PA, - FunctionAnalysisManager::Invalidator &Inv); + LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &Inv); /// getFunction - Return the function to which this metadata applies. const Function &getFunction() const { return F; } @@ -163,8 +163,8 @@ public: GCStrategyMap(GCStrategyMap &&) = default; /// Handle invalidation explicitly. - bool invalidate(Module &M, const PreservedAnalyses &PA, - ModuleAnalysisManager::Invalidator &Inv); + LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA, + ModuleAnalysisManager::Invalidator &Inv); using iterator = MapT::iterator; using const_iterator = MapT::const_iterator; @@ -205,7 +205,7 @@ class CollectorMetadataAnalysis public: using Result = GCStrategyMap; - Result run(Module &M, ModuleAnalysisManager &MAM); + LLVM_ABI Result run(Module &M, ModuleAnalysisManager &MAM); }; /// An analysis pass which caches information about the Function. @@ -217,7 +217,7 @@ class GCFunctionAnalysis : public AnalysisInfoMixin<GCFunctionAnalysis> { public: using Result = GCFunctionInfo; - Result run(Function &F, FunctionAnalysisManager &FAM); + LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM); }; /// LowerIntrinsics - This pass rewrites calls to the llvm.gcread or @@ -228,7 +228,7 @@ public: /// This pass requires `CollectorMetadataAnalysis`. class GCLoweringPass : public PassInfoMixin<GCLoweringPass> { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); }; /// An analysis pass which caches information about the entire Module. @@ -244,7 +244,7 @@ public: /// Lookup the GCStrategy object associated with the given gc name. /// Objects are owned internally; No caller should attempt to delete the /// returned objects. - GCStrategy *getGCStrategy(const StringRef Name); + LLVM_ABI GCStrategy *getGCStrategy(const StringRef Name); /// List of per function info objects. In theory, Each of these /// may be associated with a different GC. @@ -265,14 +265,14 @@ private: public: using iterator = SmallVector<std::unique_ptr<GCStrategy>, 1>::const_iterator; - static char ID; + LLVM_ABI static char ID; - GCModuleInfo(); + LLVM_ABI GCModuleInfo(); /// clear - Resets the pass. Any pass, which uses GCModuleInfo, should /// call it in doFinalization(). /// - void clear(); + LLVM_ABI void clear(); /// begin/end - Iterators for used strategies. /// @@ -282,7 +282,7 @@ public: /// get - Look up function metadata. This is currently assumed /// have the side effect of initializing the associated GCStrategy. That /// will soon change. - GCFunctionInfo &getFunctionInfo(const Function &F); + LLVM_ABI GCFunctionInfo &getFunctionInfo(const Function &F); }; } // end namespace llvm diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h b/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h index 571ec6d..4292c0b 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h @@ -26,9 +26,9 @@ namespace llvm { /// A base class for all GenericMachineInstrs. class GenericMachineInstr : public MachineInstr { - constexpr static unsigned PoisonFlags = NoUWrap | NoSWrap | NoUSWrap | - IsExact | Disjoint | NonNeg | - FmNoNans | FmNoInfs | SameSign; + constexpr static unsigned PoisonFlags = + NoUWrap | NoSWrap | NoUSWrap | IsExact | Disjoint | NonNeg | FmNoNans | + FmNoInfs | SameSign | InBounds; public: GenericMachineInstr() = delete; diff --git a/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h b/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h index 756c0b2..99d3cd0 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h @@ -518,6 +518,21 @@ public: const SrcOp &Op1, std::optional<unsigned> Flags = std::nullopt); + /// Build and insert an instruction with appropriate flags for addressing some + /// offset of an object, i.e.: \p Res = nuw inbounds G_PTR_ADD \p Op0, \p Op1 + /// The value of \p Op0 must be a pointer into or just after an object, adding + /// the value of \p Op1 to it must yield to a pointer into or just after the + /// same object. + /// + /// \pre setBasicBlock or setMI must have been called. + /// \pre \p Res and \p Op0 must be generic virtual registers with pointer + /// type. + /// \pre \p Op1 must be a generic virtual register with scalar type. + /// + /// \return a MachineInstrBuilder for the newly created instruction. + MachineInstrBuilder buildObjectPtrOffset(const DstOp &Res, const SrcOp &Op0, + const SrcOp &Op1); + /// Materialize and insert \p Res = G_PTR_ADD \p Op0, (G_CONSTANT \p Value) /// /// G_PTR_ADD adds \p Value bytes to the pointer specified by \p Op0, @@ -534,10 +549,29 @@ public: /// type as \p Op0 or \p Op0 itself. /// /// \return a MachineInstrBuilder for the newly created instruction. - std::optional<MachineInstrBuilder> materializePtrAdd(Register &Res, - Register Op0, - const LLT ValueTy, - uint64_t Value); + std::optional<MachineInstrBuilder> + materializePtrAdd(Register &Res, Register Op0, const LLT ValueTy, + uint64_t Value, + std::optional<unsigned> Flags = std::nullopt); + + /// Materialize and insert an instruction with appropriate flags for + /// addressing some offset of an object, i.e.: + /// \p Res = nuw inbounds G_PTR_ADD \p Op0, (G_CONSTANT \p Value) + /// The value of \p Op0 must be a pointer into or just after an object, adding + /// \p Value to it must yield to a pointer into or just after the same object. + /// + /// \pre setBasicBlock or setMI must have been called. + /// \pre \p Op0 must be a generic virtual register with pointer type. + /// \pre \p ValueTy must be a scalar type. + /// \pre \p Res must be 0. This is to detect confusion between + /// materializeObjectPtrOffset() and buildObjectPtrOffset(). + /// \post \p Res will either be a new generic virtual register of the same + /// type as \p Op0 or \p Op0 itself. + /// + /// \return a MachineInstrBuilder for the newly created instruction. + std::optional<MachineInstrBuilder> + materializeObjectPtrOffset(Register &Res, Register Op0, const LLT ValueTy, + uint64_t Value); /// Build and insert \p Res = G_PTRMASK \p Op0, \p Op1 MachineInstrBuilder buildPtrMask(const DstOp &Res, const SrcOp &Op0, diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h index 119786f..0f3f945 100644 --- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h +++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h @@ -482,6 +482,8 @@ struct CallSiteInfo { MachineInstrLoc CallLocation; std::vector<ArgRegPair> ArgForwardingRegs; + /// Numeric callee type identifiers for the callgraph section. + std::vector<uint64_t> CalleeTypeIds; bool operator==(const CallSiteInfo &Other) const { return CallLocation.BlockNum == Other.CallLocation.BlockNum && @@ -511,6 +513,7 @@ template <> struct MappingTraits<CallSiteInfo> { YamlIO.mapRequired("offset", CSInfo.CallLocation.Offset); YamlIO.mapOptional("fwdArgRegs", CSInfo.ArgForwardingRegs, std::vector<CallSiteInfo::ArgRegPair>()); + YamlIO.mapOptional("calleeTypeIds", CSInfo.CalleeTypeIds); } static const bool flow = true; diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index e5958ec..7f88323 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -515,6 +515,8 @@ public: struct CallSiteInfo { /// Vector of call argument and its forwarding register. SmallVector<ArgRegPair, 1> ArgRegPairs; + /// Callee type ids. + SmallVector<ConstantInt *, 4> CalleeTypeIds; }; struct CalledGlobalInfo { diff --git a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h index 1d954cf..1982ac6 100644 --- a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h +++ b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h @@ -48,7 +48,7 @@ public: class FreeMachineFunctionPass : public PassInfoMixin<FreeMachineFunctionPass> { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); }; } // namespace llvm diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h index 94d04b8..10a9b1f 100644 --- a/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/llvm/include/llvm/CodeGen/MachineInstr.h @@ -122,7 +122,9 @@ public: Disjoint = 1 << 19, // Each bit is zero in at least one of the inputs. NoUSWrap = 1 << 20, // Instruction supports geps // no unsigned signed wrap. - SameSign = 1 << 21 // Both operands have the same sign. + SameSign = 1 << 21, // Both operands have the same sign. + InBounds = 1 << 22 // Pointer arithmetic remains inbounds. + // Implies NoUSWrap. }; private: diff --git a/llvm/include/llvm/CodeGen/MachineInstrBundle.h b/llvm/include/llvm/CodeGen/MachineInstrBundle.h index ebf7534..65eb5c4 100644 --- a/llvm/include/llvm/CodeGen/MachineInstrBundle.h +++ b/llvm/include/llvm/CodeGen/MachineInstrBundle.h @@ -297,8 +297,8 @@ LLVM_ABI PhysRegInfo AnalyzePhysRegInBundle(const MachineInstr &MI, class FinalizeBundleTestPass : public PassInfoMixin<FinalizeBundleTestPass> { public: - PreservedAnalyses run(MachineFunction &MF, - MachineFunctionAnalysisManager &MFAM); + LLVM_ABI PreservedAnalyses run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM); }; } // End llvm namespace diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index eac8e14..e5644a5 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -1428,10 +1428,9 @@ public: EVT MemVT, MachineMemOperand *MMO); /// Creates a LifetimeSDNode that starts (`IsStart==true`) or ends - /// (`IsStart==false`) the lifetime of the portion of `FrameIndex` between - /// offsets `0` and `Size`. + /// (`IsStart==false`) the lifetime of the `FrameIndex`. LLVM_ABI SDValue getLifetimeNode(bool IsStart, const SDLoc &dl, SDValue Chain, - int FrameIndex, int64_t Size); + int FrameIndex); /// Creates a PseudoProbeSDNode with function GUID `Guid` and /// the index of the block `Index` it is probing, as well as the attributes diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h index 8e9c1f7..8f88811 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1999,23 +1999,19 @@ public: } }; -/// This SDNode is used for LIFETIME_START/LIFETIME_END values, which indicate -/// the offet and size that are started/ended in the underlying FrameIndex. +/// This SDNode is used for LIFETIME_START/LIFETIME_END values. class LifetimeSDNode : public SDNode { friend class SelectionDAG; - int64_t Size; LifetimeSDNode(unsigned Opcode, unsigned Order, const DebugLoc &dl, - SDVTList VTs, int64_t Size) - : SDNode(Opcode, Order, dl, VTs), Size(Size) {} + SDVTList VTs) + : SDNode(Opcode, Order, dl, VTs) {} public: int64_t getFrameIndex() const { return cast<FrameIndexSDNode>(getOperand(1))->getIndex(); } - int64_t getSize() const { return Size; } - // Methods to support isa and dyn_cast static bool classof(const SDNode *N) { return N->getOpcode() == ISD::LIFETIME_START || 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/Demangle/DemangleConfig.h b/llvm/include/llvm/Demangle/DemangleConfig.h index 8807a0e..912c9b8 100644 --- a/llvm/include/llvm/Demangle/DemangleConfig.h +++ b/llvm/include/llvm/Demangle/DemangleConfig.h @@ -15,6 +15,9 @@ #ifndef LLVM_DEMANGLE_DEMANGLECONFIG_H #define LLVM_DEMANGLE_DEMANGLECONFIG_H +// llvm-config.h is required for LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS +#include "llvm/Config/llvm-config.h" + #ifndef __has_feature #define __has_feature(x) 0 #endif @@ -103,7 +106,7 @@ #if defined(LLVM_EXPORTS) #define DEMANGLE_ABI __declspec(dllexport) #else -#define DEMANGLE_ABI__declspec(dllimport) +#define DEMANGLE_ABI __declspec(dllimport) #endif #else #if __has_attribute(visibility) diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h index 2834331..b865e02 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h @@ -17,6 +17,7 @@ #include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h" #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h" #include "llvm/ExecutionEngine/Orc/LazyReexports.h" +#include "llvm/Support/Compiler.h" #include <mutex> @@ -33,7 +34,7 @@ class EPCIndirectionUtils { public: /// ABI support base class. Used to write resolver, stub, and trampoline /// blocks. - class ABISupport { + class LLVM_ABI ABISupport { protected: ABISupport(unsigned PointerSize, unsigned TrampolineSize, unsigned StubSize, unsigned StubToPointerMaxDisplacement, unsigned ResolverCodeSize) @@ -81,7 +82,7 @@ public: CreateWithABI(ExecutorProcessControl &EPC); /// Create based on the ExecutorProcessControl triple. - static Expected<std::unique_ptr<EPCIndirectionUtils>> + LLVM_ABI static Expected<std::unique_ptr<EPCIndirectionUtils>> Create(ExecutorProcessControl &EPC); /// Create based on the ExecutorProcessControl triple. @@ -98,27 +99,27 @@ public: /// Release memory for resources held by this instance. This *must* be called /// prior to destruction of the class. - Error cleanup(); + LLVM_ABI Error cleanup(); /// Write resolver code to the executor process and return its address. /// This must be called before any call to createTrampolinePool or /// createLazyCallThroughManager. - Expected<ExecutorAddr> writeResolverBlock(ExecutorAddr ReentryFnAddr, - ExecutorAddr ReentryCtxAddr); + LLVM_ABI Expected<ExecutorAddr> + writeResolverBlock(ExecutorAddr ReentryFnAddr, ExecutorAddr ReentryCtxAddr); /// Returns the address of the Resolver block. Returns zero if the /// writeResolverBlock method has not previously been called. ExecutorAddr getResolverBlockAddress() const { return ResolverBlockAddr; } /// Create an IndirectStubsManager for the executor process. - std::unique_ptr<IndirectStubsManager> createIndirectStubsManager(); + LLVM_ABI std::unique_ptr<IndirectStubsManager> createIndirectStubsManager(); /// Create a TrampolinePool for the executor process. - TrampolinePool &getTrampolinePool(); + LLVM_ABI TrampolinePool &getTrampolinePool(); /// Create a LazyCallThroughManager. /// This function should only be called once. - LazyCallThroughManager & + LLVM_ABI LazyCallThroughManager & createLazyCallThroughManager(ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr); @@ -170,7 +171,7 @@ private: /// called. /// /// This function is experimental and likely subject to revision. -Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU); +LLVM_ABI Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU); namespace detail { diff --git a/llvm/include/llvm/ExecutionEngine/Orc/SpeculateAnalyses.h b/llvm/include/llvm/ExecutionEngine/Orc/SpeculateAnalyses.h index c92719e..a9f5c45 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/SpeculateAnalyses.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/SpeculateAnalyses.h @@ -16,6 +16,7 @@ #include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/Speculation.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -24,8 +25,8 @@ namespace orc { // Provides common code. class SpeculateQuery { protected: - void findCalles(const BasicBlock *, DenseSet<StringRef> &); - bool isStraightLine(const Function &F); + LLVM_ABI void findCalles(const BasicBlock *, DenseSet<StringRef> &); + LLVM_ABI bool isStraightLine(const Function &F); public: using ResultTy = std::optional<DenseMap<StringRef, DenseSet<StringRef>>>; @@ -37,7 +38,7 @@ class BlockFreqQuery : public SpeculateQuery { public: // Find likely next executables based on IR Block Frequency - ResultTy operator()(Function &F); + LLVM_ABI ResultTy operator()(Function &F); }; // This Query generates a sequence of basic blocks which follows the order of @@ -73,7 +74,7 @@ private: VisitedBlocksInfoTy &); public: - ResultTy operator()(Function &F); + LLVM_ABI ResultTy operator()(Function &F); }; } // namespace orc diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index 862be04..5f7225e 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -68,6 +68,7 @@ enum DiagnosticKind { DK_StackSize, DK_Linker, DK_Lowering, + DK_LegalizationFailure, DK_DebugMetadataVersion, DK_DebugMetadataInvalid, DK_Instrumentation, @@ -383,6 +384,30 @@ private: DiagnosticLocation Loc; }; +class LLVM_ABI DiagnosticInfoLegalizationFailure + : public DiagnosticInfoWithLocationBase { +private: + /// Message to be reported. + const Twine &MsgStr; + +public: + DiagnosticInfoLegalizationFailure(const Twine &MsgStr LLVM_LIFETIME_BOUND, + const Function &Fn, + const DiagnosticLocation &Loc, + DiagnosticSeverity Severity = DS_Error) + : DiagnosticInfoWithLocationBase(DK_LegalizationFailure, Severity, Fn, + Loc), + MsgStr(MsgStr) {} + + const Twine &getMsgStr() const { return MsgStr; } + + void print(DiagnosticPrinter &DP) const override; + + static bool classof(const DiagnosticInfo *DI) { + return DI->getKind() == DK_LegalizationFailure; + } +}; + class LLVM_ABI DiagnosticInfoGenericWithLoc : public DiagnosticInfoWithLocationBase { private: diff --git a/llvm/include/llvm/IR/GCStrategy.h b/llvm/include/llvm/IR/GCStrategy.h index 6b81355..44e46e4 100644 --- a/llvm/include/llvm/IR/GCStrategy.h +++ b/llvm/include/llvm/IR/GCStrategy.h @@ -47,6 +47,7 @@ #ifndef LLVM_IR_GCSTRATEGY_H #define LLVM_IR_GCSTRATEGY_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/Registry.h" #include <optional> #include <string> @@ -81,7 +82,7 @@ protected: bool UsesMetadata = false; ///< If set, backend must emit metadata tables. public: - GCStrategy(); + LLVM_ABI GCStrategy(); virtual ~GCStrategy() = default; /// Return the name of the GC strategy. This is the value of the collector @@ -145,7 +146,7 @@ using GCRegistry = Registry<GCStrategy>; extern template class LLVM_TEMPLATE_ABI Registry<GCStrategy>; /// Lookup the GCStrategy object associated with the given gc name. -std::unique_ptr<GCStrategy> getGCStrategy(const StringRef Name); +LLVM_ABI std::unique_ptr<GCStrategy> getGCStrategy(const StringRef Name); } // end namespace llvm diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 7c600e7..6d3d864 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -2614,6 +2614,8 @@ public: return CreateShuffleVector(V, PoisonValue::get(V->getType()), Mask, Name); } + Value *CreateVectorInterleave(ArrayRef<Value *> Ops, const Twine &Name = ""); + Value *CreateExtractValue(Value *Agg, ArrayRef<unsigned> Idxs, const Twine &Name = "") { if (auto *V = Folder.FoldExtractValue(Agg, Idxs)) diff --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h index 1568052..48735b0 100644 --- a/llvm/include/llvm/IR/Intrinsics.h +++ b/llvm/include/llvm/IR/Intrinsics.h @@ -283,8 +283,15 @@ namespace Intrinsic { // or of the wrong kind will be renamed by adding ".renamed" to the name. LLVM_ABI std::optional<Function *> remangleIntrinsicFunction(Function *F); -} // End Intrinsic namespace + /// Returns the corresponding llvm.vector.interleaveN intrinsic for factor N. + LLVM_ABI Intrinsic::ID getInterleaveIntrinsicID(unsigned Factor); -} // End llvm namespace + /// Returns the corresponding llvm.vector.deinterleaveN intrinsic for factor + /// N. + LLVM_ABI Intrinsic::ID getDeinterleaveIntrinsicID(unsigned Factor); + + } // namespace Intrinsic + + } // namespace llvm #endif diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td index 3a7db6d..1da4e36 100644 --- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td +++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td @@ -3643,6 +3643,50 @@ def int_amdgcn_fdiv_fast : DefaultAttrsIntrinsic< [IntrNoMem, IntrSpeculatable] >; +class AMDGPUAsyncGlobalLoadToLDS : Intrinsic < + [], + [global_ptr_ty, // Base global pointer to load from + local_ptr_ty, // LDS base pointer to store to. + llvm_i32_ty, // offset + llvm_i32_ty], // gfx12+ cachepolicy: + // bits [0-2] = th + // bits [3-4] = scope + [IntrInaccessibleMemOrArgMemOnly, ReadOnly<ArgIndex<0>>, WriteOnly<ArgIndex<1>>, NoCapture<ArgIndex<0>>, + NoCapture<ArgIndex<1>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>, IntrWillReturn, IntrNoCallback, IntrNoFree], + "", [SDNPMemOperand] +>; + +class AMDGPUAsyncGlobalStoreFromLDS : Intrinsic < + [], + [global_ptr_ty, // Base global pointer to store to + local_ptr_ty, // LDS base pointer to load from + llvm_i32_ty, // offset + llvm_i32_ty], // gfx12+ cachepolicy: + // bits [0-2] = th + // bits [3-4] = scope + [IntrInaccessibleMemOrArgMemOnly, WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>, NoCapture<ArgIndex<0>>, + NoCapture<ArgIndex<1>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>, IntrWillReturn, IntrNoCallback, IntrNoFree], + "", [SDNPMemOperand] +>; + +def int_amdgcn_global_load_async_to_lds_b8 : + ClangBuiltin<"__builtin_amdgcn_global_load_async_to_lds_b8">, AMDGPUAsyncGlobalLoadToLDS; +def int_amdgcn_global_load_async_to_lds_b32 : + ClangBuiltin<"__builtin_amdgcn_global_load_async_to_lds_b32">, AMDGPUAsyncGlobalLoadToLDS; +def int_amdgcn_global_load_async_to_lds_b64 : + ClangBuiltin<"__builtin_amdgcn_global_load_async_to_lds_b64">, AMDGPUAsyncGlobalLoadToLDS; +def int_amdgcn_global_load_async_to_lds_b128 : + ClangBuiltin<"__builtin_amdgcn_global_load_async_to_lds_b128">, AMDGPUAsyncGlobalLoadToLDS; + +def int_amdgcn_global_store_async_from_lds_b8 : + ClangBuiltin<"__builtin_amdgcn_global_store_async_from_lds_b8">, AMDGPUAsyncGlobalStoreFromLDS; +def int_amdgcn_global_store_async_from_lds_b32 : + ClangBuiltin<"__builtin_amdgcn_global_store_async_from_lds_b32">, AMDGPUAsyncGlobalStoreFromLDS; +def int_amdgcn_global_store_async_from_lds_b64 : + ClangBuiltin<"__builtin_amdgcn_global_store_async_from_lds_b64">, AMDGPUAsyncGlobalStoreFromLDS; +def int_amdgcn_global_store_async_from_lds_b128 : + ClangBuiltin<"__builtin_amdgcn_global_store_async_from_lds_b128">, AMDGPUAsyncGlobalStoreFromLDS; + // WMMA intrinsics. class AMDGPUWmmaIntrinsicModsAB<LLVMType AB, LLVMType CD> : Intrinsic< diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h index af252aa..33203ad 100644 --- a/llvm/include/llvm/IR/Metadata.h +++ b/llvm/include/llvm/IR/Metadata.h @@ -759,18 +759,18 @@ public: /// memory access used by the alias-analysis infrastructure. struct AAMDNodes { explicit AAMDNodes() = default; - explicit AAMDNodes(MDNode *T, MDNode *TS, MDNode *S, MDNode *N) - : TBAA(T), TBAAStruct(TS), Scope(S), NoAlias(N) {} + explicit AAMDNodes(MDNode *T, MDNode *TS, MDNode *S, MDNode *N, MDNode *NAS) + : TBAA(T), TBAAStruct(TS), Scope(S), NoAlias(N), NoAliasAddrSpace(NAS) {} bool operator==(const AAMDNodes &A) const { return TBAA == A.TBAA && TBAAStruct == A.TBAAStruct && Scope == A.Scope && - NoAlias == A.NoAlias; + NoAlias == A.NoAlias && NoAliasAddrSpace == A.NoAliasAddrSpace; } bool operator!=(const AAMDNodes &A) const { return !(*this == A); } explicit operator bool() const { - return TBAA || TBAAStruct || Scope || NoAlias; + return TBAA || TBAAStruct || Scope || NoAlias || NoAliasAddrSpace; } /// The tag for type-based alias analysis. @@ -785,6 +785,9 @@ struct AAMDNodes { /// The tag specifying the noalias scope. MDNode *NoAlias = nullptr; + /// The tag specifying the noalias address spaces. + MDNode *NoAliasAddrSpace = nullptr; + // Shift tbaa Metadata node to start off bytes later LLVM_ABI static MDNode *shiftTBAA(MDNode *M, size_t off); @@ -806,6 +809,8 @@ struct AAMDNodes { Result.TBAAStruct = Other.TBAAStruct == TBAAStruct ? TBAAStruct : nullptr; Result.Scope = Other.Scope == Scope ? Scope : nullptr; Result.NoAlias = Other.NoAlias == NoAlias ? NoAlias : nullptr; + Result.NoAliasAddrSpace = + Other.NoAliasAddrSpace == NoAliasAddrSpace ? NoAliasAddrSpace : nullptr; return Result; } @@ -818,6 +823,7 @@ struct AAMDNodes { TBAAStruct ? shiftTBAAStruct(TBAAStruct, Offset) : nullptr; Result.Scope = Scope; Result.NoAlias = NoAlias; + Result.NoAliasAddrSpace = NoAliasAddrSpace; return Result; } @@ -833,6 +839,7 @@ struct AAMDNodes { Result.TBAAStruct = TBAAStruct; Result.Scope = Scope; Result.NoAlias = NoAlias; + Result.NoAliasAddrSpace = NoAliasAddrSpace; return Result; } @@ -860,12 +867,12 @@ struct AAMDNodes { template<> struct DenseMapInfo<AAMDNodes> { static inline AAMDNodes getEmptyKey() { - return AAMDNodes(DenseMapInfo<MDNode *>::getEmptyKey(), - nullptr, nullptr, nullptr); + return AAMDNodes(DenseMapInfo<MDNode *>::getEmptyKey(), nullptr, nullptr, + nullptr, nullptr); } static inline AAMDNodes getTombstoneKey() { - return AAMDNodes(DenseMapInfo<MDNode *>::getTombstoneKey(), + return AAMDNodes(DenseMapInfo<MDNode *>::getTombstoneKey(), nullptr, nullptr, nullptr, nullptr); } @@ -873,7 +880,8 @@ struct DenseMapInfo<AAMDNodes> { return DenseMapInfo<MDNode *>::getHashValue(Val.TBAA) ^ DenseMapInfo<MDNode *>::getHashValue(Val.TBAAStruct) ^ DenseMapInfo<MDNode *>::getHashValue(Val.Scope) ^ - DenseMapInfo<MDNode *>::getHashValue(Val.NoAlias); + DenseMapInfo<MDNode *>::getHashValue(Val.NoAlias) ^ + DenseMapInfo<MDNode *>::getHashValue(Val.NoAliasAddrSpace); } static bool isEqual(const AAMDNodes &LHS, const AAMDNodes &RHS) { diff --git a/llvm/include/llvm/IR/NVVMIntrinsicUtils.h b/llvm/include/llvm/IR/NVVMIntrinsicUtils.h index 0fd5de3..11bfd73 100644 --- a/llvm/include/llvm/IR/NVVMIntrinsicUtils.h +++ b/llvm/include/llvm/IR/NVVMIntrinsicUtils.h @@ -408,7 +408,7 @@ inline APFloat::roundingMode GetRCPRoundingMode(Intrinsic::ID IntrinsicID) { llvm_unreachable("Checking rounding mode for invalid rcp intrinsic"); } -inline DenormalMode GetNVVMDenromMode(bool ShouldFTZ) { +inline DenormalMode GetNVVMDenormMode(bool ShouldFTZ) { if (ShouldFTZ) return DenormalMode::getPreserveSign(); return DenormalMode::getIEEE(); diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index 89ad4e5..eb882c4 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -134,7 +134,7 @@ struct RuntimeLibcallsInfo { /// Check if this is valid libcall for the current module, otherwise /// RTLIB::Unsupported. - RTLIB::LibcallImpl getSupportedLibcallImpl(StringRef FuncName) const; + LLVM_ABI RTLIB::LibcallImpl getSupportedLibcallImpl(StringRef FuncName) const; private: static const RTLIB::LibcallImpl diff --git a/llvm/include/llvm/MC/DXContainerRootSignature.h b/llvm/include/llvm/MC/DXContainerRootSignature.h index 14a2429..3c7c886 100644 --- a/llvm/include/llvm/MC/DXContainerRootSignature.h +++ b/llvm/include/llvm/MC/DXContainerRootSignature.h @@ -10,6 +10,7 @@ #define LLVM_MC_DXCONTAINERROOTSIGNATURE_H #include "llvm/BinaryFormat/DXContainer.h" +#include "llvm/Support/Compiler.h" #include <cstdint> #include <limits> @@ -113,9 +114,9 @@ struct RootSignatureDesc { mcdxbc::RootParametersContainer ParametersContainer; SmallVector<dxbc::RTS0::v1::StaticSampler> StaticSamplers; - void write(raw_ostream &OS) const; + LLVM_ABI void write(raw_ostream &OS) const; - size_t getSize() const; + LLVM_ABI size_t getSize() const; }; } // namespace mcdxbc } // namespace llvm 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/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h index 467ad4e..4853701 100644 --- a/llvm/include/llvm/MC/MCAssembler.h +++ b/llvm/include/llvm/MC/MCAssembler.h @@ -209,7 +209,7 @@ public: LLVM_ABI bool registerSection(MCSection &Section); LLVM_ABI bool registerSymbol(const MCSymbol &Symbol); - void addRelocDirective(RelocDirective RD); + LLVM_ABI void addRelocDirective(RelocDirective RD); LLVM_ABI void reportError(SMLoc L, const Twine &Msg) const; // Record pending errors during layout iteration, as they may go away once the diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index c137f61..ddac161 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -333,8 +333,6 @@ private: void reportCommon(SMLoc Loc, std::function<void(SMDiagnostic &, const SourceMgr *)>); - MCFragment *allocInitialFragment(MCSection &Sec); - MCSymbolTableEntry &getSymbolTableEntry(StringRef Name); MCSymbol *createSymbolImpl(const MCSymbolTableEntry *Name, bool IsTemporary); 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/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h index aea93e9..5ac7aba 100644 --- a/llvm/include/llvm/MC/MCObjectStreamer.h +++ b/llvm/include/llvm/MC/MCObjectStreamer.h @@ -52,6 +52,10 @@ class MCObjectStreamer : public MCStreamer { DenseMap<const MCSymbol *, SmallVector<PendingAssignment, 1>> pendingAssignments; + SmallVector<std::unique_ptr<char[]>, 0> FragStorage; + // Available bytes in the current block for trailing data or new fragments. + size_t FragSpace = 0; + void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &); void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override; void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override; @@ -84,10 +88,18 @@ public: // Add a fragment with a variable-size tail and start a new empty fragment. void insert(MCFragment *F); + char *getCurFragEnd() const { + return reinterpret_cast<char *>(CurFrag + 1) + CurFrag->getFixedSize(); + } + MCFragment *allocFragSpace(size_t Headroom); // Add a new fragment to the current section without a variable-size tail. void newFragment(); + void ensureHeadroom(size_t Headroom); + void appendContents(ArrayRef<char> Contents); void appendContents(size_t Num, char Elt); + // Add a fixup to the current fragment. Call ensureHeadroom beforehand to + // ensure the fixup and appended content apply to the same fragment. void addFixup(const MCExpr *Value, MCFixupKind Kind); void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; @@ -102,7 +114,6 @@ public: void emitSLEB128Value(const MCExpr *Value) override; void emitWeakReference(MCSymbol *Alias, const MCSymbol *Target) override; void changeSection(MCSection *Section, uint32_t Subsection = 0) override; - void switchSectionNoPrint(MCSection *Section) override; void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override; /// Emit an instruction to a special fragment, because this instruction diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h index c1f3f02..2e929d8 100644 --- a/llvm/include/llvm/MC/MCSection.h +++ b/llvm/include/llvm/MC/MCSection.h @@ -93,8 +93,7 @@ protected: // Track content and fixups for the fixed-size part as fragments are // appended to the section. The content remains immutable, except when // modified by applyFixup. - uint32_t ContentStart = 0; - uint32_t ContentEnd = 0; + uint32_t FixedSize = 0; uint32_t FixupStart = 0; uint32_t FixupEnd = 0; @@ -150,23 +149,6 @@ public: MCFragment(const MCFragment &) = delete; MCFragment &operator=(const MCFragment &) = delete; - bool isEncoded() const { - MCFragment::FragmentType Kind = getKind(); - switch (Kind) { - default: - return false; - case MCFragment::FT_Relaxable: - case MCFragment::FT_Data: - case MCFragment::FT_Align: - case MCFragment::FT_Dwarf: - case MCFragment::FT_DwarfFrame: - case MCFragment::FT_LEB: - case MCFragment::FT_CVInlineLines: - case MCFragment::FT_CVDefRange: - return true; - } - } - MCFragment *getNext() const { return Next; } FragmentType getKind() const { return Kind; } @@ -205,30 +187,18 @@ public: //== Content-related functions manage parent's storage using ContentStart and // ContentSize. - // Get a SmallVector reference. The caller should call doneAppending to update - // `ContentEnd`. - SmallVectorImpl<char> &getContentsForAppending(); - void doneAppending(); - void appendContents(ArrayRef<char> Contents) { - getContentsForAppending().append(Contents.begin(), Contents.end()); - doneAppending(); - } - void appendContents(size_t Num, char Elt) { - getContentsForAppending().append(Num, Elt); - doneAppending(); - } MutableArrayRef<char> getContents(); ArrayRef<char> getContents() const; - void setVarContents(ArrayRef<char> Contents); + LLVM_ABI void setVarContents(ArrayRef<char> Contents); void clearVarContents() { setVarContents({}); } MutableArrayRef<char> getVarContents(); ArrayRef<char> getVarContents() const; - size_t getFixedSize() const { return ContentEnd - ContentStart; } + size_t getFixedSize() const { return FixedSize; } size_t getVarSize() const { return VarContentEnd - VarContentStart; } size_t getSize() const { - return ContentEnd - ContentStart + (VarContentEnd - VarContentStart); + return FixedSize + (VarContentEnd - VarContentStart); } //== Fixup-related functions manage parent's storage using FixupStart and @@ -241,7 +211,7 @@ public: // Source fixup offsets are relative to the variable part's start. // Stored fixup offsets are relative to the fixed part's start. - void setVarFixups(ArrayRef<MCFixup> Fixups); + LLVM_ABI void setVarFixups(ArrayRef<MCFixup> Fixups); void clearVarFixups() { setVarFixups({}); } MutableArrayRef<MCFixup> getVarFixups(); ArrayRef<MCFixup> getVarFixups() const; @@ -540,17 +510,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; @@ -570,6 +529,8 @@ private: // At parse time, this holds the fragment list of the current subsection. At // layout time, this holds the concatenated fragment lists of all subsections. FragList *CurFragList; + // In many object file formats, this denotes the section symbol. In Mach-O, + // this denotes an optional temporary label at the section start. MCSymbol *Begin; MCSymbol *End = nullptr; /// The alignment requirement of this section. @@ -589,6 +550,8 @@ private: /// offset between two locations may not be fully resolved. bool LinkerRelaxable : 1; + MCFragment DummyFragment; + // Mapping from subsection number to fragment list. At layout time, the // subsection 0 list is replaced with concatenated fragments from all // subsections. @@ -602,12 +565,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; @@ -616,8 +575,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(); @@ -650,7 +607,7 @@ public: bool isLinkerRelaxable() const { return LinkerRelaxable; } void setLinkerRelaxable() { LinkerRelaxable = true; } - MCFragment &getDummyFragment() { return *Subsections[0].second.Head; } + MCFragment &getDummyFragment() { return DummyFragment; } FragList *curFragList() const { return CurFragList; } iterator begin() const { return iterator(CurFragList->Head); } @@ -659,41 +616,16 @@ 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; } }; -inline SmallVectorImpl<char> &MCFragment::getContentsForAppending() { - SmallVectorImpl<char> &S = getParent()->ContentStorage; - if (LLVM_UNLIKELY(ContentEnd != S.size())) { - // Move the elements to the end. Reserve space to avoid invalidating - // S.begin()+I for `append`. - auto Size = ContentEnd - ContentStart; - auto I = std::exchange(ContentStart, S.size()); - S.reserve(S.size() + Size); - S.append(S.begin() + I, S.begin() + I + Size); - } - return S; -} -inline void MCFragment::doneAppending() { - ContentEnd = getParent()->ContentStorage.size(); -} inline MutableArrayRef<char> MCFragment::getContents() { - return MutableArrayRef(getParent()->ContentStorage) - .slice(ContentStart, ContentEnd - ContentStart); + return {reinterpret_cast<char *>(this + 1), FixedSize}; } inline ArrayRef<char> MCFragment::getContents() const { - return ArrayRef(getParent()->ContentStorage) - .slice(ContentStart, ContentEnd - ContentStart); + return {reinterpret_cast<const char *>(this + 1), FixedSize}; } inline MutableArrayRef<char> MCFragment::getVarContents() { diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h b/llvm/include/llvm/MC/MCSectionCOFF.h index f979413a..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)++; @@ -92,8 +88,6 @@ public: static bool isImplicitlyDiscardable(StringRef Name) { return Name.starts_with(".debug"); } - - static bool classof(const MCSection *S) { return S->getVariant() == SV_COFF; } }; } // end namespace llvm 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 64a4daf..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; } @@ -100,10 +92,6 @@ public: std::pair<uint64_t, uint64_t> getOffsets() const { return std::make_pair(StartOffset, EndOffset); } - - static bool classof(const MCSection *S) { - return S->getVariant() == SV_ELF; - } }; } // end namespace llvm 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/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h index dfaf348..79c715e 100644 --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -438,7 +438,7 @@ public: assert(!CurFrag || CurFrag->getKind() == MCFragment::FT_Data); return CurFrag; } - size_t getCurFragOffset() const { return getCurrentFragment()->Offset; } + size_t getCurFragSize() const { return getCurrentFragment()->getFixedSize(); } /// Save the current and previous section on the section stack. void pushSection() { SectionStack.push_back( @@ -459,7 +459,7 @@ public: bool switchSection(MCSection *Section, const MCExpr *); /// Similar to switchSection, but does not print the section directive. - virtual void switchSectionNoPrint(MCSection *Section); + void switchSectionNoPrint(MCSection *Section); /// Create the default sections and set the initial one. virtual void initSections(bool NoExecStack, const MCSubtargetInfo &STI); 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/MC/MCXCOFFStreamer.h b/llvm/include/llvm/MC/MCXCOFFStreamer.h index 870d48f..c3bc2ca9 100644 --- a/llvm/include/llvm/MC/MCXCOFFStreamer.h +++ b/llvm/include/llvm/MC/MCXCOFFStreamer.h @@ -22,6 +22,7 @@ public: XCOFFObjectWriter &getWriter(); + void changeSection(MCSection *Section, uint32_t Subsection = 0) override; bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override; diff --git a/llvm/include/llvm/Object/SFrameParser.h b/llvm/include/llvm/Object/SFrameParser.h index cf4fe20..245e7ba 100644 --- a/llvm/include/llvm/Object/SFrameParser.h +++ b/llvm/include/llvm/Object/SFrameParser.h @@ -11,6 +11,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/BinaryFormat/SFrame.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include <cstdint> @@ -19,11 +20,14 @@ namespace object { template <endianness E> class SFrameParser { public: - static Expected<SFrameParser> create(ArrayRef<uint8_t> Contents); + static Expected<SFrameParser> create(ArrayRef<uint8_t> Contents, + uint64_t SectionAddress); const sframe::Preamble<E> &getPreamble() const { return Header.Preamble; } const sframe::Header<E> &getHeader() const { return Header; } + Expected<ArrayRef<uint8_t>> getAuxHeader() const; + bool usesFixedRAOffset() const { return getHeader().ABIArch == sframe::ABI::AMD64EndianLittle; } @@ -31,16 +35,29 @@ public: return false; // Not used in any currently defined ABI. } + using FDERange = ArrayRef<sframe::FuncDescEntry<E>>; + Expected<FDERange> fdes() const; + + // Decodes the start address of the given FDE, which must be one of the + // objects returned by the `fdes()` function. + uint64_t getAbsoluteStartAddress(typename FDERange::iterator FDE) const; + private: ArrayRef<uint8_t> Data; + uint64_t SectionAddress; const sframe::Header<E> &Header; - SFrameParser(ArrayRef<uint8_t> Data, const sframe::Header<E> &Header) - : Data(Data), Header(Header) {} + SFrameParser(ArrayRef<uint8_t> Data, uint64_t SectionAddress, + const sframe::Header<E> &Header) + : Data(Data), SectionAddress(SectionAddress), Header(Header) {} + + uint64_t getFDEBase() const { + return sizeof(Header) + Header.AuxHdrLen + Header.FDEOff; + } }; -extern template class SFrameParser<endianness::big>; -extern template class SFrameParser<endianness::little>; +extern template class LLVM_TEMPLATE_ABI SFrameParser<endianness::big>; +extern template class LLVM_TEMPLATE_ABI SFrameParser<endianness::little>; } // end namespace object } // end namespace llvm diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h index b0360f1..97c3ff8 100644 --- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h +++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h @@ -114,13 +114,16 @@ #include "llvm/Target/CGPassBuilderOption.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/CFGuard.h" +#include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar/ConstantHoisting.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" #include "llvm/Transforms/Scalar/LoopStrengthReduce.h" +#include "llvm/Transforms/Scalar/LoopTermFold.h" #include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h" #include "llvm/Transforms/Scalar/MergeICmps.h" #include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h" #include "llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h" +#include "llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h" #include "llvm/Transforms/Utils/EntryExitInstrumenter.h" #include "llvm/Transforms/Utils/LowerInvoke.h" #include <cassert> @@ -754,7 +757,12 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses( // Run loop strength reduction before anything else. if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) { - addPass(createFunctionToLoopPassAdaptor(LoopStrengthReducePass(), + LoopPassManager LPM; + LPM.addPass(CanonicalizeFreezeInLoopsPass()); + LPM.addPass(LoopStrengthReducePass()); + if (Opt.EnableLoopTermFold) + LPM.addPass(LoopTermFoldPass()); + addPass(createFunctionToLoopPassAdaptor(std::move(LPM), /*UseMemorySSA=*/true)); } @@ -799,7 +807,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses( addPass(ScalarizeMaskedMemIntrinPass()); // Expand reduction intrinsics into shuffle sequences if the target wants to. - addPass(ExpandReductionsPass()); + if (!Opt.DisableExpandReductions) + addPass(ExpandReductionsPass()); // Convert conditional moves to conditional jumps when profitable. if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize) @@ -877,6 +886,9 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPrepare( if (Opt.RequiresCodeGenSCCOrder) addPass.requireCGSCCOrder(); + if (getOptLevel() != CodeGenOptLevel::None) + addPass(ObjCARCContractPass()); + addPass(CallBrPreparePass()); // Add both the safe stack and the stack protection passes: each of them will // only protect functions that have corresponding attributes. diff --git a/llvm/include/llvm/Support/AArch64AttributeParser.h b/llvm/include/llvm/Support/AArch64AttributeParser.h index 796dbfd..f4552ef 100644 --- a/llvm/include/llvm/Support/AArch64AttributeParser.h +++ b/llvm/include/llvm/Support/AArch64AttributeParser.h @@ -34,7 +34,7 @@ struct AArch64BuildAttrSubsections { uint32_t AndFeatures = 0; }; -AArch64BuildAttrSubsections +LLVM_ABI AArch64BuildAttrSubsections extractBuildAttributesSubsections(const llvm::AArch64AttributeParser &); } // namespace llvm diff --git a/llvm/include/llvm/Support/AMDHSAKernelDescriptor.h b/llvm/include/llvm/Support/AMDHSAKernelDescriptor.h index a119b07..8f36739 100644 --- a/llvm/include/llvm/Support/AMDHSAKernelDescriptor.h +++ b/llvm/include/llvm/Support/AMDHSAKernelDescriptor.h @@ -223,7 +223,8 @@ enum : int32_t { KERNEL_CODE_PROPERTY(ENABLE_SGPR_DISPATCH_ID, 4, 1), KERNEL_CODE_PROPERTY(ENABLE_SGPR_FLAT_SCRATCH_INIT, 5, 1), KERNEL_CODE_PROPERTY(ENABLE_SGPR_PRIVATE_SEGMENT_SIZE, 6, 1), - KERNEL_CODE_PROPERTY(RESERVED0, 7, 3), + KERNEL_CODE_PROPERTY(RESERVED0, 7, 2), + KERNEL_CODE_PROPERTY(USES_CU_STORES, 9, 1), // GFX12.5 +cu-stores KERNEL_CODE_PROPERTY(ENABLE_WAVEFRONT_SIZE32, 10, 1), // GFX10+ KERNEL_CODE_PROPERTY(USES_DYNAMIC_STACK, 11, 1), KERNEL_CODE_PROPERTY(RESERVED1, 12, 4), diff --git a/llvm/include/llvm/Support/Debug.h b/llvm/include/llvm/Support/Debug.h index 924d7b2..5542089 100644 --- a/llvm/include/llvm/Support/Debug.h +++ b/llvm/include/llvm/Support/Debug.h @@ -39,13 +39,19 @@ class raw_ostream; /// isCurrentDebugType - Return true if the specified string is the debug type /// specified on the command line, or if none was specified on the command line /// with the -debug-only=X option. -/// -bool isCurrentDebugType(const char *Type); +/// An optional level can be provided to control the verbosity of the output. +/// If the provided level is not 0 and user specified a level below the provided +/// level, return false. +bool isCurrentDebugType(const char *Type, int Level = 0); /// setCurrentDebugType - Set the current debug type, as if the -debug-only=X /// option were specified. Note that DebugFlag also needs to be set to true for /// debug output to be produced. -/// +/// The debug type format is "type[:level]", where the level is an optional +/// integer. If a level is provided, the debug output is enabled only if the +/// user specified a level at least as high as the provided level. +/// 0 is a special level that acts as an opt-out for this specific debug type +/// without affecting the other debug output. void setCurrentDebugType(const char *Type); /// setCurrentDebugTypes - Set the current debug type, as if the diff --git a/llvm/include/llvm/Support/DebugLog.h b/llvm/include/llvm/Support/DebugLog.h new file mode 100644 index 0000000..8fca2d5 --- /dev/null +++ b/llvm/include/llvm/Support/DebugLog.h @@ -0,0 +1,175 @@ +//===- llvm/Support/DebugLog.h - Logging like debug output ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// This file contains macros for logging like debug output. It builds upon the +// support in Debug.h but provides a utility function for common debug output +// style. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_DEBUGLOG_H +#define LLVM_SUPPORT_DEBUGLOG_H + +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { +#ifndef NDEBUG + +// LDBG() is a macro that can be used as a raw_ostream for debugging. +// It will stream the output to the dbgs() stream, with a prefix of the +// debug type and the file and line number. A trailing newline is added to the +// output automatically. If the streamed content contains a newline, the prefix +// is added to each beginning of a new line. Nothing is printed if the debug +// output is not enabled or the debug type does not match. +// +// E.g., +// LDBG() << "Bitset contains: " << Bitset; +// is somehow equivalent to +// LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] " << __FILE__ << ":" << +// __LINE__ << " " +// << "Bitset contains: " << Bitset << "\n"); +// +// An optional `level` argument can be provided to control the verbosity of the +// output. The default level is 1, and is in increasing level of verbosity. +// +// The `level` argument can be a literal integer, or a macro that evaluates to +// an integer. +// +#define LDBG(...) _GET_LDBG_MACRO(__VA_ARGS__)(__VA_ARGS__) + +// Helper macros to choose the correct macro based on the number of arguments. +#define LDBG_FUNC_CHOOSER(_f1, _f2, ...) _f2 +#define LDBG_FUNC_RECOMPOSER(argsWithParentheses) \ + LDBG_FUNC_CHOOSER argsWithParentheses +#define LDBG_CHOOSE_FROM_ARG_COUNT(...) \ + LDBG_FUNC_RECOMPOSER((__VA_ARGS__, LDBG_LOG_LEVEL, )) +#define LDBG_NO_ARG_EXPANDER() , LDBG_LOG_LEVEL_1 +#define _GET_LDBG_MACRO(...) \ + LDBG_CHOOSE_FROM_ARG_COUNT(LDBG_NO_ARG_EXPANDER __VA_ARGS__()) + +// Dispatch macros to support the `level` argument or none (default to 1) +#define LDBG_LOG_LEVEL(LEVEL) \ + DEBUGLOG_WITH_STREAM_AND_TYPE(llvm::dbgs(), LEVEL, DEBUG_TYPE) +#define LDBG_LOG_LEVEL_1() LDBG_LOG_LEVEL(1) + +#define DEBUGLOG_WITH_STREAM_TYPE_FILE_AND_LINE(STREAM, LEVEL, TYPE, FILE, \ + LINE) \ + for (bool _c = \ + (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE, LEVEL)); \ + _c; _c = false) \ + ::llvm::impl::raw_ldbg_ostream{ \ + ::llvm::impl::computePrefix(TYPE, FILE, LINE, LEVEL), (STREAM)} \ + .asLvalue() + +#define DEBUGLOG_WITH_STREAM_TYPE_AND_FILE(STREAM, LEVEL, TYPE, FILE) \ + DEBUGLOG_WITH_STREAM_TYPE_FILE_AND_LINE(STREAM, LEVEL, TYPE, FILE, __LINE__) +// 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, LEVEL, TYPE) \ + DEBUGLOG_WITH_STREAM_TYPE_AND_FILE(STREAM, LEVEL, TYPE, __SHORT_FILE__) +#else +#define DEBUGLOG_WITH_STREAM_AND_TYPE(STREAM, LEVEL, TYPE) \ + DEBUGLOG_WITH_STREAM_TYPE_AND_FILE(STREAM, LEVEL, TYPE, \ + ::llvm::impl::getShortFileName(__FILE__)) +#endif + +namespace impl { + +/// 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: + explicit raw_ldbg_ostream(std::string Prefix, raw_ostream &Os) + : Prefix(std::move(Prefix)), Os(Os) { + SetUnbuffered(); + } + ~raw_ldbg_ostream() final { + flushEol(); + Os << '\n'; + } + void flushEol() { + if (HasPendingNewline) { + emitPrefix(); + HasPendingNewline = false; + } + } + + /// Forward the current_pos method to the underlying stream. + uint64_t current_pos() const final { return Os.tell(); } + + /// 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, int Level) { + std::string Prefix; + raw_string_ostream OsPrefix(Prefix); + if (DebugType) + OsPrefix << "[" << DebugType << ":" << Level << "] "; + OsPrefix << File << ":" << Line << " "; + return OsPrefix.str(); +} +} // end namespace impl +#else +// As others in Debug, When compiling without assertions, the -debug-* options +// and all inputs too LDBG() are ignored. +#define LDBG(...) \ + for (bool _c = false; _c; _c = false) \ + ::llvm::nulls() +#endif +} // end namespace llvm + +#endif // LLVM_SUPPORT_DEBUGLOG_H 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/Support/Windows/WindowsSupport.h b/llvm/include/llvm/Support/Windows/WindowsSupport.h index ffc6fdf..f35e7b5 100644 --- a/llvm/include/llvm/Support/Windows/WindowsSupport.h +++ b/llvm/include/llvm/Support/Windows/WindowsSupport.h @@ -245,6 +245,10 @@ LLVM_ABI std::error_code widenPath(const Twine &Path8, SmallVectorImpl<wchar_t> &Path16, size_t MaxPathLen = MAX_PATH); +/// Retrieves the handle to a in-memory system module such as ntdll.dll, while +/// ensuring we're not retrieving a malicious injected module but a module +/// loaded from the system path. +LLVM_ABI HMODULE loadSystemModuleSecure(LPCWSTR lpModuleName); } // end namespace windows } // end namespace sys } // end namespace llvm. diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index a2b86eb..9d67d8b 100644 --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/include/llvm/TableGen/Record.h @@ -841,6 +841,7 @@ public: SIZE, EMPTY, GETDAGOP, + GETDAGOPNAME, LOG2, REPR, LISTFLATTEN, @@ -910,6 +911,7 @@ public: GETDAGARG, GETDAGNAME, SETDAGOP, + SETDAGOPNAME }; private: diff --git a/llvm/include/llvm/Target/CGPassBuilderOption.h b/llvm/include/llvm/Target/CGPassBuilderOption.h index f29cbe7..8d0a7e6 100644 --- a/llvm/include/llvm/Target/CGPassBuilderOption.h +++ b/llvm/include/llvm/Target/CGPassBuilderOption.h @@ -52,6 +52,8 @@ struct CGPassBuilderOption { bool EnableMachineFunctionSplitter = false; bool EnableSinkAndFold = false; bool EnableTailMerge = true; + /// Enable LoopTermFold immediately after LSR. + bool EnableLoopTermFold = false; bool MISchedPostRA = false; bool EarlyLiveIntervals = false; bool GCEmptyBlocks = false; diff --git a/llvm/include/llvm/Target/GlobalISel/Combine.td b/llvm/include/llvm/Target/GlobalISel/Combine.td index fc81ab7..b619de3 100644 --- a/llvm/include/llvm/Target/GlobalISel/Combine.td +++ b/llvm/include/llvm/Target/GlobalISel/Combine.td @@ -194,6 +194,7 @@ def IsExact : MIFlagEnum<"IsExact">; def NoSWrap : MIFlagEnum<"NoSWrap">; def NoUWrap : MIFlagEnum<"NoUWrap">; def NonNeg : MIFlagEnum<"NonNeg">; +def InBounds : MIFlagEnum<"InBounds">; def MIFlags; // def not; -> Already defined as a SDNode diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index f420798..db90f2e 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -133,10 +133,11 @@ public: EmitStackSizeSection(false), EnableMachineOutliner(false), EnableMachineFunctionSplitter(false), EnableStaticDataPartitioning(false), SupportsDefaultOutlining(false), - EmitAddrsig(false), BBAddrMap(false), EmitCallSiteInfo(false), - SupportsDebugEntryValues(false), EnableDebugEntryValues(false), - ValueTrackingVariableLocations(false), ForceDwarfFrameSection(false), - XRayFunctionIndex(true), DebugStrictDwarf(false), Hotpatch(false), + EmitAddrsig(false), BBAddrMap(false), EmitCallGraphSection(false), + EmitCallSiteInfo(false), SupportsDebugEntryValues(false), + EnableDebugEntryValues(false), ValueTrackingVariableLocations(false), + ForceDwarfFrameSection(false), XRayFunctionIndex(true), + DebugStrictDwarf(false), Hotpatch(false), PPCGenScalarMASSEntries(false), JMCInstrument(false), EnableCFIFixup(false), MisExpect(false), XCOFFReadOnlyPointers(false), VerifyArgABICompliance(true), @@ -319,6 +320,9 @@ public: /// to selectively generate basic block sections. std::shared_ptr<MemoryBuffer> BBSectionsFuncListBuf; + /// Emit section containing call graph metadata. + unsigned EmitCallGraphSection : 1; + /// The flag enables call site info production. It is used only for debug /// info, and it is restricted only to optimized code. This can be used for /// something else, so that should be controlled in the frontend. diff --git a/llvm/include/llvm/Target/TargetSelectionDAG.td b/llvm/include/llvm/Target/TargetSelectionDAG.td index 8ec8697..a4ed62b 100644 --- a/llvm/include/llvm/Target/TargetSelectionDAG.td +++ b/llvm/include/llvm/Target/TargetSelectionDAG.td @@ -1147,6 +1147,9 @@ def fadd_contract : PatFrag<(ops node:$a, node:$b), (fadd node:$a, node:$b),[{ return N->getFlags().hasAllowContract(); }]>; +def fsub_contract : PatFrag<(ops node:$a, node:$b), (fsub node:$a, node:$b),[{ + return N->getFlags().hasAllowContract(); +}]>; def not : PatFrag<(ops node:$in), (xor node:$in, -1)>; def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>; diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index 670a632..ede9797 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -199,7 +199,8 @@ public: SUSE, OpenEmbedded, Intel, - LastVendorType = Intel + Meta, + LastVendorType = Meta }; enum OSType { UnknownOS, @@ -307,8 +308,8 @@ public: Mlibc, PAuthTest, - - LastEnvironmentType = PAuthTest + MTIA, + LastEnvironmentType = MTIA }; enum ObjectFormatType { UnknownObjectFormat, diff --git a/llvm/include/llvm/TextAPI/SymbolSet.h b/llvm/include/llvm/TextAPI/SymbolSet.h index cd30663..42c411a 100644 --- a/llvm/include/llvm/TextAPI/SymbolSet.h +++ b/llvm/include/llvm/TextAPI/SymbolSet.h @@ -92,6 +92,7 @@ private: public: SymbolSet() = default; + LLVM_ABI ~SymbolSet(); LLVM_ABI Symbol *addGlobal(EncodeKind Kind, StringRef Name, SymbolFlags Flags, const Target &Targ); size_t size() const { return Symbols.size(); } diff --git a/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h b/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h index 20850ba..a9a370b 100644 --- a/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h +++ b/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h @@ -41,6 +41,13 @@ public: static bool isRequired() { return true; } }; +class HipStdParMathFixupPass : public PassInfoMixin<HipStdParMathFixupPass> { +public: + PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM); + + static bool isRequired() { return true; } +}; + } // namespace llvm #endif // LLVM_TRANSFORMS_HIPSTDPAR_HIPSTDPAR_H 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); }; diff --git a/llvm/include/llvm/Transforms/Scalar/Reassociate.h b/llvm/include/llvm/Transforms/Scalar/Reassociate.h index a5d13766..749f6ee 100644 --- a/llvm/include/llvm/Transforms/Scalar/Reassociate.h +++ b/llvm/include/llvm/Transforms/Scalar/Reassociate.h @@ -28,6 +28,7 @@ #include "llvm/IR/BasicBlock.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/ValueHandle.h" +#include "llvm/Support/Compiler.h" #include <deque> namespace llvm { @@ -96,7 +97,7 @@ protected: bool MadeChange; public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &); private: void BuildRankMap(Function &F, ReversePostOrderTraversal<Function *> &RPOT); diff --git a/llvm/include/llvm/Transforms/Utils/Mem2Reg.h b/llvm/include/llvm/Transforms/Utils/Mem2Reg.h index 76c1c2c..d0006bf 100644 --- a/llvm/include/llvm/Transforms/Utils/Mem2Reg.h +++ b/llvm/include/llvm/Transforms/Utils/Mem2Reg.h @@ -15,6 +15,7 @@ #define LLVM_TRANSFORMS_UTILS_MEM2REG_H #include "llvm/IR/PassManager.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -22,7 +23,7 @@ class Function; class PromotePass : public PassInfoMixin<PromotePass> { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; } // end namespace llvm diff --git a/llvm/include/llvm/Transforms/Utils/ProfileVerify.h b/llvm/include/llvm/Transforms/Utils/ProfileVerify.h index 7834305..5c9c44c 100644 --- a/llvm/include/llvm/Transforms/Utils/ProfileVerify.h +++ b/llvm/include/llvm/Transforms/Utils/ProfileVerify.h @@ -15,13 +15,14 @@ #include "llvm/IR/Analysis.h" #include "llvm/IR/PassManager.h" +#include "llvm/Support/Compiler.h" namespace llvm { /// Inject MD_prof metadata where it's missing. Used for testing that passes /// don't accidentally drop this metadata. class ProfileInjectorPass : public PassInfoMixin<ProfileInjectorPass> { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); }; /// Checks that MD_prof is present on every instruction that supports it. Used @@ -29,7 +30,7 @@ public: /// valid (i.e. !{!"unknown"}) class ProfileVerifierPass : public PassInfoMixin<ProfileVerifierPass> { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); }; } // namespace llvm |