Index: include/llvm/ADT/SmallPtrSet.h =================================================================== --- include/llvm/ADT/SmallPtrSet.h +++ include/llvm/ADT/SmallPtrSet.h @@ -16,7 +16,6 @@ #define LLVM_ADT_SMALLPTRSET_H #include "llvm/Support/Compiler.h" -#include "llvm/Support/DataTypes.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include #include @@ -27,8 +26,6 @@ namespace llvm { -class SmallPtrSetIteratorImpl; - /// SmallPtrSetImplBase - This is the common code shared among all the /// SmallPtrSet<>'s, which is almost everything. SmallPtrSet has two modes, one /// for small and one for large sets. @@ -71,12 +68,14 @@ const SmallPtrSetImplBase &that); SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize, SmallPtrSetImplBase &&that); + explicit SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize) : SmallArray(SmallStorage), CurArray(SmallStorage), CurArraySize(SmallSize), NumNonEmpty(0), NumTombstones(0) { assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 && "Initial size must be a power of two!"); } + ~SmallPtrSetImplBase() { if (!isSmall()) free(CurArray); @@ -84,7 +83,11 @@ public: typedef unsigned size_type; - bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { return size() == 0; } + + bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { + return NumNonEmpty == NumTombstones; + } + size_type size() const { return NumNonEmpty - NumTombstones; } void clear() { @@ -210,6 +213,7 @@ bool operator==(const SmallPtrSetIteratorImpl &RHS) const { return Bucket == RHS.Bucket; } + bool operator!=(const SmallPtrSetIteratorImpl &RHS) const { return Bucket != RHS.Bucket; } @@ -393,14 +397,17 @@ SmallPtrSetImplBase::swap(RHS); } }; -} + +} // end namespace llvm namespace std { + /// Implement std::swap in terms of SmallPtrSet swap. template inline void swap(llvm::SmallPtrSet &LHS, llvm::SmallPtrSet &RHS) { LHS.swap(RHS); } -} -#endif +} // end namespace std + +#endif // LLVM_ADT_SMALLPTRSET_H Index: include/llvm/ADT/SparseMultiSet.h =================================================================== --- include/llvm/ADT/SparseMultiSet.h +++ include/llvm/ADT/SparseMultiSet.h @@ -21,7 +21,15 @@ #ifndef LLVM_ADT_SPARSEMULTISET_H #define LLVM_ADT_SPARSEMULTISET_H +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SparseSet.h" +#include "llvm/ADT/STLExtras.h" +#include +#include +#include +#include +#include +#include namespace llvm { @@ -321,7 +329,7 @@ /// /// This is not the same as BitVector::empty(). /// - bool empty() const { return size() == 0; } + bool empty() const { return Dense.size() == NumFree; } /// Returns the number of elements in the set. /// @@ -515,4 +523,4 @@ } // end namespace llvm -#endif +#endif // LLVM_ADT_SPARSEMULTISET_H Index: include/llvm/CodeGen/LiveRangeEdit.h =================================================================== --- include/llvm/CodeGen/LiveRangeEdit.h +++ include/llvm/CodeGen/LiveRangeEdit.h @@ -19,13 +19,19 @@ #define LLVM_CODEGEN_LIVERANGEEDIT_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/LiveInterval.h" +#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/SlotIndexes.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetSubtargetInfo.h" +#include namespace llvm { @@ -39,6 +45,7 @@ /// Callback methods for LiveRangeEdit owners. class Delegate { virtual void anchor(); + public: /// Called immediately before erasing a dead machine instruction. virtual void LRE_WillEraseInstruction(MachineInstr *MI) {} @@ -140,14 +147,15 @@ assert(Parent && "No parent LiveInterval"); return *Parent; } + unsigned getReg() const { return getParent().reg; } /// Iterator for accessing the new registers added by this edit. typedef SmallVectorImpl::const_iterator iterator; - iterator begin() const { return NewRegs.begin()+FirstNew; } + iterator begin() const { return NewRegs.begin() + FirstNew; } iterator end() const { return NewRegs.end(); } - unsigned size() const { return NewRegs.size()-FirstNew; } - bool empty() const { return size() == 0; } + unsigned size() const { return NewRegs.size() - FirstNew; } + bool empty() const { return NewRegs.size() == FirstNew; } unsigned get(unsigned idx) const { return NewRegs[idx+FirstNew]; } /// pop_back - It allows LiveRangeEdit users to drop new registers. @@ -253,6 +261,6 @@ const MachineBlockFrequencyInfo&); }; -} +} // end namespace llvm -#endif +#endif // LLVM_CODEGEN_LIVERANGEEDIT_H Index: include/llvm/DebugInfo/MSF/StreamInterface.h =================================================================== --- include/llvm/DebugInfo/MSF/StreamInterface.h +++ include/llvm/DebugInfo/MSF/StreamInterface.h @@ -37,7 +37,7 @@ class WritableStream : public ReadableStream { public: - virtual ~WritableStream() {} + ~WritableStream() override {} // Attempt to write the given bytes into the stream at the desired offset. // This will always necessitate a copy. Cannot shrink or grow the stream, Index: include/llvm/DebugInfo/MSF/StreamWriter.h =================================================================== --- include/llvm/DebugInfo/MSF/StreamWriter.h +++ include/llvm/DebugInfo/MSF/StreamWriter.h @@ -11,14 +11,13 @@ #define LLVM_DEBUGINFO_MSF_STREAMWRITER_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/MSF/MSFError.h" #include "llvm/DebugInfo/MSF/StreamArray.h" -#include "llvm/DebugInfo/MSF/StreamInterface.h" #include "llvm/DebugInfo/MSF/StreamRef.h" -#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" - -#include +#include +#include namespace llvm { namespace msf { @@ -50,7 +49,7 @@ } template Error writeArray(ArrayRef Array) { - if (Array.size() == 0) + if (Array.empty()) return Error::success(); if (Array.size() > UINT32_MAX / sizeof(T)) @@ -79,7 +78,8 @@ WritableStreamRef Stream; uint32_t Offset; }; -} // namespace msf -} // namespace llvm + +} // end namespace msf +} // end namespace llvm #endif // LLVM_DEBUGINFO_MSF_STREAMWRITER_H Index: include/llvm/ProfileData/SampleProf.h =================================================================== --- include/llvm/ProfileData/SampleProf.h +++ include/llvm/ProfileData/SampleProf.h @@ -1,4 +1,4 @@ -//=-- SampleProf.h - Sampling profiling format support --------------------===// +//=-- SampleProf.h - Sampling profiling format support ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,17 +12,22 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_PROFILEDATA_SAMPLEPROF_H_ -#define LLVM_PROFILEDATA_SAMPLEPROF_H_ +#ifndef LLVM_PROFILEDATA_SAMPLEPROF_H +#define LLVM_PROFILEDATA_SAMPLEPROF_H #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorOr.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" - +#include +#include #include +#include #include +#include namespace llvm { @@ -59,12 +64,13 @@ } // end namespace llvm namespace std { + template <> struct is_error_code_enum : std::true_type {}; -} -namespace llvm { +} // end namespace std +namespace llvm { namespace sampleprof { static inline uint64_t SPMagic() { @@ -87,8 +93,10 @@ /// (e.g., the two post-increment instructions in "if (p) x++; else y++;"). struct LineLocation { LineLocation(uint32_t L, uint32_t D) : LineOffset(L), Discriminator(D) {} + void print(raw_ostream &OS) const; void dump() const; + bool operator<(const LineLocation &O) const { return LineOffset < O.LineOffset || (LineOffset == O.LineOffset && Discriminator < O.Discriminator); @@ -144,7 +152,7 @@ } /// Return true if this sample record contains function calls. - bool hasCalls() const { return CallTargets.size() > 0; } + bool hasCalls() const { return !CallTargets.empty(); } uint64_t getSamples() const { return NumSamples; } const CallTargetMap &getCallTargets() const { return CallTargets; } @@ -181,8 +189,10 @@ class FunctionSamples { public: FunctionSamples() : Name(), TotalSamples(0), TotalHeadSamples(0) {} + void print(raw_ostream &OS = dbgs(), unsigned Indent = 0) const; void dump() const; + sampleprof_error addTotalSamples(uint64_t Num, uint64_t Weight = 1) { bool Overflowed; TotalSamples = @@ -190,6 +200,7 @@ return Overflowed ? sampleprof_error::counter_overflow : sampleprof_error::success; } + sampleprof_error addHeadSamples(uint64_t Num, uint64_t Weight = 1) { bool Overflowed; TotalHeadSamples = @@ -197,11 +208,13 @@ return Overflowed ? sampleprof_error::counter_overflow : sampleprof_error::success; } + sampleprof_error addBodySamples(uint32_t LineOffset, uint32_t Discriminator, uint64_t Num, uint64_t Weight = 1) { return BodySamples[LineLocation(LineOffset, Discriminator)].addSamples( Num, Weight); } + sampleprof_error addCalledTargetSamples(uint32_t LineOffset, uint32_t Discriminator, const std::string &FName, @@ -347,7 +360,6 @@ }; } // end namespace sampleprof - } // end namespace llvm -#endif // LLVM_PROFILEDATA_SAMPLEPROF_H_ +#endif // LLVM_PROFILEDATA_SAMPLEPROF_H