From: Eugene Zelenko Date: Fri, 12 May 2017 22:25:07 +0000 (+0000) Subject: [IR] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). X-Git-Tag: llvmorg-5.0.0-rc1~5174 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cd7948876023b4f491492fd73ae704fec8521fa;p=platform%2Fupstream%2Fllvm.git [IR] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). llvm-svn: 302961 --- diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h index d13d5dd..ad011fb 100644 --- a/llvm/include/llvm/IR/LLVMContext.h +++ b/llvm/include/llvm/IR/LLVMContext.h @@ -1,4 +1,4 @@ -//===-- llvm/LLVMContext.h - Class for managing "global" state --*- C++ -*-===// +//===- llvm/LLVMContext.h - Class for managing "global" state ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -37,7 +37,9 @@ class StringRef; class Twine; namespace yaml { + class Output; + } // end namespace yaml /// This is an important class for using LLVM in a threaded context. It @@ -134,17 +136,17 @@ public: void enableDebugTypeODRUniquing(); void disableDebugTypeODRUniquing(); - typedef void (*InlineAsmDiagHandlerTy)(const SMDiagnostic&, void *Context, - unsigned LocCookie); + using InlineAsmDiagHandlerTy = void (*)(const SMDiagnostic&, void *Context, + unsigned LocCookie); /// Defines the type of a diagnostic handler. /// \see LLVMContext::setDiagnosticHandler. /// \see LLVMContext::diagnose. - typedef void (*DiagnosticHandlerTy)(const DiagnosticInfo &DI, void *Context); + using DiagnosticHandlerTy = void (*)(const DiagnosticInfo &DI, void *Context); /// Defines the type of a yield callback. /// \see LLVMContext::setYieldCallback. - typedef void (*YieldCallbackTy)(LLVMContext *Context, void *OpaqueHandle); + using YieldCallbackTy = void (*)(LLVMContext *Context, void *OpaqueHandle); /// setInlineAsmDiagnosticHandler - This method sets a handler that is invoked /// when problems with inline asm are detected by the backend. The first diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h index 53570bd..c46c609 100644 --- a/llvm/include/llvm/IR/ModuleSummaryIndex.h +++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h @@ -1,4 +1,4 @@ -//===-- llvm/ModuleSummaryIndex.h - Module Summary Index --------*- C++ -*-===// +//===- llvm/ModuleSummaryIndex.h - Module Summary Index ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,21 +16,33 @@ #ifndef LLVM_IR_MODULESUMMARYINDEX_H #define LLVM_IR_MODULESUMMARYINDEX_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/IR/Module.h" - +#include "llvm/IR/GlobalValue.h" +#include #include +#include +#include +#include +#include +#include +#include +#include +#include namespace llvm { namespace yaml { + template struct MappingTraits; -} + +} // end namespace yaml /// \brief Class to accumulate and hold information about a callee. struct CalleeInfo { @@ -47,7 +59,7 @@ struct CalleeInfo { class GlobalValueSummary; -typedef std::vector> GlobalValueSummaryList; +using GlobalValueSummaryList = std::vector>; struct GlobalValueSummaryInfo { /// The GlobalValue corresponding to this summary. This is only used in @@ -66,19 +78,22 @@ struct GlobalValueSummaryInfo { /// likely incur less overhead, as the value type is not very small and the size /// of the map is unknown, resulting in inefficiencies due to repeated /// insertions and resizing. -typedef std::map - GlobalValueSummaryMapTy; +using GlobalValueSummaryMapTy = + std::map; /// Struct that holds a reference to a particular GUID in a global value /// summary. struct ValueInfo { const GlobalValueSummaryMapTy::value_type *Ref = nullptr; + ValueInfo() = default; ValueInfo(const GlobalValueSummaryMapTy::value_type *Ref) : Ref(Ref) {} + operator bool() const { return Ref; } GlobalValue::GUID getGUID() const { return Ref->first; } const GlobalValue *getValue() const { return Ref->second.GV; } + ArrayRef> getSummaryList() const { return Ref->second.SummaryList; } @@ -88,9 +103,11 @@ template <> struct DenseMapInfo { static inline ValueInfo getEmptyKey() { return ValueInfo((GlobalValueSummaryMapTy::value_type *)-1); } + static inline ValueInfo getTombstoneKey() { return ValueInfo((GlobalValueSummaryMapTy::value_type *)-2); } + static bool isEqual(ValueInfo L, ValueInfo R) { return L.Ref == R.Ref; } static unsigned getHashValue(ValueInfo I) { return (uintptr_t)I.Ref; } }; @@ -138,7 +155,7 @@ private: /// This is the hash of the name of the symbol in the original file. It is /// identical to the GUID for global symbols, but differs for local since the /// GUID includes the module level id in the hash. - GlobalValue::GUID OriginalName; + GlobalValue::GUID OriginalName = 0; /// \brief Path of module IR containing value's definition, used to locate /// module during importing. @@ -157,7 +174,7 @@ private: protected: GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector Refs) - : Kind(K), Flags(Flags), OriginalName(0), RefEdgeList(std::move(Refs)) {} + : Kind(K), Flags(Flags), RefEdgeList(std::move(Refs)) {} public: virtual ~GlobalValueSummary() = default; @@ -242,7 +259,7 @@ public: class FunctionSummary : public GlobalValueSummary { public: /// call edge pair. - typedef std::pair EdgeTy; + using EdgeTy = std::pair; /// An "identifier" for a virtual function. This contains the type identifier /// represented as a GUID and the offset from the address point to the virtual @@ -376,12 +393,15 @@ public: template <> struct DenseMapInfo { static FunctionSummary::VFuncId getEmptyKey() { return {0, uint64_t(-1)}; } + static FunctionSummary::VFuncId getTombstoneKey() { return {0, uint64_t(-2)}; } + static bool isEqual(FunctionSummary::VFuncId L, FunctionSummary::VFuncId R) { return L.GUID == R.GUID && L.Offset == R.Offset; } + static unsigned getHashValue(FunctionSummary::VFuncId I) { return I.GUID; } }; @@ -389,14 +409,17 @@ template <> struct DenseMapInfo { static FunctionSummary::ConstVCall getEmptyKey() { return {{0, uint64_t(-1)}, {}}; } + static FunctionSummary::ConstVCall getTombstoneKey() { return {{0, uint64_t(-2)}, {}}; } + static bool isEqual(FunctionSummary::ConstVCall L, FunctionSummary::ConstVCall R) { return DenseMapInfo::isEqual(L.VFunc, R.VFunc) && L.Args == R.Args; } + static unsigned getHashValue(FunctionSummary::ConstVCall I) { return I.VFunc.GUID; } @@ -477,20 +500,20 @@ struct TypeIdSummary { }; /// 160 bits SHA1 -typedef std::array ModuleHash; +using ModuleHash = std::array; /// Type used for iterating through the global value summary map. -typedef GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator; -typedef GlobalValueSummaryMapTy::iterator gvsummary_iterator; +using const_gvsummary_iterator = GlobalValueSummaryMapTy::const_iterator; +using gvsummary_iterator = GlobalValueSummaryMapTy::iterator; /// String table to hold/own module path strings, which additionally holds the /// module ID assigned to each module during the plugin step, as well as a hash /// of the module. The StringMap makes a copy of and owns inserted strings. -typedef StringMap> ModulePathStringTableTy; +using ModulePathStringTableTy = StringMap>; /// Map of global value GUID to its summary, used to identify values defined in /// a particular module, and provide efficient access to their summary. -typedef std::map GVSummaryMapTy; +using GVSummaryMapTy = std::map; /// Class to hold module path string table and global value map, /// and encapsulate methods for operating on them. @@ -697,6 +720,6 @@ public: StringMap &ModuleToDefinedGVSummaries) const; }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_MODULESUMMARYINDEX_H diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index c845112..d03b7b6 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -39,8 +39,8 @@ #define LLVM_IR_PASSMANAGER_H #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/TinyPtrVector.h" #include "llvm/IR/Function.h" #include "llvm/IR/Module.h" @@ -48,9 +48,15 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/TypeName.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/type_traits.h" +#include +#include +#include +#include #include #include +#include +#include +#include #include namespace llvm { @@ -469,15 +475,16 @@ public: } template void addPass(PassT Pass) { - typedef detail::PassModel - PassModelT; + using PassModelT = + detail::PassModel; + Passes.emplace_back(new PassModelT(std::move(Pass))); } private: - typedef detail::PassConcept - PassConceptT; + using PassConceptT = + detail::PassConcept; std::vector> Passes; @@ -486,12 +493,14 @@ private: }; extern template class PassManager; + /// \brief Convenience typedef for a pass manager over modules. -typedef PassManager ModulePassManager; +using ModulePassManager = PassManager; extern template class PassManager; + /// \brief Convenience typedef for a pass manager over functions. -typedef PassManager FunctionPassManager; +using FunctionPassManager = PassManager; /// \brief A container for analyses that lazily runs them and caches their /// results. @@ -504,11 +513,11 @@ public: private: // Now that we've defined our invalidator, we can define the concept types. - typedef detail::AnalysisResultConcept - ResultConceptT; - typedef detail::AnalysisPassConcept - PassConceptT; + using ResultConceptT = + detail::AnalysisResultConcept; + using PassConceptT = + detail::AnalysisPassConcept; /// \brief List of analysis pass IDs and associated concept pointers. /// @@ -516,18 +525,18 @@ private: /// erases. Provides the analysis ID to enable finding iterators to a given /// entry in maps below, and provides the storage for the actual result /// concept. - typedef std::list>> - AnalysisResultListT; + using AnalysisResultListT = + std::list>>; /// \brief Map type from IRUnitT pointer to our custom list type. - typedef DenseMap AnalysisResultListMapT; + using AnalysisResultListMapT = DenseMap; /// \brief Map type from a pair of analysis ID and IRUnitT pointer to an /// iterator into a particular result list (which is where the actual analysis /// result is stored). - typedef DenseMap, - typename AnalysisResultListT::iterator> - AnalysisResultMapT; + using AnalysisResultMapT = + DenseMap, + typename AnalysisResultListT::iterator>; public: /// API to communicate dependencies between analyses during invalidation. @@ -558,10 +567,10 @@ public: /// dependecies on it will become invalid as a result. template bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA) { - typedef detail::AnalysisResultModel - ResultModelT; + using ResultModelT = + detail::AnalysisResultModel; + return invalidateImpl(PassT::ID(), IR, PA); } @@ -672,9 +681,11 @@ public: "This analysis pass was not registered prior to being queried"); ResultConceptT &ResultConcept = getResultImpl(PassT::ID(), IR, ExtraArgs...); - typedef detail::AnalysisResultModel - ResultModelT; + + using ResultModelT = + detail::AnalysisResultModel; + return static_cast(ResultConcept).Result; } @@ -692,9 +703,10 @@ public: if (!ResultConcept) return nullptr; - typedef detail::AnalysisResultModel - ResultModelT; + using ResultModelT = + detail::AnalysisResultModel; + return &static_cast(ResultConcept)->Result; } @@ -717,10 +729,10 @@ public: /// hashtable.) template bool registerPass(PassBuilderT &&PassBuilder) { - typedef decltype(PassBuilder()) PassT; - typedef detail::AnalysisPassModel - PassModelT; + using PassT = decltype(PassBuilder()); + using PassModelT = + detail::AnalysisPassModel; auto &PassPtr = AnalysisPasses[PassT::ID()]; if (PassPtr) @@ -876,7 +888,8 @@ private: } /// \brief Map type from module analysis pass ID to pass concept pointer. - typedef DenseMap> AnalysisPassMapT; + using AnalysisPassMapT = + DenseMap>; /// \brief Collection of module analysis passes, indexed by ID. AnalysisPassMapT AnalysisPasses; @@ -896,12 +909,14 @@ private: }; extern template class AnalysisManager; + /// \brief Convenience typedef for the Module analysis manager. -typedef AnalysisManager ModuleAnalysisManager; +using ModuleAnalysisManager = AnalysisManager; extern template class AnalysisManager; + /// \brief Convenience typedef for the Function analysis manager. -typedef AnalysisManager FunctionAnalysisManager; +using FunctionAnalysisManager = AnalysisManager; /// \brief An analysis over an "outer" IR unit that provides access to an /// analysis manager over an "inner" IR unit. The inner unit must be contained @@ -927,20 +942,14 @@ public: class Result { public: explicit Result(AnalysisManagerT &InnerAM) : InnerAM(&InnerAM) {} + Result(Result &&Arg) : InnerAM(std::move(Arg.InnerAM)) { // We have to null out the analysis manager in the moved-from state // because we are taking ownership of the responsibilty to clear the // analysis state. Arg.InnerAM = nullptr; } - Result &operator=(Result &&RHS) { - InnerAM = RHS.InnerAM; - // We have to null out the analysis manager in the moved-from state - // because we are taking ownership of the responsibilty to clear the - // analysis state. - RHS.InnerAM = nullptr; - return *this; - } + ~Result() { // InnerAM is cleared in a moved from state where there is nothing to do. if (!InnerAM) @@ -951,6 +960,15 @@ public: InnerAM->clear(); } + Result &operator=(Result &&RHS) { + InnerAM = RHS.InnerAM; + // We have to null out the analysis manager in the moved-from state + // because we are taking ownership of the responsibilty to clear the + // analysis state. + RHS.InnerAM = nullptr; + return *this; + } + /// \brief Accessor for the analysis manager. AnalysisManagerT &getManager() { return *InnerAM; } @@ -988,6 +1006,7 @@ public: private: friend AnalysisInfoMixin< InnerAnalysisManagerProxy>; + static AnalysisKey Key; AnalysisManagerT *InnerAM; @@ -998,8 +1017,8 @@ AnalysisKey InnerAnalysisManagerProxy::Key; /// Provide the \c FunctionAnalysisManager to \c Module proxy. -typedef InnerAnalysisManagerProxy - FunctionAnalysisManagerModuleProxy; +using FunctionAnalysisManagerModuleProxy = + InnerAnalysisManagerProxy; /// Specialization of the invalidate method for the \c /// FunctionAnalysisManagerModuleProxy's result. @@ -1097,6 +1116,7 @@ public: private: friend AnalysisInfoMixin< OuterAnalysisManagerProxy>; + static AnalysisKey Key; const AnalysisManagerT *AM; @@ -1109,8 +1129,8 @@ AnalysisKey extern template class OuterAnalysisManagerProxy; /// Provide the \c ModuleAnalysisManager to \c Function proxy. -typedef OuterAnalysisManagerProxy - ModuleAnalysisManagerFunctionProxy; +using ModuleAnalysisManagerFunctionProxy = + OuterAnalysisManagerProxy; /// \brief Trivial adaptor that maps from a module to its functions. /// @@ -1274,6 +1294,6 @@ RepeatedPass createRepeatedPass(int Count, PassT P) { return RepeatedPass(Count, std::move(P)); } -} +} // end namespace llvm -#endif +#endif // LLVM_IR_PASSMANAGER_H diff --git a/llvm/include/llvm/IR/PassManagerInternal.h b/llvm/include/llvm/IR/PassManagerInternal.h index 387dc4c..9195d4d 100644 --- a/llvm/include/llvm/IR/PassManagerInternal.h +++ b/llvm/include/llvm/IR/PassManagerInternal.h @@ -27,7 +27,6 @@ namespace llvm { template class AllAnalysesOn; template class AnalysisManager; -class Invalidator; class PreservedAnalyses; /// \brief Implementation details of the pass manager interfaces. @@ -116,7 +115,7 @@ struct AnalysisResultConcept { /// \brief SFINAE metafunction for computing whether \c ResultT provides an /// \c invalidate member function. template class ResultHasInvalidateMethod { - typedef char EnabledType; + using EnabledType = char; struct DisabledType { char a, b; }; @@ -124,7 +123,7 @@ template class ResultHasInvalidateMethod { // Purely to help out MSVC which fails to disable the below specialization, // explicitly enable using the result type's invalidate routine if we can // successfully call that routine. - template struct Nonce { typedef EnabledType Type; }; + template struct Nonce { using Type = EnabledType; }; template static typename Nonce().invalidate( std::declval(), std::declval()))>::Type @@ -280,9 +279,9 @@ struct AnalysisPassModel : AnalysisPassConcept - ResultModelT; + using ResultModelT = + AnalysisResultModel; /// \brief The model delegates to the \c PassT::run method. /// diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h index 31a76b4..6b2b22e 100644 --- a/llvm/include/llvm/IR/PatternMatch.h +++ b/llvm/include/llvm/IR/PatternMatch.h @@ -29,11 +29,19 @@ #ifndef LLVM_IR_PATTERNMATCH_H #define LLVM_IR_PATTERNMATCH_H +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" #include "llvm/IR/CallSite.h" +#include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/InstrTypes.h" +#include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/Operator.h" +#include "llvm/IR/Value.h" +#include "llvm/Support/Casting.h" +#include namespace llvm { namespace PatternMatch { @@ -172,7 +180,9 @@ inline match_nan m_NaN() { return match_nan(); } struct apint_match { const APInt *&Res; + apint_match(const APInt *&R) : Res(R) {} + template bool match(ITy *V) { if (auto *CI = dyn_cast(V)) { Res = &CI->getValue(); @@ -230,7 +240,9 @@ template struct cst_pred_ty : public Predicate { /// satisfy a specified predicate, and bind them to an APInt. template struct api_pred_ty : public Predicate { const APInt *&Res; + api_pred_ty(const APInt *&R) : Res(R) {} + template bool match(ITy *V) { if (const auto *CI = dyn_cast(V)) if (this->isValue(CI->getValue())) { @@ -294,6 +306,7 @@ inline api_pred_ty m_MaxSignedValue(const APInt *&V) { return template struct bind_ty { Class *&VR; + bind_ty(Class *&V) : VR(V) {} template bool match(ITy *V) { @@ -326,6 +339,7 @@ inline bind_ty m_ConstantFP(ConstantFP *&C) { return C; } /// \brief Match a specified Value*. struct specificval_ty { const Value *Val; + specificval_ty(const Value *V) : Val(V) {} template bool match(ITy *V) { return V == Val; } @@ -338,6 +352,7 @@ inline specificval_ty m_Specific(const Value *V) { return V; } /// that value. struct specific_fpval { double Val; + specific_fpval(double V) : Val(V) {} template bool match(ITy *V) { @@ -360,6 +375,7 @@ inline specific_fpval m_FPOne() { return m_SpecificFP(1.0); } struct bind_const_intval_ty { uint64_t &VR; + bind_const_intval_ty(uint64_t &V) : VR(V) {} template bool match(ITy *V) { @@ -376,6 +392,7 @@ struct bind_const_intval_ty { // value. struct specific_intval { uint64_t Val; + specific_intval(uint64_t V) : Val(V) {} template bool match(ITy *V) { @@ -939,6 +956,7 @@ template inline fneg_match m_FNeg(const LHS &L) { struct br_match { BasicBlock *&Succ; + br_match(BasicBlock *&Succ) : Succ(Succ) {} template bool match(OpTy *V) { @@ -956,6 +974,7 @@ inline br_match m_UnconditionalBr(BasicBlock *&Succ) { return br_match(Succ); } template struct brc_match { Cond_t Cond; BasicBlock *&T, *&F; + brc_match(const Cond_t &C, BasicBlock *&t, BasicBlock *&f) : Cond(C), T(t), F(f) {} @@ -1202,6 +1221,7 @@ m_UnordFMin(const LHS &L, const RHS &R) { template struct Argument_match { unsigned OpI; Opnd_t Val; + Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {} template bool match(OpTy *V) { @@ -1219,6 +1239,7 @@ inline Argument_match m_Argument(const Opnd_t &Op) { /// \brief Intrinsic matchers. struct IntrinsicID_match { unsigned ID; + IntrinsicID_match(Intrinsic::ID IntrID) : ID(IntrID) {} template bool match(OpTy *V) { @@ -1239,21 +1260,23 @@ template struct m_Intrinsic_Ty; template struct m_Intrinsic_Ty { - typedef match_combine_and> Ty; + using Ty = match_combine_and>; }; template struct m_Intrinsic_Ty { - typedef match_combine_and::Ty, Argument_match> - Ty; + using Ty = + match_combine_and::Ty, Argument_match>; }; template struct m_Intrinsic_Ty { - typedef match_combine_and::Ty, - Argument_match> Ty; + using Ty = + match_combine_and::Ty, + Argument_match>; }; template struct m_Intrinsic_Ty { - typedef match_combine_and::Ty, - Argument_match> Ty; + using Ty = + match_combine_and::Ty, + Argument_match>; }; /// \brief Match intrinsic calls like this: @@ -1437,4 +1460,4 @@ m_c_UMax(const LHS &L, const RHS &R) { } // end namespace PatternMatch } // end namespace llvm -#endif +#endif // LLVM_IR_PATTERNMATCH_H diff --git a/llvm/include/llvm/IR/ProfileSummary.h b/llvm/include/llvm/IR/ProfileSummary.h index f424801..d85ce8c 100644 --- a/llvm/include/llvm/IR/ProfileSummary.h +++ b/llvm/include/llvm/IR/ProfileSummary.h @@ -1,4 +1,4 @@ -//===-- ProfileSummary.h - Profile summary data structure. ------*- C++ -*-===// +//===- ProfileSummary.h - Profile summary data structure. -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,21 +11,17 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_PROFILE_SUMMARY_H -#define LLVM_SUPPORT_PROFILE_SUMMARY_H +#ifndef LLVM_IR_PROFILESUMMARY_H +#define LLVM_IR_PROFILESUMMARY_H +#include #include -#include #include -#include "llvm/Support/Casting.h" - namespace llvm { class LLVMContext; class Metadata; -class MDTuple; -class MDNode; // The profile summary is one or more (Cutoff, MinCount, NumCounts) triplets. // The semantics of counts depend on the type of profile. For instrumentation @@ -37,12 +33,13 @@ struct ProfileSummaryEntry { uint32_t Cutoff; ///< The required percentile of counts. uint64_t MinCount; ///< The minimum count for this percentile. uint64_t NumCounts; ///< Number of counts >= the minimum count. + ProfileSummaryEntry(uint32_t TheCutoff, uint64_t TheMinCount, uint64_t TheNumCounts) : Cutoff(TheCutoff), MinCount(TheMinCount), NumCounts(TheNumCounts) {} }; -typedef std::vector SummaryEntryVector; +using SummaryEntryVector = std::vector; class ProfileSummary { public: @@ -59,6 +56,7 @@ private: public: static const int Scale = 1000000; + ProfileSummary(Kind K, SummaryEntryVector DetailedSummary, uint64_t TotalCount, uint64_t MaxCount, uint64_t MaxInternalCount, uint64_t MaxFunctionCount, @@ -67,6 +65,7 @@ public: TotalCount(TotalCount), MaxCount(MaxCount), MaxInternalCount(MaxInternalCount), MaxFunctionCount(MaxFunctionCount), NumCounts(NumCounts), NumFunctions(NumFunctions) {} + Kind getKind() const { return PSK; } /// \brief Return summary information as metadata. Metadata *getMD(LLVMContext &Context); @@ -82,4 +81,5 @@ public: }; } // end namespace llvm -#endif + +#endif // LLVM_IR_PROFILESUMMARY_H diff --git a/llvm/include/llvm/IR/Statepoint.h b/llvm/include/llvm/IR/Statepoint.h index 03151cd..f016076 100644 --- a/llvm/include/llvm/IR/Statepoint.h +++ b/llvm/include/llvm/IR/Statepoint.h @@ -1,4 +1,4 @@ -//===-- llvm/IR/Statepoint.h - gc.statepoint utilities ----------*- C++ -*-===// +//===- llvm/IR/Statepoint.h - gc.statepoint utilities -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -24,10 +24,12 @@ #include "llvm/IR/CallSite.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Function.h" +#include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Intrinsics.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/MathExtras.h" #include #include #include @@ -87,7 +89,7 @@ protected: } public: - typedef typename CallSiteTy::arg_iterator arg_iterator; + using arg_iterator = typename CallSiteTy::arg_iterator; enum { IDPos = 0, @@ -300,8 +302,9 @@ public: class ImmutableStatepoint : public StatepointBase { - typedef StatepointBase Base; + using Base = + StatepointBase; public: explicit ImmutableStatepoint(const Instruction *I) : Base(I) {} @@ -312,7 +315,7 @@ public: /// to a gc.statepoint. class Statepoint : public StatepointBase { - typedef StatepointBase Base; + using Base = StatepointBase; public: explicit Statepoint(Instruction *I) : Base(I) {} @@ -327,6 +330,7 @@ public: return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate || I->getIntrinsicID() == Intrinsic::experimental_gc_result; } + static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } @@ -369,6 +373,7 @@ public: static inline bool classof(const IntrinsicInst *I) { return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate; } + static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } @@ -403,6 +408,7 @@ public: static inline bool classof(const IntrinsicInst *I) { return I->getIntrinsicID() == Intrinsic::experimental_gc_result; } + static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } diff --git a/llvm/include/llvm/IR/SymbolTableListTraits.h b/llvm/include/llvm/IR/SymbolTableListTraits.h index 49a5fb2..87ce902 100644 --- a/llvm/include/llvm/IR/SymbolTableListTraits.h +++ b/llvm/include/llvm/IR/SymbolTableListTraits.h @@ -48,7 +48,7 @@ class ValueSymbolTable; template struct SymbolTableListParentType {}; #define DEFINE_SYMBOL_TABLE_PARENT_TYPE(NODE, PARENT) \ - template <> struct SymbolTableListParentType { typedef PARENT type; }; + template <> struct SymbolTableListParentType { using type = PARENT; }; DEFINE_SYMBOL_TABLE_PARENT_TYPE(Instruction, BasicBlock) DEFINE_SYMBOL_TABLE_PARENT_TYPE(BasicBlock, Function) DEFINE_SYMBOL_TABLE_PARENT_TYPE(Argument, Function) @@ -65,10 +65,10 @@ template class SymbolTableList; // template class SymbolTableListTraits : public ilist_alloc_traits { - typedef SymbolTableList ListTy; - typedef typename simple_ilist::iterator iterator; - typedef - typename SymbolTableListParentType::type ItemParentClass; + using ListTy = SymbolTableList; + using iterator = typename simple_ilist::iterator; + using ItemParentClass = + typename SymbolTableListParentType::type; public: SymbolTableListTraits() = default; diff --git a/llvm/include/llvm/IR/TrackingMDRef.h b/llvm/include/llvm/IR/TrackingMDRef.h index 12b1964..bdec904 100644 --- a/llvm/include/llvm/IR/TrackingMDRef.h +++ b/llvm/include/llvm/IR/TrackingMDRef.h @@ -139,31 +139,35 @@ public: bool hasTrivialDestructor() const { return Ref.hasTrivialDestructor(); } }; -typedef TypedTrackingMDRef TrackingMDNodeRef; -typedef TypedTrackingMDRef TrackingValueAsMetadataRef; +using TrackingMDNodeRef = TypedTrackingMDRef; +using TrackingValueAsMetadataRef = TypedTrackingMDRef; // Expose the underlying metadata to casting. template <> struct simplify_type { - typedef Metadata *SimpleType; + using SimpleType = Metadata *; + static SimpleType getSimplifiedValue(TrackingMDRef &MD) { return MD.get(); } }; template <> struct simplify_type { - typedef Metadata *SimpleType; + using SimpleType = Metadata *; + static SimpleType getSimplifiedValue(const TrackingMDRef &MD) { return MD.get(); } }; template struct simplify_type> { - typedef T *SimpleType; + using SimpleType = T *; + static SimpleType getSimplifiedValue(TypedTrackingMDRef &MD) { return MD.get(); } }; template struct simplify_type> { - typedef T *SimpleType; + using SimpleType = T *; + static SimpleType getSimplifiedValue(const TypedTrackingMDRef &MD) { return MD.get(); } diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h index e6a0df9..8236210 100644 --- a/llvm/include/llvm/IR/Type.h +++ b/llvm/include/llvm/IR/Type.h @@ -1,4 +1,4 @@ -//===-- llvm/Type.h - Classes for handling data types -----------*- C++ -*-===// +//===- llvm/Type.h - Classes for handling data types ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -18,21 +18,22 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallPtrSet.h" -#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/Support/CBindingWrapping.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include +#include +#include namespace llvm { -class PointerType; +template struct GraphTraits; class IntegerType; -class raw_ostream; -class Module; class LLVMContext; -class LLVMContextImpl; +class PointerType; +class raw_ostream; class StringRef; -template struct GraphTraits; /// The instances of the Type class are immutable: once they are created, /// they are never changed. Also note that only one instance of a particular @@ -86,9 +87,9 @@ private: protected: friend class LLVMContextImpl; + explicit Type(LLVMContext &C, TypeID tid) - : Context(C), ID(tid), SubclassData(0), - NumContainedTys(0), ContainedTys(nullptr) {} + : Context(C), ID(tid), SubclassData(0) {} ~Type() = default; unsigned getSubclassData() const { return SubclassData; } @@ -100,14 +101,14 @@ protected: } /// Keeps track of how many Type*'s there are in the ContainedTys list. - unsigned NumContainedTys; + unsigned NumContainedTys = 0; /// A pointer to the array of Types contained by this Type. For example, this /// includes the arguments of a function type, the elements of a structure, /// the pointee of a pointer, the element type of an array, etc. This pointer /// may be 0 for types that don't contain other types (Integer, Double, /// Float). - Type * const *ContainedTys; + Type * const *ContainedTys = nullptr; static bool isSequentialType(TypeID TyID) { return TyID == ArrayTyID || TyID == VectorTyID; @@ -122,6 +123,7 @@ public: /// inlined with the operands when printing an instruction. void print(raw_ostream &O, bool IsForDebug = false, bool NoDetails = false) const; + void dump() const; /// Return the LLVMContext in which this type was uniqued. @@ -299,14 +301,16 @@ public: //===--------------------------------------------------------------------===// // Type Iteration support. // - typedef Type * const *subtype_iterator; + using subtype_iterator = Type * const *; + subtype_iterator subtype_begin() const { return ContainedTys; } subtype_iterator subtype_end() const { return &ContainedTys[NumContainedTys];} ArrayRef subtypes() const { return makeArrayRef(subtype_begin(), subtype_end()); } - typedef std::reverse_iterator subtype_reverse_iterator; + using subtype_reverse_iterator = std::reverse_iterator; + subtype_reverse_iterator subtype_rbegin() const { return subtype_reverse_iterator(subtype_end()); } @@ -348,6 +352,7 @@ public: } inline uint64_t getArrayNumElements() const; + Type *getArrayElementType() const { assert(getTypeID() == ArrayTyID); return ContainedTys[0]; @@ -444,8 +449,8 @@ template <> struct isa_impl { // graph of sub types. template <> struct GraphTraits { - typedef Type *NodeRef; - typedef Type::subtype_iterator ChildIteratorType; + using NodeRef = Type *; + using ChildIteratorType = Type::subtype_iterator; static NodeRef getEntryNode(Type *T) { return T; } static ChildIteratorType child_begin(NodeRef N) { return N->subtype_begin(); } @@ -453,8 +458,8 @@ template <> struct GraphTraits { }; template <> struct GraphTraits { - typedef const Type *NodeRef; - typedef Type::subtype_iterator ChildIteratorType; + using NodeRef = const Type *; + using ChildIteratorType = Type::subtype_iterator; static NodeRef getEntryNode(NodeRef T) { return T; } static ChildIteratorType child_begin(NodeRef N) { return N->subtype_begin(); } @@ -474,6 +479,6 @@ inline LLVMTypeRef *wrap(Type **Tys) { return reinterpret_cast(const_cast(Tys)); } -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_TYPE_H diff --git a/llvm/include/llvm/IR/TypeFinder.h b/llvm/include/llvm/IR/TypeFinder.h index 48c4f11..c050c38 100644 --- a/llvm/include/llvm/IR/TypeFinder.h +++ b/llvm/include/llvm/IR/TypeFinder.h @@ -44,8 +44,8 @@ public: void run(const Module &M, bool onlyNamed); void clear(); - typedef std::vector::iterator iterator; - typedef std::vector::const_iterator const_iterator; + using iterator = std::vector::iterator; + using const_iterator = std::vector::const_iterator; iterator begin() { return StructTypes.begin(); } iterator end() { return StructTypes.end(); } diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h index 00f8213..96a370d 100644 --- a/llvm/include/llvm/IR/Value.h +++ b/llvm/include/llvm/IR/Value.h @@ -1,4 +1,4 @@ -//===-- llvm/Value.h - Definition of the Value class ------------*- C++ -*-===// +//===- llvm/Value.h - Definition of the Value class -------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -44,12 +44,12 @@ class LLVMContext; class Module; class ModuleSlotTracker; class raw_ostream; +template class StringMapEntry; class StringRef; class Twine; class Type; -template class StringMapEntry; -typedef StringMapEntry ValueName; +using ValueName = StringMapEntry; //===----------------------------------------------------------------------===// // Value Class @@ -120,9 +120,11 @@ private: template // UseT == 'Use' or 'const Use' class use_iterator_impl : public std::iterator { + friend class Value; + UseT *U; + explicit use_iterator_impl(UseT *u) : U(u) {} - friend class Value; public: use_iterator_impl() : U() {} @@ -309,8 +311,9 @@ public: return UseList == nullptr; } - typedef use_iterator_impl use_iterator; - typedef use_iterator_impl const_use_iterator; + using use_iterator = use_iterator_impl; + using const_use_iterator = use_iterator_impl; + use_iterator materialized_use_begin() { return use_iterator(UseList); } const_use_iterator materialized_use_begin() const { return const_use_iterator(UseList); @@ -345,8 +348,9 @@ public: return UseList == nullptr; } - typedef user_iterator_impl user_iterator; - typedef user_iterator_impl const_user_iterator; + using user_iterator = user_iterator_impl; + using const_user_iterator = user_iterator_impl; + user_iterator materialized_user_begin() { return user_iterator(UseList); } const_user_iterator materialized_user_begin() const { return const_user_iterator(UseList); @@ -560,7 +564,6 @@ public: /// block. const Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) const; - Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) { return const_cast( static_cast(this)->DoPHITranslation(CurBB, PredBB)); @@ -606,7 +609,7 @@ private: Use *Merged; Use **Next = &Merged; - for (;;) { + while (true) { if (!L) { *Next = R; break; diff --git a/llvm/include/llvm/IR/Verifier.h b/llvm/include/llvm/IR/Verifier.h index 71f727c..15e52d9 100644 --- a/llvm/include/llvm/IR/Verifier.h +++ b/llvm/include/llvm/IR/Verifier.h @@ -21,13 +21,17 @@ #ifndef LLVM_IR_VERIFIER_H #define LLVM_IR_VERIFIER_H +#include "llvm/ADT/DenseMap.h" #include "llvm/IR/PassManager.h" +#include namespace llvm { +class APInt; class Function; class FunctionPass; -class ModulePass; +class Instruction; +class MDNode; class Module; class raw_ostream; struct VerifierSupport; @@ -47,7 +51,7 @@ class TBAAVerifier { /// the offset of the access. If zero, only a zero offset is allowed. /// /// \c BitWidth has no meaning if \c IsInvalid is true. - typedef std::pair TBAABaseNodeSummary; + using TBAABaseNodeSummary = std::pair; DenseMap TBAABaseNodes; /// Maps an alleged scalar TBAA node to a boolean that is true if the said @@ -101,12 +105,14 @@ FunctionPass *createVerifierPass(bool FatalErrors = true); /// and debug info errors. class VerifierAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; + static AnalysisKey Key; public: struct Result { bool IRBroken, DebugInfoBroken; }; + Result run(Module &M, ModuleAnalysisManager &); Result run(Function &F, FunctionAnalysisManager &); }; @@ -136,7 +142,6 @@ public: PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; +} // end namespace llvm -} // End llvm namespace - -#endif +#endif // LLVM_IR_VERIFIER_H diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index 492898a..c9f957c 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -1,4 +1,4 @@ -//===-- Type.cpp - Implement the Type class -------------------------------===// +//===- Type.cpp - Implement the Type class --------------------------------===// // // The LLVM Compiler Infrastructure // @@ -11,11 +11,25 @@ // //===----------------------------------------------------------------------===// -#include "llvm/IR/Type.h" #include "LLVMContextImpl.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/IR/Constant.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" -#include +#include "llvm/IR/Type.h" +#include "llvm/IR/Value.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/Support/raw_ostream.h" +#include +#include + using namespace llvm; //===----------------------------------------------------------------------===// @@ -219,7 +233,6 @@ PointerType *Type::getInt64PtrTy(LLVMContext &C, unsigned AS) { return getInt64Ty(C)->getPointerTo(AS); } - //===----------------------------------------------------------------------===// // IntegerType Implementation //===----------------------------------------------------------------------===// @@ -361,7 +374,8 @@ void StructType::setName(StringRef Name) { if (Name == getName()) return; StringMap &SymbolTable = getContext().pImpl->NamedStructTypes; - typedef StringMap::MapEntryTy EntryTy; + + using EntryTy = StringMap::MapEntryTy; // If this struct already had a name, remove its symbol table entry. Don't // delete the data yet because it may be part of the new name. @@ -496,7 +510,6 @@ StructType *Module::getTypeByName(StringRef Name) const { return getContext().pImpl->NamedStructTypes.lookup(Name); } - //===----------------------------------------------------------------------===// // CompositeType Implementation //===----------------------------------------------------------------------===// @@ -545,7 +558,6 @@ bool CompositeType::indexValid(unsigned Idx) const { return true; } - //===----------------------------------------------------------------------===// // ArrayType Implementation //===----------------------------------------------------------------------===// @@ -617,7 +629,6 @@ PointerType *PointerType::get(Type *EltTy, unsigned AddressSpace) { return Entry; } - PointerType::PointerType(Type *E, unsigned AddrSpace) : Type(E->getContext(), PointerTyID), PointeeTy(E) { ContainedTys = &PointeeTy;