diff options
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineFunction.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineInstr.h | 52 | ||||
-rw-r--r-- | llvm/include/llvm/CodeGen/StackProtector.h | 3 | ||||
-rw-r--r-- | llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h | 2 | ||||
-rw-r--r-- | llvm/include/llvm/Transforms/Scalar/GVN.h | 2 |
5 files changed, 55 insertions, 8 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index 201c126ee52ec..60c13468542af 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -792,6 +792,10 @@ public: MCSymbol *PreInstrSymbol = nullptr, MCSymbol *PostInstrSymbol = nullptr); + MachineInstr::ExtraInfo *createMIExtraInfoWithMarker( + ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol, + MCSymbol *PostInstrSymbol, MDNode *HeapAllocMarker); + /// Allocate a string and populate it with the given external symbol name. const char *createExternalSymbolName(StringRef Name); diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h index c82c5b137507b..fa532ec831fd0 100644 --- a/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/llvm/include/llvm/CodeGen/MachineInstr.h @@ -137,19 +137,23 @@ private: /// This has to be defined eagerly due to the implementation constraints of /// `PointerSumType` where it is used. class ExtraInfo final - : TrailingObjects<ExtraInfo, MachineMemOperand *, MCSymbol *> { + : TrailingObjects<ExtraInfo, MachineMemOperand *, MCSymbol *, MDNode *> { public: static ExtraInfo *create(BumpPtrAllocator &Allocator, ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol = nullptr, - MCSymbol *PostInstrSymbol = nullptr) { + MCSymbol *PostInstrSymbol = nullptr, + MDNode *HeapAllocMarker = nullptr) { bool HasPreInstrSymbol = PreInstrSymbol != nullptr; bool HasPostInstrSymbol = PostInstrSymbol != nullptr; + bool HasHeapAllocMarker = HeapAllocMarker != nullptr; auto *Result = new (Allocator.Allocate( - totalSizeToAlloc<MachineMemOperand *, MCSymbol *>( - MMOs.size(), HasPreInstrSymbol + HasPostInstrSymbol), + totalSizeToAlloc<MachineMemOperand *, MCSymbol *, MDNode *>( + MMOs.size(), HasPreInstrSymbol + HasPostInstrSymbol, + HasHeapAllocMarker), alignof(ExtraInfo))) - ExtraInfo(MMOs.size(), HasPreInstrSymbol, HasPostInstrSymbol); + ExtraInfo(MMOs.size(), HasPreInstrSymbol, HasPostInstrSymbol, + HasHeapAllocMarker); // Copy the actual data into the trailing objects. std::copy(MMOs.begin(), MMOs.end(), @@ -160,6 +164,8 @@ private: if (HasPostInstrSymbol) Result->getTrailingObjects<MCSymbol *>()[HasPreInstrSymbol] = PostInstrSymbol; + if (HasHeapAllocMarker) + Result->getTrailingObjects<MDNode *>()[0] = HeapAllocMarker; return Result; } @@ -178,6 +184,10 @@ private: : nullptr; } + MDNode *getHeapAllocMarker() const { + return HasHeapAllocMarker ? getTrailingObjects<MDNode *>()[0] : nullptr; + } + private: friend TrailingObjects; @@ -189,6 +199,7 @@ private: const int NumMMOs; const bool HasPreInstrSymbol; const bool HasPostInstrSymbol; + const bool HasHeapAllocMarker; // Implement the `TrailingObjects` internal API. size_t numTrailingObjects(OverloadToken<MachineMemOperand *>) const { @@ -197,12 +208,17 @@ private: size_t numTrailingObjects(OverloadToken<MCSymbol *>) const { return HasPreInstrSymbol + HasPostInstrSymbol; } + size_t numTrailingObjects(OverloadToken<MDNode *>) const { + return HasHeapAllocMarker; + } // Just a boring constructor to allow us to initialize the sizes. Always use // the `create` routine above. - ExtraInfo(int NumMMOs, bool HasPreInstrSymbol, bool HasPostInstrSymbol) + ExtraInfo(int NumMMOs, bool HasPreInstrSymbol, bool HasPostInstrSymbol, + bool HasHeapAllocMarker) : NumMMOs(NumMMOs), HasPreInstrSymbol(HasPreInstrSymbol), - HasPostInstrSymbol(HasPostInstrSymbol) {} + HasPostInstrSymbol(HasPostInstrSymbol), + HasHeapAllocMarker(HasHeapAllocMarker) {} }; /// Enumeration of the kinds of inline extra info available. It is important @@ -577,6 +593,16 @@ public: return nullptr; } + /// Helper to extract a heap alloc marker if one has been added. + MDNode *getHeapAllocMarker() const { + if (!Info) + return nullptr; + if (ExtraInfo *EI = Info.get<EIIK_OutOfLine>()) + return EI->getHeapAllocMarker(); + + return nullptr; + } + /// API for querying MachineInstr properties. They are the same as MCInstrDesc /// queries but they are bundle aware. @@ -1578,6 +1604,12 @@ public: /// replace ours with it. void cloneInstrSymbols(MachineFunction &MF, const MachineInstr &MI); + /// Set a marker on instructions that denotes where we should create and emit + /// heap alloc site labels. This waits until after instruction selection and + /// optimizations to create the label, so it should still work if the + /// instruction is removed or duplicated. + void setHeapAllocMarker(MachineFunction &MF, MDNode *MD); + /// Return the MIFlags which represent both MachineInstrs. This /// should be used when merging two MachineInstrs into one. This routine does /// not modify the MIFlags of this MachineInstr. @@ -1632,6 +1664,12 @@ private: const TargetRegisterClass *getRegClassConstraintEffectForVRegImpl( unsigned OpIdx, unsigned Reg, const TargetRegisterClass *CurRC, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const; + + /// Stores extra instruction information inline or allocates as ExtraInfo + /// based on the number of pointers. + void setExtraInfo(MachineFunction &MF, ArrayRef<MachineMemOperand *> MMOs, + MCSymbol *PreInstrSymbol, MCSymbol *PostInstrSymbol, + MDNode *HeapAllocMarker); }; /// Special DenseMapInfo traits to compare MachineInstr* by *value* of the diff --git a/llvm/include/llvm/CodeGen/StackProtector.h b/llvm/include/llvm/CodeGen/StackProtector.h index 2bdf4425e24a3..f330cd1f1eb22 100644 --- a/llvm/include/llvm/CodeGen/StackProtector.h +++ b/llvm/include/llvm/CodeGen/StackProtector.h @@ -89,7 +89,8 @@ private: bool InStruct = false) const; /// Check whether a stack allocation has its address taken. - bool HasAddressTaken(const Instruction *AI); + bool HasAddressTaken(const Instruction *AI, + SmallPtrSetImpl<const PHINode *> &VisitedPHIs); /// RequiresStackProtector - Check whether or not this function needs a /// stack protector based upon the stack protector level. diff --git a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h index da9d9d5bfdc0c..3d47471f0ef0e 100644 --- a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h +++ b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h @@ -16,6 +16,8 @@ #include "llvm/Demangle/DemangleConfig.h" #include "llvm/Demangle/StringView.h" #include <array> +#include <cstdint> +#include <string> namespace llvm { namespace itanium_demangle { diff --git a/llvm/include/llvm/Transforms/Scalar/GVN.h b/llvm/include/llvm/Transforms/Scalar/GVN.h index 9fe00a9e7f2d7..5a3d6aceae694 100644 --- a/llvm/include/llvm/Transforms/Scalar/GVN.h +++ b/llvm/include/llvm/Transforms/Scalar/GVN.h @@ -120,6 +120,8 @@ public: uint32_t lookupOrAddCall(CallInst *C); uint32_t phiTranslateImpl(const BasicBlock *BB, const BasicBlock *PhiBlock, uint32_t Num, GVN &Gvn); + bool areCallValsEqual(uint32_t Num, uint32_t NewNum, const BasicBlock *Pred, + const BasicBlock *PhiBlock, GVN &Gvn); std::pair<uint32_t, bool> assignExpNewValueNum(Expression &exp); bool areAllValsInBB(uint32_t num, const BasicBlock *BB, GVN &Gvn); |