From b81f81b9d944e3e4b09ebe1735bcc592eb3803a8 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Thu, 10 Nov 2016 18:02:34 +0000 Subject: [PATCH] Fix some Clang-tidy modernize-use-default and readability-redundant-member-init and Include What You Use warnings; other minor fixes. Differential revision: https://reviews.llvm.org/D26087 llvm-svn: 286484 --- llvm/include/llvm/CodeGen/DIE.h | 35 ++++-- llvm/include/llvm/CodeGen/LivePhysRegs.h | 11 +- llvm/include/llvm/CodeGen/MachineScheduler.h | 35 ++++-- llvm/include/llvm/CodeGen/SelectionDAGNodes.h | 172 +++++++++++++++++++------- llvm/include/llvm/Support/Allocator.h | 14 ++- llvm/include/llvm/Support/GCOV.h | 34 +++-- llvm/include/llvm/Support/RWMutex.h | 23 ++-- llvm/include/llvm/Support/SMLoc.h | 6 +- 8 files changed, 234 insertions(+), 96 deletions(-) diff --git a/llvm/include/llvm/CodeGen/DIE.h b/llvm/include/llvm/CodeGen/DIE.h index 7d6e66f..f93dd79 100644 --- a/llvm/include/llvm/CodeGen/DIE.h +++ b/llvm/include/llvm/CodeGen/DIE.h @@ -15,18 +15,28 @@ #define LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/PointerIntPair.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/DwarfStringPoolEntry.h" +#include "llvm/Support/AlignOf.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/Dwarf.h" +#include +#include +#include +#include +#include +#include namespace llvm { + class AsmPrinter; class MCExpr; class MCSymbol; class raw_ostream; -class DwarfTypeUnit; //===--------------------------------------------------------------------===// /// DIEAbbrevData - Dwarf abbreviation data, describes one attribute of a @@ -75,7 +85,7 @@ class DIEAbbrev : public FoldingSetNode { SmallVector Data; public: - DIEAbbrev(dwarf::Tag T, bool C) : Tag(T), Children(C), Data() {} + DIEAbbrev(dwarf::Tag T, bool C) : Tag(T), Children(C) {} // Accessors. dwarf::Tag getTag() const { return Tag; } @@ -355,9 +365,11 @@ private: public: DIEValue() = default; + DIEValue(const DIEValue &X) : Ty(X.Ty), Attribute(X.Attribute), Form(X.Form) { copyVal(X); } + DIEValue &operator=(const DIEValue &X) { destroyVal(); Ty = X.Ty; @@ -366,6 +378,7 @@ public: copyVal(X); return *this; } + ~DIEValue() { destroyVal(); } #define HANDLE_DIEVALUE_SMALL(T) \ @@ -413,6 +426,7 @@ public: struct IntrusiveBackListNode { PointerIntPair Next; + IntrusiveBackListNode() : Next(this, true) {} IntrusiveBackListNode *getNext() const { @@ -576,12 +590,11 @@ public: } value_range values() { - return llvm::make_range(value_iterator(List.begin()), - value_iterator(List.end())); + return make_range(value_iterator(List.begin()), value_iterator(List.end())); } const_value_range values() const { - return llvm::make_range(const_value_iterator(List.begin()), - const_value_iterator(List.end())); + return make_range(const_value_iterator(List.begin()), + const_value_iterator(List.end())); } }; @@ -631,10 +644,10 @@ public: typedef iterator_range const_child_range; child_range children() { - return llvm::make_range(Children.begin(), Children.end()); + return make_range(Children.begin(), Children.end()); } const_child_range children() const { - return llvm::make_range(Children.begin(), Children.end()); + return make_range(Children.begin(), Children.end()); } DIE *getParent() const { return Parent; } @@ -740,6 +753,6 @@ public: void print(raw_ostream &O) const; }; -} // end llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H diff --git a/llvm/include/llvm/CodeGen/LivePhysRegs.h b/llvm/include/llvm/CodeGen/LivePhysRegs.h index d5be010..96660de 100644 --- a/llvm/include/llvm/CodeGen/LivePhysRegs.h +++ b/llvm/include/llvm/CodeGen/LivePhysRegs.h @@ -31,8 +31,10 @@ #include "llvm/ADT/SparseSet.h" #include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/MC/MCRegisterInfo.h" #include "llvm/Target/TargetRegisterInfo.h" #include +#include namespace llvm { @@ -41,14 +43,15 @@ class MachineInstr; /// \brief A set of live physical registers with functions to track liveness /// when walking backward/forward through a basic block. class LivePhysRegs { - const TargetRegisterInfo *TRI; + const TargetRegisterInfo *TRI = nullptr; SparseSet LiveRegs; LivePhysRegs(const LivePhysRegs&) = delete; LivePhysRegs &operator=(const LivePhysRegs&) = delete; + public: /// \brief Constructs a new empty LivePhysRegs set. - LivePhysRegs() : TRI(nullptr), LiveRegs() {} + LivePhysRegs() = default; /// \brief Constructs and initialize an empty LivePhysRegs set. LivePhysRegs(const TargetRegisterInfo *TRI) : TRI(TRI) { @@ -153,6 +156,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const LivePhysRegs& LR) { return OS; } -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_CODEGEN_LIVEPHYSREGS_H diff --git a/llvm/include/llvm/CodeGen/MachineScheduler.h b/llvm/include/llvm/CodeGen/MachineScheduler.h index 58cb7a8..a137a84 100644 --- a/llvm/include/llvm/CodeGen/MachineScheduler.h +++ b/llvm/include/llvm/CodeGen/MachineScheduler.h @@ -75,12 +75,27 @@ #ifndef LLVM_CODEGEN_MACHINESCHEDULER_H #define LLVM_CODEGEN_MACHINESCHEDULER_H +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" #include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachinePassRegistry.h" #include "llvm/CodeGen/RegisterPressure.h" +#include "llvm/CodeGen/ScheduleDAG.h" #include "llvm/CodeGen/ScheduleDAGInstrs.h" #include "llvm/CodeGen/ScheduleDAGMutation.h" +#include "llvm/CodeGen/TargetSchedule.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" +#include +#include #include +#include +#include namespace llvm { @@ -91,7 +106,6 @@ class LiveIntervals; class MachineDominatorTree; class MachineLoopInfo; class RegisterClassInfo; -class ScheduleDAGInstrs; class SchedDFSResult; class ScheduleHazardRecognizer; @@ -126,6 +140,7 @@ public: : MachinePassRegistryNode(N, D, (MachinePassCtor)C) { Registry.Add(this); } + ~MachineSchedRegistry() { Registry.Remove(this); } // Accessors. @@ -133,9 +148,11 @@ public: MachineSchedRegistry *getNext() const { return (MachineSchedRegistry *)MachinePassRegistryNode::getNext(); } + static MachineSchedRegistry *getList() { return (MachineSchedRegistry *)Registry.getList(); } + static void setListener(MachinePassRegistryListener *L) { Registry.setListener(L); } @@ -173,8 +190,9 @@ struct MachineSchedPolicy { /// initPolicy -> shouldTrackPressure -> initialize(DAG) -> registerRoots class MachineSchedStrategy { virtual void anchor(); + public: - virtual ~MachineSchedStrategy() {} + virtual ~MachineSchedStrategy() = default; /// Optionally override the per-region scheduling policy. virtual void initPolicy(MachineBasicBlock::iterator Begin, @@ -256,8 +274,7 @@ public: bool RemoveKillFlags) : ScheduleDAGInstrs(*C->MF, C->MLI, RemoveKillFlags), AA(C->AA), LIS(C->LIS), SchedImpl(std::move(S)), Topo(SUnits, &ExitSU), - CurrentTop(), CurrentBottom(), NextClusterPred(nullptr), - NextClusterSucc(nullptr) { + NextClusterPred(nullptr), NextClusterSucc(nullptr) { #ifndef NDEBUG NumInstrsScheduled = 0; #endif @@ -847,7 +864,7 @@ protected: const TargetRegisterInfo *TRI; SchedRemainder Rem; -protected: + GenericSchedulerBase(const MachineSchedContext *C): Context(C), SchedModel(nullptr), TRI(nullptr) {} @@ -919,7 +936,6 @@ protected: /// Candidate last picked from Bot boundary. SchedCandidate BotCand; - void checkAcyclicLatency(); void initCandidate(SchedCandidate &Cand, SUnit *SU, bool AtTop, @@ -949,11 +965,12 @@ class PostGenericScheduler : public GenericSchedulerBase { ScheduleDAGMI *DAG; SchedBoundary Top; SmallVector BotRoots; + public: PostGenericScheduler(const MachineSchedContext *C): GenericSchedulerBase(C), Top(SchedBoundary::TopQID, "TopQ") {} - ~PostGenericScheduler() override {} + ~PostGenericScheduler() override = default; void initPolicy(MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, @@ -1009,6 +1026,6 @@ std::unique_ptr createCopyConstrainDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI); -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_CODEGEN_MACHINESCHEDULER_H diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h index 46805a9..079e81b 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -19,23 +19,37 @@ #ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H #define LLVM_CODEGEN_SELECTIONDAGNODES_H +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/ilist_node.h" +#include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/ISDOpcodes.h" #include "llvm/CodeGen/MachineMemOperand.h" +#include "llvm/CodeGen/MachineValueType.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DebugLoc.h" +#include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" -#include "llvm/Support/DataTypes.h" -#include "llvm/Support/MathExtras.h" +#include "llvm/Support/AlignOf.h" +#include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/ErrorHandling.h" +#include #include +#include +#include +#include +#include +#include +#include +#include namespace llvm { @@ -44,11 +58,9 @@ class GlobalValue; class MachineBasicBlock; class MachineConstantPoolValue; class SDNode; -class HandleSDNode; class Value; class MCSymbol; template struct DenseMapInfo; -template struct simplify_type; void checkForCycles(const SDNode *N, const SelectionDAG *DAG = nullptr, bool force = false); @@ -63,6 +75,7 @@ struct SDVTList { }; namespace ISD { + /// Node predicates /// If N is a BUILD_VECTOR node whose elements are all the same constant or @@ -88,7 +101,8 @@ namespace ISD { /// Return true if the node has at least one operand and all operands of the /// specified node are ISD::UNDEF. bool allOperandsUndef(const SDNode *N); -} // end llvm:ISD namespace + +} // end namespace ISD //===----------------------------------------------------------------------===// /// Unlike LLVM values, Selection DAG nodes may return multiple @@ -106,6 +120,7 @@ class SDValue { SDNode *Node; // The node defining the value we are using. unsigned ResNo; // Which return value of the node we are using. + public: SDValue() : Node(nullptr), ResNo(0) {} SDValue(SDNode *node, unsigned resno); @@ -187,29 +202,30 @@ public: inline bool hasOneUse() const; }; - template<> struct DenseMapInfo { static inline SDValue getEmptyKey() { SDValue V; V.ResNo = -1U; return V; } + static inline SDValue getTombstoneKey() { SDValue V; V.ResNo = -2U; return V; } + static unsigned getHashValue(const SDValue &Val) { return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^ (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo(); } + static bool isEqual(const SDValue &LHS, const SDValue &RHS) { return LHS == RHS; } }; template <> struct isPodLike { static const bool value = true; }; - /// Allow casting operators to work directly on /// SDValues as if they were SDNode*'s. template<> struct simplify_type { @@ -243,7 +259,7 @@ class SDUse { void operator=(const SDUse &U) = delete; public: - SDUse() : Val(), User(nullptr), Prev(nullptr), Next(nullptr) {} + SDUse() : User(nullptr), Prev(nullptr), Next(nullptr) {} /// Normally SDUse will just implicitly convert to an SDValue that it holds. operator const SDValue&() const { return Val; } @@ -600,9 +616,11 @@ public: class use_iterator : public std::iterator { SDUse *Op; - explicit use_iterator(SDUse *op) : Op(op) { - } + friend class SDNode; + + explicit use_iterator(SDUse *op) : Op(op) {} + public: typedef std::iterator::reference reference; @@ -730,6 +748,7 @@ public: } typedef SDUse* op_iterator; + op_iterator op_begin() const { return OperandList; } op_iterator op_end() const { return OperandList+NumOperands; } ArrayRef ops() const { return makeArrayRef(op_begin(), op_end()); } @@ -829,7 +848,6 @@ public: void printrWithDepth(raw_ostream &O, const SelectionDAG *G = nullptr, unsigned depth = 100) const; - /// Dump this node, for debugging. void dump() const; @@ -913,11 +931,11 @@ public: if (I) DL = I->getDebugLoc(); } + unsigned getIROrder() const { return IROrder; } const DebugLoc &getDebugLoc() const { return DL; } }; - // Define inline functions from the SDValue class. inline SDValue::SDValue(SDNode *node, unsigned resno) @@ -933,48 +951,63 @@ inline SDValue::SDValue(SDNode *node, unsigned resno) inline unsigned SDValue::getOpcode() const { return Node->getOpcode(); } + inline EVT SDValue::getValueType() const { return Node->getValueType(ResNo); } + inline unsigned SDValue::getNumOperands() const { return Node->getNumOperands(); } + inline const SDValue &SDValue::getOperand(unsigned i) const { return Node->getOperand(i); } + inline uint64_t SDValue::getConstantOperandVal(unsigned i) const { return Node->getConstantOperandVal(i); } + inline bool SDValue::isTargetOpcode() const { return Node->isTargetOpcode(); } + inline bool SDValue::isTargetMemoryOpcode() const { return Node->isTargetMemoryOpcode(); } + inline bool SDValue::isMachineOpcode() const { return Node->isMachineOpcode(); } + inline unsigned SDValue::getMachineOpcode() const { return Node->getMachineOpcode(); } + inline bool SDValue::isUndef() const { return Node->isUndef(); } + inline bool SDValue::use_empty() const { return !Node->hasAnyUseOfValue(ResNo); } + inline bool SDValue::hasOneUse() const { return Node->hasNUsesOfValue(1, ResNo); } + inline const DebugLoc &SDValue::getDebugLoc() const { return Node->getDebugLoc(); } + inline void SDValue::dump() const { return Node->dump(); } + inline void SDValue::dumpr() const { return Node->dumpr(); } + // Define inline functions from the SDUse class. inline void SDUse::set(const SDValue &V) { @@ -1021,9 +1054,11 @@ static bool isBinOpWithFlags(unsigned Opcode) { class BinaryWithFlagsSDNode : public SDNode { public: SDNodeFlags Flags; + BinaryWithFlagsSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, SDVTList VTs, const SDNodeFlags &NodeFlags) : SDNode(Opc, Order, dl, VTs), Flags(NodeFlags) {} + static bool classof(const SDNode *N) { return isBinOpWithFlags(N->getOpcode()); } @@ -1035,6 +1070,7 @@ public: /// the AllNodes list. class HandleSDNode : public SDNode { SDUse Op; + public: explicit HandleSDNode(SDValue X) : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) { @@ -1052,6 +1088,7 @@ public: OperandList = &Op; } ~HandleSDNode(); + const SDValue &getValue() const { return Op; } }; @@ -1267,8 +1304,10 @@ class ShuffleVectorSDNode : public SDNode { // The memory for Mask is owned by the SelectionDAG's OperandAllocator, and // is freed when the SelectionDAG object is destroyed. const int *Mask; + protected: friend class SelectionDAG; + ShuffleVectorSDNode(EVT VT, unsigned Order, const DebugLoc &dl, const int *M) : SDNode(ISD::VECTOR_SHUFFLE, Order, dl, getSDVTList(VT)), Mask(M) {} @@ -1277,12 +1316,14 @@ public: EVT VT = getValueType(0); return makeArrayRef(Mask, VT.getVectorNumElements()); } + int getMaskElt(unsigned Idx) const { assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!"); return Mask[Idx]; } bool isSplat() const { return isSplatMask(Mask, getValueType(0)); } + int getSplatIndex() const { assert(isSplat() && "Cannot get splat index for non-splat!"); EVT VT = getValueType(0); @@ -1292,6 +1333,7 @@ public: } llvm_unreachable("Splat with all undef indices?"); } + static bool isSplatMask(const int *Mask, EVT VT); /// Change values in a shuffle permute mask assuming @@ -1316,7 +1358,9 @@ public: class ConstantSDNode : public SDNode { const ConstantInt *Value; + friend class SelectionDAG; + ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, const DebugLoc &DL, EVT VT) : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, DL, @@ -1324,8 +1368,8 @@ class ConstantSDNode : public SDNode { Value(val) { ConstantSDNodeBits.IsOpaque = isOpaque; } -public: +public: const ConstantInt *getConstantIntValue() const { return Value; } const APInt &getAPIntValue() const { return Value->getValue(); } uint64_t getZExtValue() const { return Value->getZExtValue(); } @@ -1345,7 +1389,9 @@ public: class ConstantFPSDNode : public SDNode { const ConstantFP *Value; + friend class SelectionDAG; + ConstantFPSDNode(bool isTarget, const ConstantFP *val, const DebugLoc &DL, EVT VT) : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0, DL, @@ -1353,7 +1399,6 @@ class ConstantFPSDNode : public SDNode { Value(val) {} public: - const APFloat& getValueAPF() const { return Value->getValueAPF(); } const ConstantFP *getConstantFPValue() const { return Value; } @@ -1416,7 +1461,6 @@ ConstantSDNode *isConstOrConstSplat(SDValue V); /// Returns the SDNode if it is a constant splat BuildVector or constant float. ConstantFPSDNode *isConstOrConstSplatFP(SDValue V); - class GlobalAddressSDNode : public SDNode { const GlobalValue *TheGlobal; int64_t Offset; @@ -1427,7 +1471,6 @@ class GlobalAddressSDNode : public SDNode { unsigned char TargetFlags); public: - const GlobalValue *getGlobal() const { return TheGlobal; } int64_t getOffset() const { return Offset; } unsigned char getTargetFlags() const { return TargetFlags; } @@ -1444,13 +1487,15 @@ public: class FrameIndexSDNode : public SDNode { int FI; + friend class SelectionDAG; + FrameIndexSDNode(int fi, EVT VT, bool isTarg) : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, 0, DebugLoc(), getSDVTList(VT)), FI(fi) { } -public: +public: int getIndex() const { return FI; } static bool classof(const SDNode *N) { @@ -1462,13 +1507,15 @@ public: class JumpTableSDNode : public SDNode { int JTI; unsigned char TargetFlags; + friend class SelectionDAG; + JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF) : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, 0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) { } -public: +public: int getIndex() const { return JTI; } unsigned char getTargetFlags() const { return TargetFlags; } @@ -1486,7 +1533,9 @@ class ConstantPoolSDNode : public SDNode { int Offset; // It's a MachineConstantPoolValue if top bit is set. unsigned Alignment; // Minimum alignment requirement of CP (not log2 value). unsigned char TargetFlags; + friend class SelectionDAG; + ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o, unsigned Align, unsigned char TF) : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, @@ -1495,6 +1544,7 @@ class ConstantPoolSDNode : public SDNode { assert(Offset >= 0 && "Offset is too large"); Val.ConstVal = c; } + ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, EVT VT, int o, unsigned Align, unsigned char TF) : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, @@ -1504,8 +1554,8 @@ class ConstantPoolSDNode : public SDNode { Val.MachineCPVal = v; Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1); } -public: +public: bool isMachineConstantPoolEntry() const { return Offset < 0; } @@ -1542,13 +1592,13 @@ class TargetIndexSDNode : public SDNode { unsigned char TargetFlags; int Index; int64_t Offset; + friend class SelectionDAG; -public: +public: TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF) : SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)), TargetFlags(TF), Index(Idx), Offset(Ofs) {} -public: unsigned char getTargetFlags() const { return TargetFlags; } int getIndex() const { return Index; } @@ -1561,15 +1611,17 @@ public: class BasicBlockSDNode : public SDNode { MachineBasicBlock *MBB; + friend class SelectionDAG; + /// Debug info is meaningful and potentially useful here, but we create /// blocks out of order when they're jumped to, which makes it a bit /// harder. Let's see if we need it first. explicit BasicBlockSDNode(MachineBasicBlock *mbb) : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb) {} -public: +public: MachineBasicBlock *getBasicBlock() const { return MBB; } static bool classof(const SDNode *N) { @@ -1581,6 +1633,7 @@ public: class BuildVectorSDNode : public SDNode { // These are constructed as SDNodes and then cast to BuildVectorSDNodes. explicit BuildVectorSDNode() = delete; + public: /// Check if this is a constant splat, and if so, find the /// smallest element size that splats the vector. If MinSplatBits is @@ -1639,7 +1692,9 @@ public: /// class SrcValueSDNode : public SDNode { const Value *V; + friend class SelectionDAG; + /// Create a SrcValue for a general value. explicit SrcValueSDNode(const Value *v) : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {} @@ -1655,12 +1710,14 @@ public: class MDNodeSDNode : public SDNode { const MDNode *MD; + friend class SelectionDAG; + explicit MDNodeSDNode(const MDNode *md) : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md) {} -public: +public: const MDNode *getMD() const { return MD; } static bool classof(const SDNode *N) { @@ -1670,12 +1727,13 @@ public: class RegisterSDNode : public SDNode { unsigned Reg; + friend class SelectionDAG; + RegisterSDNode(unsigned reg, EVT VT) - : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) { - } -public: + : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {} +public: unsigned getReg() const { return Reg; } static bool classof(const SDNode *N) { @@ -1686,12 +1744,14 @@ public: class RegisterMaskSDNode : public SDNode { // The memory for RegMask is not owned by the node. const uint32_t *RegMask; + friend class SelectionDAG; + RegisterMaskSDNode(const uint32_t *mask) : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)), RegMask(mask) {} -public: +public: const uint32_t *getRegMask() const { return RegMask; } static bool classof(const SDNode *N) { @@ -1703,12 +1763,15 @@ class BlockAddressSDNode : public SDNode { const BlockAddress *BA; int64_t Offset; unsigned char TargetFlags; + friend class SelectionDAG; + BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba, int64_t o, unsigned char Flags) : SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)), BA(ba), Offset(o), TargetFlags(Flags) { } + public: const BlockAddress *getBlockAddress() const { return BA; } int64_t getOffset() const { return Offset; } @@ -1722,7 +1785,9 @@ public: class EHLabelSDNode : public SDNode { MCSymbol *Label; + friend class SelectionDAG; + EHLabelSDNode(unsigned Order, const DebugLoc &dl, MCSymbol *L) : SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {} @@ -1739,12 +1804,12 @@ class ExternalSymbolSDNode : public SDNode { unsigned char TargetFlags; friend class SelectionDAG; + ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT) : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, - 0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) { - } -public: + 0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) {} +public: const char *getSymbol() const { return Symbol; } unsigned char getTargetFlags() const { return TargetFlags; } @@ -1771,13 +1836,14 @@ public: class CondCodeSDNode : public SDNode { ISD::CondCode Condition; + friend class SelectionDAG; + explicit CondCodeSDNode(ISD::CondCode Cond) : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)), - Condition(Cond) { - } -public: + Condition(Cond) {} +public: ISD::CondCode get() const { return Condition; } static bool classof(const SDNode *N) { @@ -1789,7 +1855,9 @@ public: /// future and most targets don't support it. class CvtRndSatSDNode : public SDNode { ISD::CvtCode CvtCode; + friend class SelectionDAG; + explicit CvtRndSatSDNode(EVT VT, unsigned Order, const DebugLoc &dl, ISD::CvtCode Code) : SDNode(ISD::CONVERT_RNDSAT, Order, dl, getSDVTList(VT)), CvtCode(Code) { @@ -1807,13 +1875,14 @@ public: /// to parameterize some operations. class VTSDNode : public SDNode { EVT ValueType; + friend class SelectionDAG; + explicit VTSDNode(EVT VT) : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)), - ValueType(VT) { - } -public: + ValueType(VT) {} +public: EVT getVT() const { return ValueType; } static bool classof(const SDNode *N) { @@ -1857,6 +1926,7 @@ public: /// This class is used to represent ISD::LOAD nodes. class LoadSDNode : public LSBaseSDNode { friend class SelectionDAG; + LoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::MemIndexedMode AM, ISD::LoadExtType ETy, EVT MemVT, MachineMemOperand *MMO) @@ -1865,8 +1935,8 @@ class LoadSDNode : public LSBaseSDNode { assert(readMem() && "Load MachineMemOperand is not a load!"); assert(!writeMem() && "Load MachineMemOperand is a store!"); } -public: +public: /// Return whether this is a plain node, /// or one of the varieties of value-extending loads. ISD::LoadExtType getExtensionType() const { @@ -1884,6 +1954,7 @@ public: /// This class is used to represent ISD::STORE nodes. class StoreSDNode : public LSBaseSDNode { friend class SelectionDAG; + StoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::MemIndexedMode AM, bool isTrunc, EVT MemVT, MachineMemOperand *MMO) @@ -1892,8 +1963,8 @@ class StoreSDNode : public LSBaseSDNode { assert(!readMem() && "Store MachineMemOperand is a load!"); assert(writeMem() && "Store MachineMemOperand is not a store!"); } -public: +public: /// Return true if the op does a truncation before store. /// For integers this is the same as doing a TRUNCATE and storing the result. /// For floats, it is the same as doing an FP_ROUND and storing the result. @@ -1912,6 +1983,7 @@ public: class MaskedLoadStoreSDNode : public MemSDNode { public: friend class SelectionDAG; + MaskedLoadStoreSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO) @@ -1956,9 +2028,9 @@ public: /// This class is used to represent an MSTORE node class MaskedStoreSDNode : public MaskedLoadStoreSDNode { - public: friend class SelectionDAG; + MaskedStoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, bool isTrunc, bool isCompressing, EVT MemVT, MachineMemOperand *MMO) @@ -1966,6 +2038,7 @@ public: StoreSDNodeBits.IsTruncating = isTrunc; StoreSDNodeBits.IsCompressing = isCompressing; } + /// Return true if the op does a truncation before store. /// For integers this is the same as doing a TRUNCATE and storing the result. /// For floats, it is the same as doing an FP_ROUND and storing the result. @@ -1990,6 +2063,7 @@ public: class MaskedGatherScatterSDNode : public MemSDNode { public: friend class SelectionDAG; + MaskedGatherScatterSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO) @@ -2015,6 +2089,7 @@ public: class MaskedGatherSDNode : public MaskedGatherScatterSDNode { public: friend class SelectionDAG; + MaskedGatherSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO) : MaskedGatherScatterSDNode(ISD::MGATHER, Order, dl, VTs, MemVT, MMO) {} @@ -2027,9 +2102,9 @@ public: /// This class is used to represent an MSCATTER node /// class MaskedScatterSDNode : public MaskedGatherScatterSDNode { - public: friend class SelectionDAG; + MaskedScatterSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO) : MaskedGatherScatterSDNode(ISD::MSCATTER, Order, dl, VTs, MemVT, MMO) {} @@ -2048,6 +2123,7 @@ public: private: friend class SelectionDAG; + MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL, SDVTList VTs) : SDNode(Opc, Order, DL, VTs), MemRefs(nullptr), MemRefsEnd(nullptr) {} @@ -2080,6 +2156,7 @@ class SDNodeIterator : public std::iterator struct GraphTraits { typedef SDNode *NodeRef; typedef SDNodeIterator ChildIteratorType; + static NodeRef getEntryNode(SDNode *N) { return N; } static ChildIteratorType child_begin(NodeRef N) { return SDNodeIterator::begin(N); @@ -2137,6 +2215,7 @@ typedef AlignedCharArrayUnion(N); @@ -2197,8 +2276,9 @@ namespace ISD { return isa(N) && cast(N)->getAddressingMode() == ISD::UNINDEXED; } -} -} // end llvm namespace +} // end namespace ISD + +} // end namespace llvm -#endif +#endif // LLVM_CODEGEN_SELECTIONDAGNODES_H diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h index 023c94c..c71759a 100644 --- a/llvm/include/llvm/Support/Allocator.h +++ b/llvm/include/llvm/Support/Allocator.h @@ -22,13 +22,16 @@ #define LLVM_SUPPORT_ALLOCATOR_H #include "llvm/ADT/SmallVector.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/Memory.h" #include #include #include +#include #include +#include +#include +#include namespace llvm { @@ -113,7 +116,8 @@ namespace detail { // printing code uses Allocator.h in its implementation. void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated, size_t TotalMemory); -} // End namespace detail. + +} // end namespace detail /// \brief Allocate memory in an ever growing pool, as if by bump-pointer. /// @@ -365,7 +369,7 @@ template class SpecificBumpPtrAllocator { BumpPtrAllocator Allocator; public: - SpecificBumpPtrAllocator() : Allocator() {} + SpecificBumpPtrAllocator() = default; SpecificBumpPtrAllocator(SpecificBumpPtrAllocator &&Old) : Allocator(std::move(Old.Allocator)) {} ~SpecificBumpPtrAllocator() { DestroyAll(); } @@ -409,7 +413,7 @@ public: T *Allocate(size_t num = 1) { return Allocator.Allocate(num); } }; -} // end namespace llvm +} // end namespace llvm template void *operator new(size_t Size, diff --git a/llvm/include/llvm/Support/GCOV.h b/llvm/include/llvm/Support/GCOV.h index 544434f..f297fe6 100644 --- a/llvm/include/llvm/Support/GCOV.h +++ b/llvm/include/llvm/Support/GCOV.h @@ -1,4 +1,4 @@ -//===- GCOV.h - LLVM coverage tool ----------------------------------------===// +//===- GCOV.h - LLVM coverage tool ------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,12 +16,20 @@ #define LLVM_SUPPORT_GCOV_H #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/iterator.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include namespace llvm { @@ -30,6 +38,7 @@ class GCOVBlock; class FileInfo; namespace GCOV { + enum GCOVVersion { V402, V404, V704 }; /// \brief A struct for passing gcov options between functions. @@ -47,7 +56,8 @@ struct Options { bool LongFileNames; bool NoOutput; }; -} // end GCOV namespace + +} // end namespace GCOV /// GCOVBuffer - A wrapper around MemoryBuffer to provide GCOV specific /// read operations. @@ -232,8 +242,9 @@ private: class GCOVFile { public: GCOVFile() - : GCNOInitialized(false), Checksum(0), Functions(), RunCount(0), + : GCNOInitialized(false), Checksum(0), RunCount(0), ProgramCount(0) {} + bool readGCNO(GCOVBuffer &Buffer); bool readGCDA(GCOVBuffer &Buffer); uint32_t getChecksum() const { return Checksum; } @@ -312,9 +323,9 @@ public: typedef SmallVectorImpl::const_iterator EdgeIterator; GCOVBlock(GCOVFunction &P, uint32_t N) - : Parent(P), Number(N), Counter(0), DstEdgesAreSorted(true), SrcEdges(), - DstEdges(), Lines() {} + : Parent(P), Number(N), Counter(0), DstEdgesAreSorted(true) {} ~GCOVBlock(); + const GCOVFunction &getParent() const { return Parent; } void addLine(uint32_t N) { Lines.push_back(N); } uint32_t getLastLine() const { return Lines.back(); } @@ -325,6 +336,7 @@ public: assert(&Edge->Dst == this); // up to caller to ensure edge is valid SrcEdges.push_back(Edge); } + void addDstEdge(GCOVEdge *Edge) { assert(&Edge->Src == this); // up to caller to ensure edge is valid // Check if adding this edge causes list to become unsorted. @@ -332,6 +344,7 @@ public: DstEdgesAreSorted = false; DstEdges.push_back(Edge); } + size_t getNumSrcEdges() const { return SrcEdges.size(); } size_t getNumDstEdges() const { return DstEdges.size(); } void sortDstEdges(); @@ -396,19 +409,21 @@ class FileInfo { public: FileInfo(const GCOV::Options &Options) - : Options(Options), LineInfo(), RunCount(0), ProgramCount(0) {} + : Options(Options), RunCount(0), ProgramCount(0) {} void addBlockLine(StringRef Filename, uint32_t Line, const GCOVBlock *Block) { if (Line > LineInfo[Filename].LastLine) LineInfo[Filename].LastLine = Line; LineInfo[Filename].Blocks[Line - 1].push_back(Block); } + void addFunctionLine(StringRef Filename, uint32_t Line, const GCOVFunction *Function) { if (Line > LineInfo[Filename].LastLine) LineInfo[Filename].LastLine = Line; LineInfo[Filename].Functions[Line - 1].push_back(Function); } + void setRunCount(uint32_t Runs) { RunCount = Runs; } void setProgramCount(uint32_t Programs) { ProgramCount = Programs; } void print(raw_ostream &OS, StringRef MainFilename, StringRef GCNOFile, @@ -440,6 +455,7 @@ private: FileCoverageList FileCoverages; FuncCoverageMap FuncCoverages; }; -} -#endif +} // end namespace llvm + +#endif // LLVM_SUPPORT_GCOV_H diff --git a/llvm/include/llvm/Support/RWMutex.h b/llvm/include/llvm/Support/RWMutex.h index 4be9313..e4736b8 100644 --- a/llvm/include/llvm/Support/RWMutex.h +++ b/llvm/include/llvm/Support/RWMutex.h @@ -18,10 +18,9 @@ #include "llvm/Support/Threading.h" #include -namespace llvm -{ - namespace sys - { +namespace llvm { +namespace sys { + /// @brief Platform agnostic RWMutex class. class RWMutexImpl { @@ -89,9 +88,11 @@ namespace llvm template class SmartRWMutex { RWMutexImpl impl; - unsigned readers, writers; + unsigned readers = 0; + unsigned writers = 0; + public: - explicit SmartRWMutex() : impl(), readers(0), writers(0) { } + explicit SmartRWMutex() = default; bool lock_shared() { if (!mt_only || llvm_is_multithreaded()) @@ -140,6 +141,7 @@ namespace llvm SmartRWMutex(const SmartRWMutex & original); void operator=(const SmartRWMutex &); }; + typedef SmartRWMutex RWMutex; /// ScopedReader - RAII acquisition of a reader lock @@ -155,6 +157,7 @@ namespace llvm mutex.unlock_shared(); } }; + typedef SmartScopedReader ScopedReader; /// ScopedWriter - RAII acquisition of a writer lock @@ -170,8 +173,10 @@ namespace llvm mutex.unlock(); } }; + typedef SmartScopedWriter ScopedWriter; - } -} -#endif +} // end namespace sys +} // end namespace llvm + +#endif // LLVM_SUPPORT_RWMUTEX_H diff --git a/llvm/include/llvm/Support/SMLoc.h b/llvm/include/llvm/Support/SMLoc.h index 7f32d8d..eb3a1ba 100644 --- a/llvm/include/llvm/Support/SMLoc.h +++ b/llvm/include/llvm/Support/SMLoc.h @@ -50,8 +50,8 @@ class SMRange { public: SMLoc Start, End; - SMRange() {} - SMRange(NoneType) : Start(), End() {} + SMRange() = default; + SMRange(NoneType) {} SMRange(SMLoc St, SMLoc En) : Start(St), End(En) { assert(Start.isValid() == End.isValid() && "Start and end should either both be valid or both be invalid!"); @@ -62,4 +62,4 @@ public: } // end namespace llvm -#endif +#endif // LLVM_SUPPORT_SMLOC_H -- 2.7.4