From: Eugene Zelenko Date: Sat, 14 Jan 2017 00:32:38 +0000 (+0000) Subject: [Transforms/Utils] Fix some Clang-tidy modernize and Include What You Use warnings... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=034cc87d1e6538b7104165acdc09e493248a0bca;p=llvm [Transforms/Utils] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291983 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Transforms/Utils/BasicBlockUtils.h b/include/llvm/Transforms/Utils/BasicBlockUtils.h index 3d41dbe2b95..85bb053135a 100644 --- a/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -78,14 +78,13 @@ void ReplaceInstWithInst(Instruction *From, Instruction *To); struct CriticalEdgeSplittingOptions { DominatorTree *DT; LoopInfo *LI; - bool MergeIdenticalEdges; - bool DontDeleteUselessPHIs; - bool PreserveLCSSA; + bool MergeIdenticalEdges = false; + bool DontDeleteUselessPHIs = false; + bool PreserveLCSSA = false; CriticalEdgeSplittingOptions(DominatorTree *DT = nullptr, LoopInfo *LI = nullptr) - : DT(DT), LI(LI), MergeIdenticalEdges(false), - DontDeleteUselessPHIs(false), PreserveLCSSA(false) {} + : DT(DT), LI(LI) {} CriticalEdgeSplittingOptions &setMergeIdenticalEdges() { MergeIdenticalEdges = true; diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h index 5eeb8cf3069..6bd3aedd593 100644 --- a/include/llvm/Transforms/Utils/Cloning.h +++ b/include/llvm/Transforms/Utils/Cloning.h @@ -22,32 +22,27 @@ #include "llvm/ADT/Twine.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AssumptionCache.h" +#include "llvm/IR/CallSite.h" #include "llvm/IR/ValueHandle.h" -#include "llvm/IR/ValueMap.h" #include "llvm/Transforms/Utils/ValueMapper.h" #include +#include +#include namespace llvm { -class Module; -class Function; -class Instruction; -class Pass; -class LPPassManager; +class AllocaInst; class BasicBlock; -class Value; class CallInst; -class InvokeInst; -class ReturnInst; -class CallSite; -class Trace; class CallGraph; -class DataLayout; +class DominatorTree; +class Function; +class Instruction; +class InvokeInst; class Loop; class LoopInfo; -class AllocaInst; -class AssumptionCacheTracker; -class DominatorTree; +class Module; +class ReturnInst; /// Return an exact copy of the specified module /// @@ -67,20 +62,20 @@ CloneModule(const Module *M, ValueToValueMapTy &VMap, struct ClonedCodeInfo { /// ContainsCalls - This is set to true if the cloned code contains a normal /// call instruction. - bool ContainsCalls; + bool ContainsCalls = false; /// ContainsDynamicAllocas - This is set to true if the cloned code contains /// a 'dynamic' alloca. Dynamic allocas are allocas that are either not in /// the entry block or they are in the entry block but are not a constant /// size. - bool ContainsDynamicAllocas; + bool ContainsDynamicAllocas = false; /// All cloned call sites that have operand bundles attached are appended to /// this vector. This vector may contain nulls or undefs if some of the /// originally inserted callsites were DCE'ed after they were cloned. std::vector OperandBundleCallSites; - ClonedCodeInfo() : ContainsCalls(false), ContainsDynamicAllocas(false) {} + ClonedCodeInfo() = default; }; /// CloneBasicBlock - Return a copy of the specified basic block, but without @@ -245,6 +240,6 @@ Loop *cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, void remapInstructionsInBlocks(const SmallVectorImpl &Blocks, ValueToValueMapTy &VMap); -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_TRANSFORMS_UTILS_CLONING_H diff --git a/include/llvm/Transforms/Utils/GlobalStatus.h b/include/llvm/Transforms/Utils/GlobalStatus.h index c3660950880..dcb5d95917c 100644 --- a/include/llvm/Transforms/Utils/GlobalStatus.h +++ b/include/llvm/Transforms/Utils/GlobalStatus.h @@ -10,9 +10,10 @@ #ifndef LLVM_TRANSFORMS_UTILS_GLOBALSTATUS_H #define LLVM_TRANSFORMS_UTILS_GLOBALSTATUS_H -#include "llvm/IR/Instructions.h" +#include "llvm/Support/AtomicOrdering.h" namespace llvm { + class Value; class Function; @@ -27,11 +28,11 @@ bool isSafeToDestroyConstant(const Constant *C); /// accurate. struct GlobalStatus { /// True if the global's address is used in a comparison. - bool IsCompared; + bool IsCompared = false; /// True if the global is ever loaded. If the global isn't ever loaded it /// can be deleted. - bool IsLoaded; + bool IsLoaded = false; /// Keep track of what stores to the global look like. enum StoredType { @@ -51,32 +52,33 @@ struct GlobalStatus { /// This global is stored to by multiple values or something else that we /// cannot track. Stored - } StoredType; + } StoredType = NotStored; /// If only one value (besides the initializer constant) is ever stored to /// this global, keep track of what value it is. - Value *StoredOnceValue; + Value *StoredOnceValue = nullptr; /// These start out null/false. When the first accessing function is noticed, /// it is recorded. When a second different accessing function is noticed, /// HasMultipleAccessingFunctions is set to true. - const Function *AccessingFunction; - bool HasMultipleAccessingFunctions; + const Function *AccessingFunction = nullptr; + bool HasMultipleAccessingFunctions = false; /// Set to true if this global has a user that is not an instruction (e.g. a /// constant expr or GV initializer). - bool HasNonInstructionUser; + bool HasNonInstructionUser = false; /// Set to the strongest atomic ordering requirement. - AtomicOrdering Ordering; + AtomicOrdering Ordering = AtomicOrdering::NotAtomic; + + GlobalStatus(); /// Look at all uses of the global and fill in the GlobalStatus structure. If /// the global has its address taken, return true to indicate we can't do /// anything with it. static bool analyzeGlobal(const Value *V, GlobalStatus &GS); - - GlobalStatus(); }; -} -#endif +} // end namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_GLOBALSTATUS_H diff --git a/include/llvm/Transforms/Utils/LoopUtils.h b/include/llvm/Transforms/Utils/LoopUtils.h index 27b45c4fa94..a1cf41d6f93 100644 --- a/include/llvm/Transforms/Utils/LoopUtils.h +++ b/include/llvm/Transforms/Utils/LoopUtils.h @@ -1,4 +1,4 @@ -//===- llvm/Transforms/Utils/LoopUtils.h - Loop utilities -*- C++ -*-=========// +//===- llvm/Transforms/Utils/LoopUtils.h - Loop utilities -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,23 +14,29 @@ #ifndef LLVM_TRANSFORMS_UTILS_LOOPUTILS_H #define LLVM_TRANSFORMS_UTILS_LOOPUTILS_H +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/EHPersonalities.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/IRBuilder.h" +#include "llvm/IR/InstrTypes.h" +#include "llvm/IR/Operator.h" +#include "llvm/IR/ValueHandle.h" +#include "llvm/Support/Casting.h" namespace llvm { + class AliasSet; class AliasSetTracker; -class AssumptionCache; class BasicBlock; class DataLayout; -class DominatorTree; class Loop; class LoopInfo; class OptimizationRemarkEmitter; -class Pass; class PredicatedScalarEvolution; class PredIteratorCache; class ScalarEvolution; @@ -40,12 +46,13 @@ class TargetLibraryInfo; /// \brief Captures loop safety information. /// It keep information for loop & its header may throw exception. struct LoopSafetyInfo { - bool MayThrow; // The current loop contains an instruction which - // may throw. - bool HeaderMayThrow; // Same as previous, but specific to loop header + bool MayThrow = false; // The current loop contains an instruction which + // may throw. + bool HeaderMayThrow = false; // Same as previous, but specific to loop header // Used to update funclet bundle operands. DenseMap BlockColors; - LoopSafetyInfo() : MayThrow(false), HeaderMayThrow(false) {} + + LoopSafetyInfo() = default; }; /// The RecurrenceDescriptor is used to identify recurrences variables in a @@ -61,7 +68,6 @@ struct LoopSafetyInfo { /// This struct holds information about recurrence variables. class RecurrenceDescriptor { - public: /// This enum represents the kinds of recurrences that we support. enum RecurrenceKind { @@ -88,10 +94,7 @@ public: MRK_FloatMax }; - RecurrenceDescriptor() - : StartValue(nullptr), LoopExitInstr(nullptr), Kind(RK_NoRecurrence), - MinMaxKind(MRK_Invalid), UnsafeAlgebraInst(nullptr), - RecurrenceType(nullptr), IsSigned(false) {} + RecurrenceDescriptor() = default; RecurrenceDescriptor(Value *Start, Instruction *Exit, RecurrenceKind K, MinMaxRecurrenceKind MK, Instruction *UAI, Type *RT, @@ -103,7 +106,6 @@ public: /// This POD struct holds information about a potential recurrence operation. class InstDesc { - public: InstDesc(bool IsRecur, Instruction *I, Instruction *UAI = nullptr) : IsRecurrence(IsRecur), PatternLastInst(I), MinMaxKind(MRK_Invalid), @@ -242,17 +244,17 @@ private: // It does not have to be zero! TrackingVH StartValue; // The instruction who's value is used outside the loop. - Instruction *LoopExitInstr; + Instruction *LoopExitInstr = nullptr; // The kind of the recurrence. - RecurrenceKind Kind; + RecurrenceKind Kind = RK_NoRecurrence; // If this a min/max recurrence the kind of recurrence. - MinMaxRecurrenceKind MinMaxKind; + MinMaxRecurrenceKind MinMaxKind = MRK_Invalid; // First occurrence of unasfe algebra in the PHI's use-chain. - Instruction *UnsafeAlgebraInst; + Instruction *UnsafeAlgebraInst = nullptr; // The type of the recurrence. - Type *RecurrenceType; + Type *RecurrenceType = nullptr; // True if all source operands of the recurrence are SExtInsts. - bool IsSigned; + bool IsSigned = false; // Instructions used for type-promoting the recurrence. SmallPtrSet CastInsts; }; @@ -270,9 +272,7 @@ public: public: /// Default constructor - creates an invalid induction. - InductionDescriptor() - : StartValue(nullptr), IK(IK_NoInduction), Step(nullptr), - InductionBinOp(nullptr) {} + InductionDescriptor() = default; /// Get the consecutive direction. Returns: /// 0 - unknown or non-consecutive. @@ -350,11 +350,11 @@ private: /// Start value. TrackingVH StartValue; /// Induction kind. - InductionKind IK; + InductionKind IK = IK_NoInduction; /// Step value. - const SCEV *Step; + const SCEV *Step = nullptr; // Instruction that advances induction variable. - BinaryOperator *InductionBinOp; + BinaryOperator *InductionBinOp = nullptr; }; BasicBlock *InsertPreheaderForLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, @@ -488,6 +488,7 @@ bool canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, Loop *CurLoop, AliasSetTracker *CurAST, LoopSafetyInfo *SafetyInfo, OptimizationRemarkEmitter *ORE = nullptr); -} -#endif +} // end namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_LOOPUTILS_H diff --git a/include/llvm/Transforms/Utils/MemorySSA.h b/include/llvm/Transforms/Utils/MemorySSA.h index 408c6a157cd..10fdf55e54c 100644 --- a/include/llvm/Transforms/Utils/MemorySSA.h +++ b/include/llvm/Transforms/Utils/MemorySSA.h @@ -74,6 +74,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/ilist.h" @@ -91,9 +92,7 @@ #include "llvm/IR/User.h" #include "llvm/IR/Value.h" #include "llvm/Pass.h" -#include "llvm/PassAnalysisSupport.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include #include @@ -104,12 +103,12 @@ namespace llvm { -class DominatorTree; class Function; class Instruction; class MemoryAccess; class LLVMContext; class raw_ostream; + enum { // Used to signify what the default invalid ID is for MemoryAccess's // getID() @@ -124,9 +123,6 @@ using const_memoryaccess_def_iterator = // \brief The base for all memory accesses. All memory accesses in a block are // linked together using an intrusive list. class MemoryAccess : public User, public ilist_node { - void *operator new(size_t, unsigned) = delete; - void *operator new(size_t) = delete; - public: // Methods for support type inquiry through isa, cast, and // dyn_cast @@ -136,8 +132,13 @@ public: return ID == MemoryUseVal || ID == MemoryPhiVal || ID == MemoryDefVal; } + MemoryAccess(const MemoryAccess &) = delete; + MemoryAccess &operator=(const MemoryAccess &) = delete; ~MemoryAccess() override; + void *operator new(size_t, unsigned) = delete; + void *operator new(size_t) = delete; + BasicBlock *getBlock() const { return Block; } virtual void print(raw_ostream &OS) const = 0; @@ -171,8 +172,6 @@ protected: : User(Type::getVoidTy(C), Vty, nullptr, NumOperands), Block(BB) {} private: - MemoryAccess(const MemoryAccess &); - void operator=(const MemoryAccess &); BasicBlock *Block; }; @@ -189,10 +188,10 @@ inline raw_ostream &operator<<(raw_ostream &OS, const MemoryAccess &MA) { /// This class should never be instantiated directly; make a MemoryUse or /// MemoryDef instead. class MemoryUseOrDef : public MemoryAccess { +public: void *operator new(size_t, unsigned) = delete; void *operator new(size_t) = delete; -public: DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess); /// \brief Get the instruction that this MemoryUse represents. @@ -232,31 +231,33 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(MemoryUseOrDef, MemoryAccess) /// MemoryUse's is exactly the set of Instructions for which /// AliasAnalysis::getModRefInfo returns "Ref". class MemoryUse final : public MemoryUseOrDef { - void *operator new(size_t, unsigned) = delete; - public: DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess); - // allocate space for exactly one operand - void *operator new(size_t s) { return User::operator new(s, 1); } - MemoryUse(LLVMContext &C, MemoryAccess *DMA, Instruction *MI, BasicBlock *BB) : MemoryUseOrDef(C, DMA, MemoryUseVal, MI, BB), OptimizedID(0) {} + // allocate space for exactly one operand + void *operator new(size_t s) { return User::operator new(s, 1); } + void *operator new(size_t, unsigned) = delete; + static inline bool classof(const MemoryUse *) { return true; } static inline bool classof(const Value *MA) { return MA->getValueID() == MemoryUseVal; } void print(raw_ostream &OS) const override; + void setDefiningAccess(MemoryAccess *DMA, bool Optimized = false) { if (Optimized) OptimizedID = DMA->getID(); MemoryUseOrDef::setDefiningAccess(DMA); } + bool isOptimized() const { return getDefiningAccess() && OptimizedID == getDefiningAccess()->getID(); } + /// \brief Reset the ID of what this MemoryUse was optimized to, causing it to /// be rewalked by the walker if necessary. /// This really should only be called by tests. @@ -287,18 +288,17 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(MemoryUse, MemoryAccess) /// associated with them. This use points to the nearest reaching /// MemoryDef/MemoryPhi. class MemoryDef final : public MemoryUseOrDef { - void *operator new(size_t, unsigned) = delete; - public: DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess); - // allocate space for exactly one operand - void *operator new(size_t s) { return User::operator new(s, 1); } - MemoryDef(LLVMContext &C, MemoryAccess *DMA, Instruction *MI, BasicBlock *BB, unsigned Ver) : MemoryUseOrDef(C, DMA, MemoryDefVal, MI, BB), ID(Ver) {} + // allocate space for exactly one operand + void *operator new(size_t s) { return User::operator new(s, 1); } + void *operator new(size_t, unsigned) = delete; + static inline bool classof(const MemoryDef *) { return true; } static inline bool classof(const Value *MA) { return MA->getValueID() == MemoryDefVal; @@ -352,7 +352,6 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(MemoryDef, MemoryAccess) /// Because MemoryUse's do not generate new definitions, they do not have this /// issue. class MemoryPhi final : public MemoryAccess { - void *operator new(size_t, unsigned) = delete; // allocate space for exactly zero operands void *operator new(size_t s) { return User::operator new(s); } @@ -365,6 +364,8 @@ public: allocHungoffUses(ReservedSpace); } + void *operator new(size_t, unsigned) = delete; + // Block iterator interface. This provides access to the list of incoming // basic blocks, which parallels the list of incoming values. typedef BasicBlock **block_iterator; @@ -466,6 +467,7 @@ public: protected: friend class MemorySSA; + /// \brief this is more complicated than the generic /// User::allocHungoffUses, because we have to allocate Uses for the incoming /// values and pointers to the incoming blocks, all in one allocation. @@ -561,6 +563,7 @@ public: MemoryAccess *createMemoryAccessInBB(Instruction *I, MemoryAccess *Definition, const BasicBlock *BB, InsertionPlace Point); + /// \brief Create a MemoryAccess in MemorySSA before or after an existing /// MemoryAccess. /// @@ -615,6 +618,7 @@ protected: // Used by Memory SSA annotater, dumpers, and wrapper pass friend class MemorySSAAnnotatedWriter; friend class MemorySSAPrinterLegacyPass; + void verifyDefUses(Function &F) const; void verifyDomination(Function &F) const; void verifyOrdering(Function &F) const; @@ -680,15 +684,17 @@ class MemorySSAPrinterLegacyPass : public FunctionPass { public: MemorySSAPrinterLegacyPass(); - static char ID; bool runOnFunction(Function &) override; void getAnalysisUsage(AnalysisUsage &AU) const override; + + static char ID; }; /// An analysis that produces \c MemorySSA for a function. /// class MemorySSAAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; + static AnalysisKey Key; public: @@ -711,6 +717,7 @@ class MemorySSAPrinterPass : public PassInfoMixin { public: explicit MemorySSAPrinterPass(raw_ostream &OS) : OS(OS) {} + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; @@ -725,6 +732,7 @@ public: MemorySSAWrapperPass(); static char ID; + bool runOnFunction(Function &) override; void releaseMemory() override; MemorySSA &getMSSA() { return *MSSA; } @@ -753,7 +761,7 @@ private: class MemorySSAWalker { public: MemorySSAWalker(MemorySSA *); - virtual ~MemorySSAWalker() {} + virtual ~MemorySSAWalker() = default; using MemoryAccessSet = SmallVector; @@ -825,6 +833,7 @@ public: // Keep the overrides below from hiding the Instruction overload of // getClobberingMemoryAccess. using MemorySSAWalker::getClobberingMemoryAccess; + MemoryAccess *getClobberingMemoryAccess(MemoryAccess *) override; MemoryAccess *getClobberingMemoryAccess(MemoryAccess *, const MemoryLocation &) override; @@ -843,8 +852,9 @@ class memoryaccess_def_iterator_base using BaseT = typename memoryaccess_def_iterator_base::iterator_facade_base; public: - memoryaccess_def_iterator_base(T *Start) : Access(Start), ArgNo(0) {} - memoryaccess_def_iterator_base() : Access(nullptr), ArgNo(0) {} + memoryaccess_def_iterator_base(T *Start) : Access(Start) {} + memoryaccess_def_iterator_base() = default; + bool operator==(const memoryaccess_def_iterator_base &Other) const { return Access == Other.Access && (!Access || ArgNo == Other.ArgNo); } @@ -883,8 +893,8 @@ public: } private: - T *Access; - unsigned ArgNo; + T *Access = nullptr; + unsigned ArgNo = 0; }; inline memoryaccess_def_iterator MemoryAccess::defs_begin() { @@ -947,8 +957,7 @@ public: fillInCurrentPair(); } - upward_defs_iterator() - : DefIterator(), Location(), OriginalAccess(), WalkingPhi(false) { + upward_defs_iterator() { CurrentPair.first = nullptr; } @@ -995,8 +1004,8 @@ private: MemoryAccessPair CurrentPair; memoryaccess_def_iterator DefIterator; MemoryLocation Location; - MemoryAccess *OriginalAccess; - bool WalkingPhi; + MemoryAccess *OriginalAccess = nullptr; + bool WalkingPhi = false; }; inline upward_defs_iterator upward_defs_begin(const MemoryAccessPair &Pair) { diff --git a/include/llvm/Transforms/Utils/NameAnonGlobals.h b/include/llvm/Transforms/Utils/NameAnonGlobals.h index 4bec361674b..17fc902eebf 100644 --- a/include/llvm/Transforms/Utils/NameAnonGlobals.h +++ b/include/llvm/Transforms/Utils/NameAnonGlobals.h @@ -1,4 +1,4 @@ -//===-- NameAnonGlobals.h - Anonymous Global Naming Pass ----*- C++ -*-=======// +//===-- NameAnonGlobals.h - Anonymous Global Naming Pass --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -23,9 +23,11 @@ namespace llvm { /// Simple pass that provides a name to every anonymous globals. class NameAnonGlobalPass : public PassInfoMixin { public: - NameAnonGlobalPass() {} + NameAnonGlobalPass() = default; + PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); }; -} + +} // end namespace llvm #endif // LLVM_TRANSFORMS_UTILS_NAMEANONGLOBALS_H diff --git a/include/llvm/Transforms/Utils/SSAUpdater.h b/include/llvm/Transforms/Utils/SSAUpdater.h index 9f98bac22dc..6ba9e4d2e68 100644 --- a/include/llvm/Transforms/Utils/SSAUpdater.h +++ b/include/llvm/Transforms/Utils/SSAUpdater.h @@ -15,19 +15,20 @@ #define LLVM_TRANSFORMS_UTILS_SSAUPDATER_H #include "llvm/ADT/StringRef.h" -#include "llvm/Support/Compiler.h" +#include namespace llvm { - class BasicBlock; - class Instruction; - class LoadInst; - template class ArrayRef; - template class SmallVectorImpl; - template class SSAUpdaterTraits; - class PHINode; - class Type; - class Use; - class Value; + +class BasicBlock; +class Instruction; +class LoadInst; +template class ArrayRef; +template class SmallVectorImpl; +template class SSAUpdaterTraits; +class PHINode; +class Type; +class Use; +class Value; /// \brief Helper class for SSA formation on a set of values defined in /// multiple blocks. @@ -58,6 +59,8 @@ public: /// If InsertedPHIs is specified, it will be filled /// in with all PHI Nodes created by rewriting. explicit SSAUpdater(SmallVectorImpl *InsertedPHIs = nullptr); + SSAUpdater(const SSAUpdater &) = delete; + SSAUpdater &operator=(const SSAUpdater &) = delete; ~SSAUpdater(); /// \brief Reset this object to get ready for a new set of SSA updates with @@ -118,9 +121,6 @@ public: private: Value *GetValueAtEndOfBlockInternal(BasicBlock *BB); - - void operator=(const SSAUpdater&) = delete; - SSAUpdater(const SSAUpdater&) = delete; }; /// \brief Helper class for promoting a collection of loads and stores into SSA @@ -138,7 +138,7 @@ protected: public: LoadAndStorePromoter(ArrayRef Insts, SSAUpdater &S, StringRef Name = StringRef()); - virtual ~LoadAndStorePromoter() {} + virtual ~LoadAndStorePromoter() = default; /// \brief This does the promotion. /// @@ -173,6 +173,6 @@ public: } }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_TRANSFORMS_UTILS_SSAUPDATER_H diff --git a/include/llvm/Transforms/Utils/SimplifyIndVar.h b/include/llvm/Transforms/Utils/SimplifyIndVar.h index 90438ee699f..6cdeeeb60a6 100644 --- a/include/llvm/Transforms/Utils/SimplifyIndVar.h +++ b/include/llvm/Transforms/Utils/SimplifyIndVar.h @@ -22,7 +22,6 @@ namespace llvm { class CastInst; class DominatorTree; -class IVUsers; class Loop; class LoopInfo; class PHINode; @@ -32,13 +31,13 @@ class ScalarEvolution; /// simplified by this utility. class IVVisitor { protected: - const DominatorTree *DT; + const DominatorTree *DT = nullptr; virtual void anchor(); public: - IVVisitor() : DT(nullptr) {} - virtual ~IVVisitor() {} + IVVisitor() = default; + virtual ~IVVisitor() = default; const DominatorTree *getDomTree() const { return DT; } virtual void visitCast(CastInst *Cast) = 0; @@ -55,6 +54,6 @@ bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, DominatorTree *DT, bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT, LoopInfo *LI, SmallVectorImpl &Dead); -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H diff --git a/include/llvm/Transforms/Utils/SymbolRewriter.h b/include/llvm/Transforms/Utils/SymbolRewriter.h index ff995173e12..93658989fba 100644 --- a/include/llvm/Transforms/Utils/SymbolRewriter.h +++ b/include/llvm/Transforms/Utils/SymbolRewriter.h @@ -36,18 +36,24 @@ #include "llvm/IR/Module.h" #include "llvm/IR/PassManager.h" #include +#include +#include namespace llvm { + class MemoryBuffer; namespace yaml { + class KeyValueNode; class MappingNode; class ScalarNode; class Stream; -} + +} // end namespace yaml namespace SymbolRewriter { + /// The basic entity representing a rewrite operation. It serves as the base /// class for any rewrite descriptor. It has a certain set of specializations /// which describe a particular rewrite. @@ -60,11 +66,6 @@ namespace SymbolRewriter { /// select the symbols to rewrite. This descriptor list is passed to the /// SymbolRewriter pass. class RewriteDescriptor { - RewriteDescriptor(const RewriteDescriptor &) = delete; - - const RewriteDescriptor & - operator=(const RewriteDescriptor &) = delete; - public: enum class Type { Invalid, /// invalid @@ -73,7 +74,9 @@ public: NamedAlias, /// named alias - descriptor rewrites a global alias }; - virtual ~RewriteDescriptor() {} + RewriteDescriptor(const RewriteDescriptor &) = delete; + RewriteDescriptor &operator=(const RewriteDescriptor &) = delete; + virtual ~RewriteDescriptor() = default; Type getType() const { return Kind; } @@ -108,7 +111,8 @@ private: yaml::MappingNode *V, RewriteDescriptorList *DL); }; -} + +} // end namespace SymbolRewriter ModulePass *createRewriteSymbolsPass(); ModulePass *createRewriteSymbolsPass(SymbolRewriter::RewriteDescriptorList &); @@ -130,6 +134,7 @@ private: SymbolRewriter::RewriteDescriptorList Descriptors; }; -} + +} // end namespace llvm #endif //LLVM_TRANSFORMS_UTILS_SYMBOLREWRITER_H diff --git a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h index 550292f6b7a..222c601ad60 100644 --- a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h +++ b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h @@ -19,16 +19,18 @@ #define LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H #include "llvm/Pass.h" +#include "llvm/PassRegistry.h" namespace llvm { struct UnifyFunctionExitNodes : public FunctionPass { - BasicBlock *ReturnBlock, *UnwindBlock, *UnreachableBlock; + BasicBlock *ReturnBlock = nullptr; + BasicBlock *UnwindBlock = nullptr; + BasicBlock *UnreachableBlock; public: static char ID; // Pass identification, replacement for typeid - UnifyFunctionExitNodes() : FunctionPass(ID), - ReturnBlock(nullptr), UnwindBlock(nullptr) { + UnifyFunctionExitNodes() : FunctionPass(ID) { initializeUnifyFunctionExitNodesPass(*PassRegistry::getPassRegistry()); } @@ -47,6 +49,6 @@ public: Pass *createUnifyFunctionExitNodesPass(); -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H diff --git a/include/llvm/Transforms/Utils/ValueMapper.h b/include/llvm/Transforms/Utils/ValueMapper.h index de649009612..950ad92afcd 100644 --- a/include/llvm/Transforms/Utils/ValueMapper.h +++ b/include/llvm/Transforms/Utils/ValueMapper.h @@ -15,7 +15,9 @@ #ifndef LLVM_TRANSFORMS_UTILS_VALUEMAPPER_H #define LLVM_TRANSFORMS_UTILS_VALUEMAPPER_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/IR/ValueMap.h" +#include "llvm/IR/ValueHandle.h" namespace llvm { @@ -27,8 +29,9 @@ typedef ValueMap ValueToValueMapTy; /// cloning constants and instructions. class ValueMapTypeRemapper { virtual void anchor(); // Out of line method. + public: - virtual ~ValueMapTypeRemapper() {} + virtual ~ValueMapTypeRemapper() = default; /// The client should implement this method if they want to remap types while /// mapping values. @@ -92,8 +95,6 @@ static inline RemapFlags operator|(RemapFlags LHS, RemapFlags RHS) { return RemapFlags(unsigned(LHS) | unsigned(RHS)); } -class ValueMapperImpl; - /// Context for (re-)mapping values (and metadata). /// /// A shared context used for mapping and remapping of Value and Metadata @@ -133,15 +134,14 @@ class ValueMapperImpl; class ValueMapper { void *pImpl; - ValueMapper(ValueMapper &&) = delete; - ValueMapper(const ValueMapper &) = delete; - ValueMapper &operator=(ValueMapper &&) = delete; - ValueMapper &operator=(const ValueMapper &) = delete; - public: ValueMapper(ValueToValueMapTy &VM, RemapFlags Flags = RF_None, ValueMapTypeRemapper *TypeMapper = nullptr, ValueMaterializer *Materializer = nullptr); + ValueMapper(ValueMapper &&) = delete; + ValueMapper(const ValueMapper &) = delete; + ValueMapper &operator=(ValueMapper &&) = delete; + ValueMapper &operator=(const ValueMapper &) = delete; ~ValueMapper(); /// Register an alternate mapping context. @@ -268,6 +268,6 @@ inline Constant *MapValue(const Constant *V, ValueToValueMapTy &VM, return ValueMapper(VM, Flags, TypeMapper, Materializer).mapConstant(*V); } -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_TRANSFORMS_UTILS_VALUEMAPPER_H diff --git a/lib/Transforms/Utils/GlobalStatus.cpp b/lib/Transforms/Utils/GlobalStatus.cpp index 74ebcda8355..ba4b78ac758 100644 --- a/lib/Transforms/Utils/GlobalStatus.cpp +++ b/lib/Transforms/Utils/GlobalStatus.cpp @@ -10,9 +10,22 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CallSite.h" +#include "llvm/IR/Constant.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalVariable.h" +#include "llvm/IR/InstrTypes.h" +#include "llvm/IR/Instruction.h" +#include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/Transforms/Utils/GlobalStatus.h" +#include "llvm/IR/Use.h" +#include "llvm/IR/User.h" +#include "llvm/IR/Value.h" +#include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/Casting.h" +#include +#include using namespace llvm; @@ -175,13 +188,9 @@ static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS, return false; } +GlobalStatus::GlobalStatus() = default; + bool GlobalStatus::analyzeGlobal(const Value *V, GlobalStatus &GS) { SmallPtrSet PhiUsers; return analyzeGlobalAux(V, GS, PhiUsers); } - -GlobalStatus::GlobalStatus() - : IsCompared(false), IsLoaded(false), StoredType(NotStored), - StoredOnceValue(nullptr), AccessingFunction(nullptr), - HasMultipleAccessingFunctions(false), HasNonInstructionUser(false), - Ordering(AtomicOrdering::NotAtomic) {}