Index: include/polly/CodeGen/BlockGenerators.h =================================================================== --- include/polly/CodeGen/BlockGenerators.h +++ include/polly/CodeGen/BlockGenerators.h @@ -19,20 +19,24 @@ #include "polly/CodeGen/IRBuilder.h" #include "polly/Support/ScopHelper.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "isl/map.h" +#include +#include -struct isl_ast_build; struct isl_id_to_ast_expr; namespace llvm { -class Pass; -class Region; + class ScalarEvolution; -} +} // end namespace llvm + namespace polly { + using namespace llvm; + class ScopStmt; class MemoryAccess; class ScopArrayInfo; @@ -162,7 +166,7 @@ void finalizeSCoP(Scop &S); /// @brief An empty destructor - virtual ~BlockGenerator(){}; + virtual ~BlockGenerator() {} BlockGenerator(const BlockGenerator &) = default; @@ -732,7 +736,7 @@ /// @param BlockGen A generator for basic blocks. RegionGenerator(BlockGenerator &BlockGen) : BlockGenerator(BlockGen) {} - virtual ~RegionGenerator(){}; + ~RegionGenerator() override {} /// @brief Copy the region statement @p Stmt. /// @@ -816,8 +820,8 @@ /// their new values (for values recalculated in the new ScoP, /// but not within this basic block) /// @param BBMap A mapping from old values to their new values in this block. - virtual void generateScalarStores(ScopStmt &Stmt, LoopToScevMapT <S, - ValueMapT &BBMAp) override; + void generateScalarStores(ScopStmt &Stmt, LoopToScevMapT <S, + ValueMapT &BBMAp) override; /// @brief Copy a single PHI instruction. /// @@ -829,9 +833,10 @@ /// @param BBMap A mapping from old values to their new values /// (for values recalculated within this basic block). /// @param LTS A map from old loops to new induction variables as SCEVs. - virtual void copyPHIInstruction(ScopStmt &Stmt, PHINode *Inst, - ValueMapT &BBMap, - LoopToScevMapT <S) override; + void copyPHIInstruction(ScopStmt &Stmt, PHINode *Inst, ValueMapT &BBMap, + LoopToScevMapT <S) override; }; -} -#endif + +} // end namespace polly + +#endif // POLLY_BLOCK_GENERATORS_H Index: include/polly/CodeGen/LoopGenerators.h =================================================================== --- include/polly/CodeGen/LoopGenerators.h +++ include/polly/CodeGen/LoopGenerators.h @@ -11,22 +11,27 @@ // as LLVM-IR. // //===----------------------------------------------------------------------===// + #ifndef POLLY_LOOP_GENERATORS_H #define POLLY_LOOP_GENERATORS_H #include "polly/CodeGen/IRBuilder.h" #include "polly/Support/ScopHelper.h" - #include "llvm/ADT/SetVector.h" -#include "llvm/IR/ValueMap.h" +#include "llvm/IR/BasicBlock.h" +#include "llvm/IR/InstrTypes.h" +#include "llvm/IR/Instructions.h" +#include "llvm/IR/Type.h" namespace llvm { + +class Pass; class Value; -class Pass; -class BasicBlock; -} +} // end namespace llvm + namespace polly { + using namespace llvm; /// @brief Create a scalar do/for-style loop. @@ -53,7 +58,7 @@ PollyIRBuilder &Builder, Pass *P, LoopInfo &LI, DominatorTree &DT, BasicBlock *&ExitBlock, ICmpInst::Predicate Predicate, - ScopAnnotator *Annotator = NULL, bool Parallel = false, + ScopAnnotator *Annotator = nullptr, bool Parallel = false, bool UseGuard = true); /// @brief The ParallelLoopGenerator allows to create parallelized loops @@ -216,5 +221,7 @@ SetVector UsedValues, ValueMapT &VMap, Function **SubFn); }; + } // end namespace polly -#endif + +#endif // POLLY_LOOP_GENERATORS_H Index: include/polly/ScopDetection.h =================================================================== --- include/polly/ScopDetection.h +++ include/polly/ScopDetection.h @@ -49,31 +49,40 @@ #include "polly/ScopDetectionDiagnostic.h" #include "polly/Support/ScopHelper.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SetVector.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Analysis/RegionInfo.h" #include "llvm/Pass.h" +#include #include #include #include +#include +#include +#include using namespace llvm; namespace llvm { + class LoopInfo; class Loop; class ScalarEvolution; class SCEV; -class SCEVAddRecExpr; class SCEVUnknown; class CallInst; class Instruction; class Value; class IntrinsicInst; -} +} // end namespace llvm + namespace polly { + typedef std::set ParamSetType; // Description of the shape of an array. @@ -568,7 +577,7 @@ /// @brief Verify if all valid Regions in this Function are still valid /// after some transformations. - void verifyAnalysis() const; + void verifyAnalysis() const override; /// @brief Verify if R is still a valid part of Scop after some /// transformations. @@ -578,18 +587,21 @@ /// @name FunctionPass interface //@{ - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - virtual void releaseMemory(); - virtual bool runOnFunction(Function &F); - virtual void print(raw_ostream &OS, const Module *) const; + void getAnalysisUsage(AnalysisUsage &AU) const override; + void releaseMemory() override; + bool runOnFunction(Function &F) override; + void print(raw_ostream &OS, const Module *) const override; //@} }; } // end namespace polly namespace llvm { + class PassRegistry; + void initializeScopDetectionPass(llvm::PassRegistry &); -} -#endif +} // end namespace llvm + +#endif // POLLY_SCOP_DETECTION_H Index: include/polly/ScopDetectionDiagnostic.h =================================================================== --- include/polly/ScopDetectionDiagnostic.h +++ include/polly/ScopDetectionDiagnostic.h @@ -17,30 +17,37 @@ // to diagnose the error and generate a helpful error message. // //===----------------------------------------------------------------------===// + #ifndef POLLY_SCOP_DETECTION_DIAGNOSTIC_H #define POLLY_SCOP_DETECTION_DIAGNOSTIC_H #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/ADT/Twine.h" #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/IR/BasicBlock.h" +#include "llvm/IR/DebugLoc.h" +#include "llvm/IR/Instruction.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" +#include #include #include +#include +#include using namespace llvm; namespace llvm { + +class BasicBlock; +class Loop; +class Region; class SCEV; -class BasicBlock; class Value; -class Region; -} +} // end namespace llvm + namespace polly { /// @brief Type to hold region delimitors (entry & exit block). @@ -134,9 +141,7 @@ /// regions amenable to Polly. /// /// @return A short message representing this error. - virtual std::string getEndUserMessage() const { - return "Unspecified error."; - }; + virtual std::string getEndUserMessage() const { return "Unspecified error."; } /// @brief Get the source location of this error. /// @@ -203,8 +208,8 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; //@} }; @@ -225,9 +230,9 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual std::string getEndUserMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + std::string getMessage() const override; + std::string getEndUserMessage() const override; + const DebugLoc &getDebugLoc() const override; //@} }; @@ -252,9 +257,7 @@ /// @name RejectReason interface //@{ - virtual const DebugLoc &getDebugLoc() const override { - return Inst->getDebugLoc(); - }; + const DebugLoc &getDebugLoc() const override { return Inst->getDebugLoc(); } //@} }; @@ -277,7 +280,7 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; + std::string getMessage() const override; //@} }; @@ -302,7 +305,7 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; + std::string getMessage() const override; //@} }; @@ -325,7 +328,7 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; + std::string getMessage() const override; //@} }; @@ -358,7 +361,7 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; + std::string getMessage() const override; //@} }; @@ -377,7 +380,7 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; + std::string getMessage() const override; //@} }; @@ -396,7 +399,7 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; + std::string getMessage() const override; //@} }; @@ -419,8 +422,8 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual std::string getEndUserMessage() const override; + std::string getMessage() const override; + std::string getEndUserMessage() const override; //@} }; @@ -450,8 +453,8 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual std::string getEndUserMessage() const override; + std::string getMessage() const override; + std::string getEndUserMessage() const override; //@} }; @@ -474,8 +477,8 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual std::string getEndUserMessage() const override; + std::string getMessage() const override; + std::string getEndUserMessage() const override; //@} }; @@ -505,9 +508,9 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; - virtual std::string getEndUserMessage() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; + std::string getEndUserMessage() const override; //@} }; @@ -529,9 +532,9 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; - virtual std::string getEndUserMessage() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; + std::string getEndUserMessage() const override; //@} }; @@ -567,9 +570,9 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; - virtual std::string getEndUserMessage() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; + std::string getEndUserMessage() const override; //@} }; @@ -587,7 +590,7 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; + std::string getMessage() const override; //@} }; @@ -609,8 +612,8 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; //@} }; @@ -630,8 +633,8 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; //@} }; @@ -651,8 +654,8 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; //@} }; @@ -672,8 +675,8 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; //@} }; @@ -693,9 +696,9 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual std::string getEndUserMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + std::string getMessage() const override; + std::string getEndUserMessage() const override; + const DebugLoc &getDebugLoc() const override; //@} }; @@ -717,12 +720,12 @@ /// @name RejectReason interface //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; - virtual std::string getEndUserMessage() const override; + std::string getMessage() const override; + const DebugLoc &getDebugLoc() const override; + std::string getEndUserMessage() const override; //@} }; -} // namespace polly +} // end namespace polly #endif // POLLY_SCOP_DETECTION_DIAGNOSTIC_H Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -22,29 +22,49 @@ #include "polly/ScopDetection.h" #include "polly/Support/SCEVAffinator.h" - +#include "polly/Support/ScopHelper.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" +#include "llvm/ADT/SetVector.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/Analysis/RegionPass.h" +#include "llvm/Analysis/ScalarEvolutionExpressions.h" +#include "llvm/IR/DebugLoc.h" +#include "llvm/IR/Instruction.h" +#include "llvm/IR/ValueHandle.h" #include "isl/aff.h" #include "isl/ctx.h" #include "isl/set.h" - +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include using namespace llvm; namespace llvm { + class AssumptionCache; class Loop; class LoopInfo; class PHINode; class ScalarEvolution; class SCEV; -class SCEVAddRecExpr; class Type; -} +} // end namespace llvm + struct isl_ctx; struct isl_map; struct isl_basic_map; @@ -54,7 +74,6 @@ struct isl_union_map; struct isl_space; struct isl_ast_build; -struct isl_constraint; struct isl_pw_aff; struct isl_pw_multi_aff; struct isl_schedule; @@ -274,7 +293,7 @@ /// @brief The set of derived indirect SAIs for this origin SAI. const SmallPtrSetImpl &getDerivedSAIs() const { return DerivedSAIs; - }; + } /// @brief Return the number of dimensions. unsigned getNumberOfDimensions() const { @@ -320,7 +339,7 @@ __isl_give isl_id *getBasePtrId() const; /// @brief Is this array info modeling an llvm::Value? - bool isValueKind() const { return Kind == MK_Value; }; + bool isValueKind() const { return Kind == MK_Value; } /// @brief Is this array info modeling special PHI node memory? /// @@ -332,13 +351,13 @@ /// original PHI node as virtual base pointer, we have this additional /// attribute to distinguish the PHI node specific array modeling from the /// normal scalar array modeling. - bool isPHIKind() const { return Kind == MK_PHI; }; + bool isPHIKind() const { return Kind == MK_PHI; } /// @brief Is this array info modeling an MK_ExitPHI? - bool isExitPHIKind() const { return Kind == MK_ExitPHI; }; + bool isExitPHIKind() const { return Kind == MK_ExitPHI; } /// @brief Is this array info modeling an array? - bool isArrayKind() const { return Kind == MK_Array; }; + bool isArrayKind() const { return Kind == MK_Array; } /// @brief Dump a readable representation to stderr. void dump() const; @@ -1755,7 +1774,7 @@ LoopStackElement(Loop *L, __isl_give isl_schedule *S, unsigned NumBlocksProcessed) - : L(L), Schedule(S), NumBlocksProcessed(NumBlocksProcessed){}; + : L(L), Schedule(S), NumBlocksProcessed(NumBlocksProcessed) {} } LoopStackElementTy; /// @brief The loop stack used for schedule construction. @@ -1827,7 +1846,7 @@ /// AccFuncSetType *getAccessFunctions(const BasicBlock *BB) { AccFuncMapType::iterator at = AccFuncMap.find(BB); - return at != AccFuncMap.end() ? &(at->second) : 0; + return at != AccFuncMap.end() ? &(at->second) : nullptr; } ScalarEvolution *getSE() const; @@ -2502,7 +2521,7 @@ static char ID; // Pass identification, replacement for typeid ScopInfoRegionPass() : RegionPass(ID) {} - ~ScopInfoRegionPass() {} + ~ScopInfoRegionPass() override {} /// @brief Build ScopBuilder object, which constructs Polly IR of static /// control part for the current SESE-Region. @@ -2534,8 +2553,11 @@ } // end namespace polly namespace llvm { + class PassRegistry; + void initializeScopInfoRegionPassPass(llvm::PassRegistry &); -} -#endif +} // end namespace llvm + +#endif // POLLY_SCOP_INFO_H Index: include/polly/ScopPass.h =================================================================== --- include/polly/ScopPass.h +++ include/polly/ScopPass.h @@ -23,6 +23,7 @@ using namespace llvm; namespace polly { + class Scop; /// ScopPass - This class adapts the RegionPass interface to allow convenient @@ -32,7 +33,7 @@ Scop *S; protected: - explicit ScopPass(char &ID) : RegionPass(ID), S(0) {} + explicit ScopPass(char &ID) : RegionPass(ID), S(nullptr) {} /// runOnScop - This method must be overloaded to perform the /// desired Polyhedral transformation or analysis. @@ -40,18 +41,18 @@ virtual bool runOnScop(Scop &S) = 0; /// @brief Print method for SCoPs. - virtual void printScop(raw_ostream &OS, Scop &S) const {}; + virtual void printScop(raw_ostream &OS, Scop &S) const {} /// getAnalysisUsage - Subclasses that override getAnalysisUsage /// must call this. /// - virtual void getAnalysisUsage(AnalysisUsage &AU) const override; + void getAnalysisUsage(AnalysisUsage &AU) const override; private: bool runOnRegion(Region *R, RGPassManager &RGM) override; void print(raw_ostream &OS, const Module *) const override; }; -} // End llvm namespace +} // end namespace polly -#endif +#endif // POLLY_SCOP_PASS_H Index: lib/Analysis/DependenceInfo.cpp =================================================================== --- lib/Analysis/DependenceInfo.cpp +++ lib/Analysis/DependenceInfo.cpp @@ -19,22 +19,30 @@ // analysis will never produce redundant dependences. // //===----------------------------------------------------------------------===// -// + #include "polly/DependenceInfo.h" #include "polly/LinkAllPasses.h" #include "polly/Options.h" #include "polly/ScopInfo.h" #include "polly/Support/GICHelper.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/PassAnalysisSupport.h" +#include "llvm/PassSupport.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "llvm/Support/raw_ostream.h" +#include "isl/aff.h" +#include "isl/ctx.h" +#include "isl/flow.h" +#include "isl/map.h" +#include "isl/options.h" +#include "isl/schedule.h" +#include "isl/set.h" +#include "isl/space.h" +#include "isl/union_map.h" +#include "isl/union_set.h" +#include +#include using namespace polly; using namespace llvm; @@ -244,7 +252,7 @@ // dependency cycles in the privatization dependences. To make sure this // will not happen we remove all negative dependences after we computed // the transitive closure. - TC_RED = isl_union_map_transitive_closure(isl_union_map_copy(RED), 0); + TC_RED = isl_union_map_transitive_closure(isl_union_map_copy(RED), nullptr); // FIXME: Apply the current schedule instead of assuming the identity schedule // here. The current approach is only valid as long as we compute the Index: lib/Analysis/ScopDetection.cpp =================================================================== --- lib/Analysis/ScopDetection.cpp +++ lib/Analysis/ScopDetection.cpp @@ -45,7 +45,6 @@ //===----------------------------------------------------------------------===// #include "polly/ScopDetection.h" -#include "polly/CodeGen/CodeGeneration.h" #include "polly/LinkAllPasses.h" #include "polly/Options.h" #include "polly/ScopDetectionDiagnostic.h" @@ -54,18 +53,35 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/LoopInfo.h" -#include "llvm/Analysis/PostDominators.h" -#include "llvm/Analysis/RegionIterator.h" +#include "llvm/Analysis/MemoryLocation.h" +#include "llvm/Analysis/RegionInfo.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" -#include "llvm/IR/DebugInfo.h" +#include "llvm/IR/BasicBlock.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/DebugLoc.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" +#include "llvm/IR/Dominators.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/InstrTypes.h" +#include "llvm/IR/Instruction.h" +#include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Metadata.h" +#include "llvm/PassAnalysisSupport.h" +#include "llvm/PassSupport.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" -#include +#include "llvm/Support/raw_ostream.h" +#include +#include #include +#include +#include using namespace llvm; using namespace polly; @@ -204,7 +220,7 @@ : DiagnosticInfo(PluginDiagnosticKind, DS_Note), F(F), FileName(FileName), EntryLine(EntryLine), ExitLine(ExitLine) {} - virtual void print(DiagnosticPrinter &DP) const; + void print(DiagnosticPrinter &DP) const override; static bool classof(const DiagnosticInfo *DI) { return DI->getKind() == PluginDiagnosticKind; @@ -289,7 +305,6 @@ bool ScopDetection::addOverApproximatedRegion(Region *AR, DetectionContext &Context) const { - // If we already know about Ar we can exit. if (!Context.NonAffineSubRegionSet.insert(AR)) return true; @@ -323,7 +338,6 @@ bool ScopDetection::isAffine(const SCEV *S, Loop *Scope, DetectionContext &Context) const { - InvariantLoadsSetTy AccessILS; if (!isAffineExpr(&Context.CurRegion, Scope, S, *SE, &AccessILS)) return false; @@ -357,7 +371,6 @@ bool ScopDetection::isValidBranch(BasicBlock &BB, BranchInst *BI, Value *Condition, bool IsLoopBranch, DetectionContext &Context) const { - if (BinaryOperator *BinOp = dyn_cast(Condition)) { auto Opcode = BinOp->getOpcode(); if (Opcode == Instruction::And || Opcode == Instruction::Or) { @@ -452,7 +465,7 @@ Function *CalledFunction = CI.getCalledFunction(); // Indirect calls are not supported. - if (CalledFunction == 0) + if (CalledFunction == nullptr) return false; if (AllowModrefCall) { @@ -665,7 +678,7 @@ for (const auto &Pair : Context.Accesses[BasePointer]) { std::vector MaxTerms; SCEVRemoveMax::remove(*SE, Pair.second, &MaxTerms); - if (MaxTerms.size() > 0) { + if (!MaxTerms.empty()) { Terms.insert(Terms.begin(), MaxTerms.begin(), MaxTerms.end()); continue; } @@ -848,7 +861,6 @@ bool ScopDetection::isValidAccess(Instruction *Inst, const SCEV *AF, const SCEVUnknown *BP, DetectionContext &Context) const { - if (!BP) return invalid(Context, /*Assert=*/true, Inst); @@ -1131,6 +1143,7 @@ return LastValidRegion.release(); } + static bool regionWithoutLoops(Region &R, LoopInfo *LI) { for (const BasicBlock *BB : R.blocks()) if (R.contains(LI->getLoopFor(BB))) Index: lib/CodeGen/CodegenCleanup.cpp =================================================================== --- lib/CodeGen/CodegenCleanup.cpp +++ lib/CodeGen/CodegenCleanup.cpp @@ -1,15 +1,25 @@ +//===- CodegenCleanup.cpp -------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + #include "polly/CodeGen/CodegenCleanup.h" - +#include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/CFLAliasAnalysis.h" #include "llvm/Analysis/ScopedNoAliasAA.h" #include "llvm/Analysis/TypeBasedAliasAnalysis.h" #include "llvm/IR/Function.h" #include "llvm/IR/LegacyPassManager.h" -#include "llvm/PassInfo.h" -#include "llvm/PassRegistry.h" +#include "llvm/Pass.h" #include "llvm/PassSupport.h" #include "llvm/Support/Debug.h" #include "llvm/Transforms/Scalar.h" +#include + #define DEBUG_TYPE "polly-cleanup" using namespace llvm; @@ -30,9 +40,9 @@ /// @name FunctionPass interface //@{ - virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {} + void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {} - virtual bool doInitialization(Module &M) override { + bool doInitialization(Module &M) override { assert(!FPM); FPM = new llvm::legacy::FunctionPassManager(&M); @@ -86,7 +96,7 @@ return FPM->doInitialization(); } - virtual bool doFinalization(Module &M) override { + bool doFinalization(Module &M) override { bool Result = FPM->doFinalization(); delete FPM; @@ -95,7 +105,7 @@ return Result; } - virtual bool runOnFunction(llvm::Function &F) override { + bool runOnFunction(llvm::Function &F) override { if (!F.hasFnAttribute("polly-optimized")) { DEBUG(dbgs() << F.getName() << ": Skipping cleanup because Polly did not optimize it."); @@ -109,8 +119,9 @@ }; char CodegenCleanup::ID; -} +} // end anonymous namespace + FunctionPass *polly::createCodegenCleanupPass() { return new CodegenCleanup(); } INITIALIZE_PASS_BEGIN(CodegenCleanup, "polly-cleanup", Index: lib/CodeGen/LoopGenerators.cpp =================================================================== --- lib/CodeGen/LoopGenerators.cpp +++ lib/CodeGen/LoopGenerators.cpp @@ -13,12 +13,21 @@ #include "polly/CodeGen/LoopGenerators.h" #include "polly/ScopDetection.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Dominators.h" +#include "llvm/IR/GlobalValue.h" #include "llvm/IR/Module.h" +#include "llvm/IR/Value.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include +#include +#include +#include using namespace llvm; using namespace polly; @@ -289,7 +298,7 @@ BasicBlock &EntryBB = Builder.GetInsertBlock()->getParent()->getEntryBlock(); Instruction *IP = &*EntryBB.getFirstInsertionPt(); StructType *Ty = StructType::get(Builder.getContext(), Members); - AllocaInst *Struct = new AllocaInst(Ty, 0, "polly.par.userContext", IP); + AllocaInst *Struct = new AllocaInst(Ty, nullptr, "polly.par.userContext", IP); // Mark the start of the lifetime for the parameter struct. ConstantInt *SizeOf = Builder.getInt64(DL.getTypeAllocSize(Ty)); @@ -338,8 +347,8 @@ // Fill up basic block HeaderBB. Builder.SetInsertPoint(HeaderBB); - LBPtr = Builder.CreateAlloca(LongType, 0, "polly.par.LBPtr"); - UBPtr = Builder.CreateAlloca(LongType, 0, "polly.par.UBPtr"); + LBPtr = Builder.CreateAlloca(LongType, nullptr, "polly.par.LBPtr"); + UBPtr = Builder.CreateAlloca(LongType, nullptr, "polly.par.UBPtr"); UserContext = Builder.CreateBitCast( &*SubFn->arg_begin(), StructData->getType(), "polly.par.userContext"); Index: lib/Transform/Canonicalization.cpp =================================================================== --- lib/Transform/Canonicalization.cpp +++ lib/Transform/Canonicalization.cpp @@ -1,4 +1,4 @@ -//===---- Canonicalization.cpp - Run canonicalization passes ======-------===// +//===---- Canonicalization.cpp - Run canonicalization passes --------------===// // // The LLVM Compiler Infrastructure // @@ -16,6 +16,10 @@ #include "polly/Canonicalization.h" #include "polly/LinkAllPasses.h" #include "polly/Options.h" +#include "llvm/IR/LegacyPassManager.h" +#include "llvm/Pass.h" +#include "llvm/PassSupport.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" @@ -47,6 +51,7 @@ } namespace { + class PollyCanonicalize : public ModulePass { PollyCanonicalize(const PollyCanonicalize &) = delete; const PollyCanonicalize &operator=(const PollyCanonicalize &) = delete; @@ -55,18 +60,19 @@ static char ID; explicit PollyCanonicalize() : ModulePass(ID) {} - ~PollyCanonicalize(); + ~PollyCanonicalize() override; /// @name FunctionPass interface. //@{ - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - virtual void releaseMemory(); - virtual bool runOnModule(Module &M); - virtual void print(raw_ostream &OS, const Module *) const; + void getAnalysisUsage(AnalysisUsage &AU) const override; + void releaseMemory() override; + bool runOnModule(Module &M) override; + void print(raw_ostream &OS, const Module *) const override; //@} }; -} +} // end anonymous namespace + PollyCanonicalize::~PollyCanonicalize() {} void PollyCanonicalize::getAnalysisUsage(AnalysisUsage &AU) const {} Index: lib/Transform/CodePreparation.cpp =================================================================== --- lib/Transform/CodePreparation.cpp +++ lib/Transform/CodePreparation.cpp @@ -17,13 +17,16 @@ //===----------------------------------------------------------------------===// #include "polly/LinkAllPasses.h" -#include "polly/ScopDetection.h" #include "polly/Support/ScopHelper.h" #include "llvm/Analysis/DominanceFrontier.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/RegionInfo.h" #include "llvm/Analysis/ScalarEvolution.h" -#include "llvm/Transforms/Utils/Local.h" +#include "llvm/IR/Dominators.h" +#include "llvm/IR/Function.h" +#include "llvm/Pass.h" +#include "llvm/PassAnalysisSupport.h" +#include "llvm/PassSupport.h" using namespace llvm; using namespace polly; @@ -47,18 +50,19 @@ static char ID; explicit CodePreparation() : FunctionPass(ID) {} - ~CodePreparation(); + ~CodePreparation() override; /// @name FunctionPass interface. //@{ - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - virtual void releaseMemory(); - virtual bool runOnFunction(Function &F); - virtual void print(raw_ostream &OS, const Module *) const; + void getAnalysisUsage(AnalysisUsage &AU) const override; + void releaseMemory() override; + bool runOnFunction(Function &F) override; + void print(raw_ostream &OS, const Module *) const override; //@} }; -} +} // end anonymous namespace + void CodePreparation::clear() {} CodePreparation::~CodePreparation() { clear(); } Index: lib/Transform/ScheduleOptimizer.cpp =================================================================== --- lib/Transform/ScheduleOptimizer.cpp +++ lib/Transform/ScheduleOptimizer.cpp @@ -52,19 +52,27 @@ #include "polly/LinkAllPasses.h" #include "polly/Options.h" #include "polly/ScopInfo.h" -#include "polly/Support/GICHelper.h" +#include "polly/ScopPass.h" +#include "llvm/PassAnalysisSupport.h" +#include "llvm/PassSupport.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" -#include "isl/aff.h" -#include "isl/band.h" +#include "llvm/Support/raw_ostream.h" #include "isl/constraint.h" +#include "isl/id.h" +#include "isl/local_space.h" #include "isl/map.h" #include "isl/options.h" #include "isl/printer.h" #include "isl/schedule.h" #include "isl/schedule_node.h" +#include "isl/set.h" #include "isl/space.h" #include "isl/union_map.h" #include "isl/union_set.h" +#include "isl/val.h" +#include +#include using namespace llvm; using namespace polly; @@ -183,7 +191,7 @@ IsolateRelation = isl_map_move_dims(IsolateRelation, isl_dim_out, 0, isl_dim_in, Dims - 1, 1); auto *IsolateOption = isl_map_wrap(IsolateRelation); - auto *Id = isl_id_alloc(isl_set_get_ctx(IsolateOption), "isolate", NULL); + auto *Id = isl_id_alloc(isl_set_get_ctx(IsolateOption), "isolate", nullptr); return isl_union_set_from_set(isl_set_set_tuple_id(IsolateOption, Id)); } @@ -196,7 +204,7 @@ static __isl_give isl_union_set *getAtomicOptions(__isl_take isl_ctx *Ctx) { auto *Space = isl_space_set_alloc(Ctx, 0, 1); auto *AtomicOption = isl_set_universe(Space); - auto *Id = isl_id_alloc(Ctx, "atomic", NULL); + auto *Id = isl_id_alloc(Ctx, "atomic", nullptr); return isl_union_set_from_set(isl_set_set_tuple_id(AtomicOption, Id)); } @@ -526,7 +534,8 @@ __isl_give isl_schedule_node *ScheduleTreeOptimizer::optimizeScheduleNode( __isl_take isl_schedule_node *Node) { - Node = isl_schedule_node_map_descendant_bottom_up(Node, optimizeBand, NULL); + Node = + isl_schedule_node_map_descendant_bottom_up(Node, optimizeBand, nullptr); return Node; } @@ -548,12 +557,13 @@ } namespace { + class IslScheduleOptimizer : public ScopPass { public: static char ID; explicit IslScheduleOptimizer() : ScopPass(ID) { LastSchedule = nullptr; } - ~IslScheduleOptimizer() { isl_schedule_free(LastSchedule); } + ~IslScheduleOptimizer() override { isl_schedule_free(LastSchedule); } /// @brief Optimize the schedule of the SCoP @p S. bool runOnScop(Scop &S) override; @@ -573,12 +583,12 @@ private: isl_schedule *LastSchedule; }; -} +} // end anonymous namespace + char IslScheduleOptimizer::ID = 0; bool IslScheduleOptimizer::runOnScop(Scop &S) { - // Skip empty SCoPs but still allow code generation as it will delete the // loops present but not needed. if (S.getSize() == 0) {