Index: include/polly/CodeGen/IslAst.h =================================================================== --- include/polly/CodeGen/IslAst.h +++ include/polly/CodeGen/IslAst.h @@ -44,7 +44,7 @@ class IslAstInfo : public ScopPass { public: - using MemoryAccessSet = SmallPtrSet; + using MemoryAccessSet = llvm::SmallPtrSet; /// @brief Payload information used to annotate an AST node. struct IslAstUserPayload { @@ -144,7 +144,7 @@ ///} - virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const; virtual void releaseMemory(); }; } Index: include/polly/ScopDetection.h =================================================================== --- include/polly/ScopDetection.h +++ include/polly/ScopDetection.h @@ -58,8 +58,6 @@ #include #include -using namespace llvm; - namespace llvm { class RegionInfo; class Region; @@ -76,37 +74,38 @@ } namespace polly { -typedef std::set ParamSetType; + +typedef std::set ParamSetType; // Description of the shape of an array. struct ArrayShape { // Base pointer identifying all accesses to this array. - const SCEVUnknown *BasePointer; + const llvm::SCEVUnknown *BasePointer; // Sizes of each delinearized dimension. - SmallVector DelinearizedSizes; + llvm::SmallVector DelinearizedSizes; - ArrayShape(const SCEVUnknown *B) : BasePointer(B), DelinearizedSizes() {} + ArrayShape(const llvm::SCEVUnknown *B) : BasePointer(B), DelinearizedSizes() {} }; struct MemAcc { - const Instruction *Insn; + const llvm::Instruction *Insn; // A pointer to the shape description of the array. ArrayShape *Shape; // Subscripts computed by delinearization. - SmallVector DelinearizedSubscripts; + llvm::SmallVector DelinearizedSubscripts; - MemAcc(const Instruction *I, ArrayShape *S) + MemAcc(const llvm::Instruction *I, ArrayShape *S) : Insn(I), Shape(S), DelinearizedSubscripts() {} }; -typedef std::map MapInsnToMemAcc; -typedef std::pair PairInstSCEV; +typedef std::map MapInsnToMemAcc; +typedef std::pair PairInstSCEV; typedef std::vector AFs; -typedef std::map BaseToAFs; -typedef std::map BaseToElSize; +typedef std::map BaseToAFs; +typedef std::map BaseToElSize; extern bool PollyModelPHINodes; extern bool PollyTrackFailures; @@ -119,9 +118,13 @@ //===----------------------------------------------------------------------===// /// @brief Pass to detect the maximal static control parts (Scops) of a /// function. -class ScopDetection : public FunctionPass { +class ScopDetection : public llvm::FunctionPass { + + using Region = llvm::Region; + using Instruction = llvm::Instruction; + public: - typedef SetVector RegionSet; + typedef llvm::SetVector RegionSet; private: //===--------------------------------------------------------------------===// @@ -130,22 +133,22 @@ /// @brief Analysis passes used. //@{ - ScalarEvolution *SE; - LoopInfo *LI; - RegionInfo *RI; - AliasAnalysis *AA; + llvm::ScalarEvolution *SE; + llvm::LoopInfo *LI; + llvm::RegionInfo *RI; + llvm::AliasAnalysis *AA; //@} /// @brief Set to remember non-affine branches in regions. using NonAffineSubRegionSetTy = RegionSet; using NonAffineSubRegionMapTy = - DenseMap; + llvm::DenseMap; NonAffineSubRegionMapTy NonAffineSubRegionMap; /// @brief Context variables for SCoP detection. struct DetectionContext { Region &CurRegion; // The region to check. - AliasSetTracker AST; // The AliasSetTracker to hold the alias information. + llvm::AliasSetTracker AST; // The AliasSetTracker to hold the alias information. bool Verifying; // If we are in the verification phase? RejectLog Log; @@ -159,7 +162,7 @@ /// /// This set contains all base pointers which are used in memory accesses /// that can not be detected as affine accesses. - SetVector NonAffineAccesses; + llvm::SetVector NonAffineAccesses; BaseToElSize ElementSize; /// @brief The region has at least one load instruction. @@ -171,7 +174,7 @@ /// @brief The set of non-affine subregions in the region we analyze. NonAffineSubRegionSetTy &NonAffineSubRegionSet; - DetectionContext(Region &R, AliasAnalysis &AA, + DetectionContext(Region &R, llvm::AliasAnalysis &AA, NonAffineSubRegionSetTy &NABS, bool Verify) : CurRegion(R), AST(AA), Verifying(Verify), Log(&R), hasLoads(false), hasStores(false), NonAffineSubRegionSet(NABS) {} @@ -222,7 +225,7 @@ /// /// @param CI The call instruction to check. /// @return True if the call instruction is valid, false otherwise. - static bool isValidCallInst(CallInst &CI); + static bool isValidCallInst(llvm::CallInst &CI); /// @brief Check if a value is invariant in the region Reg. /// @@ -231,7 +234,7 @@ /// /// @return True if the value represented by Val is invariant in the region /// identified by Reg. - bool isInvariant(const Value &Val, const Region &Reg) const; + bool isInvariant(const llvm::Value &Val, const Region &Reg) const; /// @brief Check if a memory access can be part of a Scop. /// @@ -265,7 +268,7 @@ /// @param Context The context of scop detection. /// /// @return True if the BB contains only valid control flow. - bool isValidCFG(BasicBlock &BB, DetectionContext &Context) const; + bool isValidCFG(llvm::BasicBlock &BB, DetectionContext &Context) const; /// @brief Is a loop valid with respect to a given region. /// @@ -273,7 +276,7 @@ /// @param Context The context of scop detection. /// /// @return True if the loop is valid in the region. - bool isValidLoop(Loop *L, DetectionContext &Context) const; + bool isValidLoop(llvm::Loop *L, DetectionContext &Context) const; /// @brief Check if the function @p F is marked as invalid. /// @@ -299,7 +302,7 @@ /// @brief Get the RegionInfo stored in this pass. /// /// This was added to give the DOT printer easy access to this information. - RegionInfo *getRI() const { return RI; } + llvm::RegionInfo *getRI() const { return RI; } /// @brief Is the region is the maximum region of a Scop? /// @@ -355,7 +358,7 @@ /// /// @param F The function to emit remarks for. /// @param R The region to start the region tree traversal for. - void emitMissedRemarksForLeaves(const Function &F, const Region *R); + void emitMissedRemarksForLeaves(const llvm::Function &F, const Region *R); /// @brief Emit rejection remarks for the parent regions of all valid regions. /// @@ -365,14 +368,14 @@ /// /// @param F The function to emit remarks for. /// @param ValidRegions The set of valid regions to emit remarks for. - void emitMissedRemarksForValidRegions(const Function &F, + void emitMissedRemarksForValidRegions(const llvm::Function &F, const RegionSet &ValidRegions); /// @brief Mark the function as invalid so we will not extract any scop from /// the function. /// /// @param F The function to mark as invalid. - void markFunctionAsInvalid(Function *F) const; + void markFunctionAsInvalid(llvm::Function *F) const; /// @brief Verify if all valid Regions in this Function are still valid /// after some transformations. @@ -386,10 +389,10 @@ /// @name FunctionPass interface //@{ - virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const; virtual void releaseMemory(); - virtual bool runOnFunction(Function &F); - virtual void print(raw_ostream &OS, const Module *) const; + virtual bool runOnFunction(llvm::Function &F); + virtual void print(llvm::raw_ostream &OS, const llvm::Module *) const; //@} }; @@ -397,7 +400,7 @@ namespace llvm { class PassRegistry; -void initializeScopDetectionPass(llvm::PassRegistry &); +void initializeScopDetectionPass(PassRegistry &); } #endif Index: include/polly/ScopDetectionDiagnostic.h =================================================================== --- include/polly/ScopDetectionDiagnostic.h +++ include/polly/ScopDetectionDiagnostic.h @@ -33,7 +33,6 @@ #include #include -using namespace llvm; namespace llvm { class SCEV; @@ -50,7 +49,7 @@ /// @param LineBegin The first line in the region. /// @param LineEnd The last line in the region. /// @param FileName The filename where the region was defined. -void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd, +void getDebugLocation(const llvm::Region *R, unsigned &LineBegin, unsigned &LineEnd, std::string &FileName); class RejectLog; @@ -66,7 +65,7 @@ /// /// @param F The function we emit remarks for /// @param R The region that marks a valid Scop -void emitValidRemarks(const llvm::Function &F, const Region *R); +void emitValidRemarks(const llvm::Function &F, const llvm::Region *R); // Discriminator for LLVM-style RTTI (dyn_cast<> et al.) enum RejectReasonKind { @@ -127,7 +126,7 @@ const RejectReasonKind Kind; protected: - static const DebugLoc Unknown; + static const llvm::DebugLoc Unknown; public: RejectReasonKind getKind() const { return Kind; } @@ -163,6 +162,7 @@ /// @brief Stores all errors that ocurred during the detection. class RejectLog { + using Region = llvm::Region; Region *R; llvm::SmallVector ErrorReports; @@ -180,7 +180,7 @@ /// @return true, if we store at least one error. bool hasErrors() const { return size() > 0; } - void print(raw_ostream &OS, int level = 0) const; + void print(llvm::raw_ostream &OS, int level = 0) const; const Region *region() const { return R; } void report(RejectReasonPtr Reject) { ErrorReports.push_back(Reject); } @@ -188,6 +188,9 @@ /// @brief Store reject logs class RejectLogsContainer { + + using Region = llvm::Region; + std::map Logs; public: @@ -249,10 +252,11 @@ //===----------------------------------------------------------------------===// /// @brief Captures a non-branch terminator within a Scop candidate. class ReportNonBranchTerminator : public ReportCFG { - BasicBlock *BB; + + llvm::BasicBlock *BB; public: - ReportNonBranchTerminator(BasicBlock *BB) + ReportNonBranchTerminator(llvm::BasicBlock *BB) : ReportCFG(rrkNonBranchTerminator), BB(BB) {} /// @name LLVM-RTTI interface @@ -263,7 +267,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; @@ -272,11 +276,12 @@ class ReportCondition : public ReportCFG { //===--------------------------------------------------------------------===// + // The BasicBlock we found the broken condition in. - BasicBlock *BB; + llvm::BasicBlock *BB; public: - ReportCondition(BasicBlock *BB) : ReportCFG(rrkCondition), BB(BB) {} + ReportCondition(llvm::BasicBlock *BB) : ReportCFG(rrkCondition), BB(BB) {} /// @name LLVM-RTTI interface //@{ @@ -286,7 +291,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; @@ -299,10 +304,10 @@ //===--------------------------------------------------------------------===// // The instruction that caused non-affinity to occur. - const Instruction *Inst; + const llvm::Instruction *Inst; public: - ReportAffFunc(const RejectReasonKind K, const Instruction *Inst); + ReportAffFunc(const RejectReasonKind K, const llvm::Instruction *Inst); /// @name LLVM-RTTI interface //@{ @@ -311,7 +316,7 @@ /// @name RejectReason interface //@{ - virtual const DebugLoc &getDebugLoc() const override { + virtual const llvm::DebugLoc &getDebugLoc() const override { return Inst->getDebugLoc(); }; //@} @@ -322,11 +327,12 @@ class ReportUndefCond : public ReportAffFunc { //===--------------------------------------------------------------------===// + // The BasicBlock we found the broken condition in. - BasicBlock *BB; + llvm::BasicBlock *BB; public: - ReportUndefCond(const Instruction *Inst, BasicBlock *BB) + ReportUndefCond(const llvm::Instruction *Inst, llvm::BasicBlock *BB) : ReportAffFunc(rrkUndefCond, Inst), BB(BB) {} /// @name LLVM-RTTI interface @@ -348,10 +354,10 @@ //===--------------------------------------------------------------------===// // The BasicBlock we found the broken condition in. - BasicBlock *BB; + llvm::BasicBlock *BB; public: - ReportInvalidCond(const Instruction *Inst, BasicBlock *BB) + ReportInvalidCond(const llvm::Instruction *Inst, llvm::BasicBlock *BB) : ReportAffFunc(rrkInvalidCond, Inst), BB(BB) {} /// @name LLVM-RTTI interface @@ -371,10 +377,10 @@ //===--------------------------------------------------------------------===// // The BasicBlock we found the undefined operand in. - BasicBlock *BB; + llvm::BasicBlock *BB; public: - ReportUndefOperand(BasicBlock *BB, const Instruction *Inst) + ReportUndefOperand(llvm::BasicBlock *BB, const llvm::Instruction *Inst) : ReportAffFunc(rrkUndefOperand, Inst), BB(BB) {} /// @name LLVM-RTTI interface @@ -393,6 +399,10 @@ class ReportNonAffBranch : public ReportAffFunc { //===--------------------------------------------------------------------===// + using BasicBlock = llvm::BasicBlock; + using SCEV = llvm::SCEV; + using Instruction = llvm::Instruction; + // The BasicBlock we found the non-affine branch in. BasicBlock *BB; @@ -426,6 +436,7 @@ class ReportNoBasePtr : public ReportAffFunc { //===--------------------------------------------------------------------===// public: + using Instruction = llvm::Instruction; ReportNoBasePtr(const Instruction *Inst) : ReportAffFunc(rrkNoBasePtr, Inst) {} @@ -443,6 +454,7 @@ //===----------------------------------------------------------------------===// /// @brief Captures an undefined base pointer. class ReportUndefBasePtr : public ReportAffFunc { + using Instruction = llvm::Instruction; //===--------------------------------------------------------------------===// public: ReportUndefBasePtr(const Instruction *Inst) @@ -464,6 +476,9 @@ class ReportVariantBasePtr : public ReportAffFunc { //===--------------------------------------------------------------------===// + using Value = llvm::Value; + using Instruction = llvm::Instruction; + // The variant base pointer. Value *BaseValue; @@ -489,18 +504,19 @@ //===--------------------------------------------------------------------===// // The non-affine access function. - const SCEV *AccessFunction; + const llvm::SCEV *AccessFunction; // The base pointer of the memory access. - const Value *BaseValue; + const llvm::Value *BaseValue; public: - ReportNonAffineAccess(const SCEV *AccessFunction, const Instruction *Inst, - const Value *V) + ReportNonAffineAccess(const llvm::SCEV *AccessFunction, + const llvm::Instruction *Inst, + const llvm::Value *V) : ReportAffFunc(rrkNonAffineAccess, Inst), AccessFunction(AccessFunction), BaseValue(V) {} - const SCEV *get() { return AccessFunction; } + const llvm::SCEV *get() { return AccessFunction; } /// @name LLVM-RTTI interface //@{ @@ -520,10 +536,10 @@ //===--------------------------------------------------------------------===// // The base pointer of the memory access. - const Value *BaseValue; + const llvm::Value *BaseValue; public: - ReportDifferentArrayElementSize(const Instruction *Inst, const Value *V) + ReportDifferentArrayElementSize(const llvm::Instruction *Inst, const llvm::Value *V) : ReportAffFunc(rrkDifferentElementSize, Inst), BaseValue(V) {} /// @name LLVM-RTTI interface @@ -555,10 +571,10 @@ //===--------------------------------------------------------------------===// // The offending instruction. - Instruction *Inst; + llvm::Instruction *Inst; public: - ReportPhiNodeRefInRegion(Instruction *Inst); + ReportPhiNodeRefInRegion(llvm::Instruction *Inst); /// @name LLVM-RTTI interface //@{ @@ -568,7 +584,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; @@ -576,7 +592,7 @@ /// @brief Captures a region with invalid entering edges. class ReportIndEdge : public RejectReason { //===--------------------------------------------------------------------===// - + using BasicBlock = llvm::BasicBlock; BasicBlock *BB; public: @@ -590,7 +606,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; @@ -600,18 +616,18 @@ //===--------------------------------------------------------------------===// // The offending loop. - Loop *L; + llvm::Loop *L; // The non-affine loop bound. - const SCEV *LoopCount; + const llvm::SCEV *LoopCount; // A copy of the offending loop's debug location. - const DebugLoc Loc; + const llvm::DebugLoc Loc; public: - ReportLoopBound(Loop *L, const SCEV *LoopCount); + ReportLoopBound(llvm::Loop *L, const llvm::SCEV *LoopCount); - const SCEV *loopCount() { return LoopCount; } + const llvm::SCEV *loopCount() { return LoopCount; } /// @name LLVM-RTTI interface //@{ @@ -621,7 +637,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; virtual std::string getEndUserMessage() const override; //@} }; @@ -632,10 +648,10 @@ //===--------------------------------------------------------------------===// // The offending call instruction. - Instruction *Inst; + llvm::Instruction *Inst; public: - ReportFuncCall(Instruction *Inst); + ReportFuncCall(llvm::Instruction *Inst); /// @name LLVM-RTTI interface //@{ @@ -645,7 +661,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; virtual std::string getEndUserMessage() const override; //@} }; @@ -665,13 +681,14 @@ std::string formatInvalidAlias(std::string Prefix = "", std::string Suffix = "") const; - Instruction *Inst; + + llvm::Instruction *Inst; // A snapshot of the llvm values that took part in the aliasing error. mutable PointerSnapshotTy Pointers; public: - ReportAlias(Instruction *Inst, AliasSet &AS); + ReportAlias(llvm::Instruction *Inst, llvm::AliasSet &AS); const PointerSnapshotTy &getPointers() const { return Pointers; } @@ -683,7 +700,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; virtual std::string getEndUserMessage() const override; //@} }; @@ -730,10 +747,10 @@ //===--------------------------------------------------------------------===// // The offending base value. - Instruction *BaseValue; + llvm::Instruction *BaseValue; public: - ReportIntToPtr(Instruction *BaseValue); + ReportIntToPtr(llvm::Instruction *BaseValue); /// @name LLVM-RTTI interface //@{ @@ -743,7 +760,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; @@ -751,10 +768,10 @@ /// @brief Captures errors with alloca instructions. class ReportAlloca : public ReportOther { //===--------------------------------------------------------------------===// - Instruction *Inst; + llvm::Instruction *Inst; public: - ReportAlloca(Instruction *Inst); + ReportAlloca(llvm::Instruction *Inst); /// @name LLVM-RTTI interface //@{ @@ -764,7 +781,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; @@ -772,10 +789,10 @@ /// @brief Captures errors with unknown instructions. class ReportUnknownInst : public ReportOther { //===--------------------------------------------------------------------===// - Instruction *Inst; + llvm::Instruction *Inst; public: - ReportUnknownInst(Instruction *Inst); + ReportUnknownInst(llvm::Instruction *Inst); /// @name LLVM-RTTI interface //@{ @@ -785,7 +802,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; @@ -793,10 +810,10 @@ /// @brief Captures errors with phi nodes in exit BBs. class ReportPHIinExit : public ReportOther { //===--------------------------------------------------------------------===// - Instruction *Inst; + llvm::Instruction *Inst; public: - ReportPHIinExit(Instruction *Inst); + ReportPHIinExit(llvm::Instruction *Inst); /// @name LLVM-RTTI interface //@{ @@ -806,7 +823,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; @@ -814,10 +831,10 @@ /// @brief Captures errors with regions containing the function entry block. class ReportEntry : public ReportOther { //===--------------------------------------------------------------------===// - BasicBlock *BB; + llvm::BasicBlock *BB; public: - ReportEntry(BasicBlock *BB); + ReportEntry(llvm::BasicBlock *BB); /// @name LLVM-RTTI interface //@{ @@ -827,7 +844,7 @@ /// @name RejectReason interface //@{ virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; + virtual const llvm::DebugLoc &getDebugLoc() const override; //@} }; Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -26,8 +26,6 @@ #include "isl/ctx.h" -using namespace llvm; - namespace llvm { class Loop; class LoopInfo; @@ -66,6 +64,11 @@ /// the MemoryAccess access function. /// class ScopArrayInfo { + + using Type = llvm::Type; + using SCEV = llvm::SCEV; + using Value = llvm::Value; + public: /// @brief Construct a ScopArrayInfo object. /// @@ -74,7 +77,7 @@ /// @param IslCtx The isl context used to create the base pointer id. /// @param DimensionSizes A vector containing the size of each dimension. ScopArrayInfo(Value *BasePtr, Type *AccessType, isl_ctx *IslCtx, - const SmallVector &DimensionSizes); + const llvm::SmallVector &DimensionSizes); /// @brief Destructor to free the isl id of the base pointer. ~ScopArrayInfo(); @@ -101,7 +104,7 @@ void dump() const; /// @brief Print a readable representation to @p OS. - void print(raw_ostream &OS) const; + void print(llvm::raw_ostream &OS) const; /// @brief Access the ScopArrayInfo associated with an access function. static const ScopArrayInfo * @@ -121,11 +124,15 @@ isl_id *Id; /// @brief The sizes of each dimension. - SmallVector DimensionSizes; + llvm::SmallVector DimensionSizes; }; /// @brief Represent memory accesses in statements. class MemoryAccess { + + using Value =llvm::Value; + using Instruction = llvm::Instruction; + public: /// @brief The access type of a memory access /// @@ -341,7 +348,7 @@ /// @brief Print the MemoryAccess. /// /// @param OS The output stream the MemoryAccess is printed to. - void print(raw_ostream &OS) const; + void print(llvm::raw_ostream &OS) const; /// @brief Print the MemoryAccess to stderr. void dump() const; @@ -359,6 +366,13 @@ /// accesses. /// At the moment every statement represents a single basic block of LLVM-IR. class ScopStmt { + + using Region = llvm::Region; + using BasicBlock = llvm::BasicBlock; + using Loop = llvm::Loop; + using Instruction = llvm::Instruction; + using raw_ostream = llvm::raw_ostream; + //===-------------------------------------------------------------------===// ScopStmt(const ScopStmt &) = delete; const ScopStmt &operator=(const ScopStmt &) = delete; @@ -423,7 +437,7 @@ /// The memory accesses of this statement. /// /// The only side effects of a statement are its memory accesses. - typedef SmallVector MemoryAccessVec; + typedef llvm::SmallVector MemoryAccessVec; MemoryAccessVec MemAccs; std::map InstructionToAccess; @@ -460,7 +474,7 @@ __isl_give isl_set *addLoopBoundsToDomain(__isl_take isl_set *Domain, TempScop &tempScop); __isl_give isl_set *buildDomain(TempScop &tempScop, const Region &CurRegion); - void buildScattering(SmallVectorImpl &Scatter); + void buildScattering(llvm::SmallVectorImpl &Scatter); /// @brief Create the accesses for instructions in @p Block. /// @@ -509,20 +523,20 @@ /// result scanning for GEP[s] is imprecise. Even though this is not a /// correctness problem, this imprecision may result in missed optimizations /// or non-optimal run-time checks. - void deriveAssumptionsFromGEP(GetElementPtrInst *Inst); + void deriveAssumptionsFromGEP(llvm::GetElementPtrInst *Inst); /// @brief Scan @p Block and derive assumptions about parameter values. void deriveAssumptions(BasicBlock *Block); /// Create the ScopStmt from a BasicBlock. ScopStmt(Scop &parent, TempScop &tempScop, const Region &CurRegion, - BasicBlock &bb, SmallVectorImpl &NestLoops, - SmallVectorImpl &Scatter); + BasicBlock &bb, llvm::SmallVectorImpl &NestLoops, + llvm::SmallVectorImpl &Scatter); /// Create an overapproximating ScopStmt for the region @p R. ScopStmt(Scop &parent, TempScop &tempScop, const Region &CurRegion, Region &R, - SmallVectorImpl &NestLoops, - SmallVectorImpl &Scatter); + llvm::SmallVectorImpl &NestLoops, + llvm::SmallVectorImpl &Scatter); friend class Scop; @@ -643,7 +657,7 @@ }; /// @brief Print ScopStmt S to raw_ostream O. -static inline raw_ostream &operator<<(raw_ostream &O, const ScopStmt &S) { +static inline llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const ScopStmt &S) { S.print(O); return O; } @@ -667,21 +681,29 @@ /// This context contains information about the values the parameters /// can take and relations between different parameters. class Scop { + + using Region = llvm::Region; + using SCEV = llvm::SCEV; + using Value = llvm::Value; + using BasicBlock = llvm::BasicBlock; + using raw_ostream = llvm::raw_ostream; + using Loop = llvm::Loop; + public: /// @brief Type to represent a pair of minimal/maximal access to an array. using MinMaxAccessTy = std::pair; /// @brief Vector of minimal/maximal accesses to different arrays. - using MinMaxVectorTy = SmallVector; + using MinMaxVectorTy = llvm::SmallVector; /// @brief Vector of minimal/maximal access vectors one for each alias group. - using MinMaxVectorVectorTy = SmallVector; + using MinMaxVectorVectorTy = llvm::SmallVector; private: Scop(const Scop &) = delete; const Scop &operator=(const Scop &) = delete; - ScalarEvolution *SE; + llvm::ScalarEvolution *SE; /// The underlying Region. Region &R; @@ -697,7 +719,7 @@ StmtSet Stmts; /// Parameters of this Scop - typedef SmallVector ParamVecType; + typedef llvm::SmallVector ParamVecType; ParamVecType Parameters; /// The isl_ids that are used to represent the parameters @@ -708,13 +730,13 @@ isl_ctx *IslCtx; /// @brief A map from basic blocks to SCoP statements. - DenseMap StmtMap; + llvm::DenseMap StmtMap; /// Constraints on parameters. isl_set *Context; /// @brief A map to remember ScopArrayInfo objects for all base pointers. - DenseMap ScopArrayInfoMap; + llvm::DenseMap ScopArrayInfoMap; /// @brief The assumptions under which this scop was built. /// @@ -742,7 +764,7 @@ /// Create the static control part with a region, max loop depth of this /// region and parameters used in this region. - Scop(TempScop &TempScop, LoopInfo &LI, ScalarEvolution &SE, ScopDetection &SD, + Scop(TempScop &TempScop, llvm::LoopInfo &LI, llvm::ScalarEvolution &SE, ScopDetection &SD, isl_ctx *ctx); /// @brief Check if a basic block is trivial. @@ -777,15 +799,15 @@ /// @param NestLoops A vector of all surrounding loops. /// @param Scatter The position of the new statement as scattering. void addScopStmt(BasicBlock *BB, Region *R, TempScop &tempScop, - const Region &CurRegion, SmallVectorImpl &NestLoops, - SmallVectorImpl &Scatter); + const Region &CurRegion, llvm::SmallVectorImpl &NestLoops, + llvm::SmallVectorImpl &Scatter); /// Build the Scop and Statement with precalculated scop information. void buildScop(TempScop &TempScop, const Region &CurRegion, // Loops in Scop containing CurRegion - SmallVectorImpl &NestLoops, + llvm::SmallVectorImpl &NestLoops, // The scattering numbers - SmallVectorImpl &Scatter, LoopInfo &LI, + llvm::SmallVectorImpl &Scatter, llvm::LoopInfo &LI, ScopDetection &SD); /// @name Helper function for printing the Scop. @@ -801,7 +823,7 @@ public: ~Scop(); - ScalarEvolution *getSE() const; + llvm::ScalarEvolution *getSE() const; /// @brief Get the count of parameters used in this Scop. /// @@ -899,7 +921,7 @@ /// @brief Build all alias groups for this SCoP. /// /// @returns True if __no__ error occurred, false otherwise. - bool buildAliasGroups(AliasAnalysis &AA); + bool buildAliasGroups(llvm::AliasAnalysis &AA); //// @brief Drop all constant dimensions from statment schedules. /// @@ -948,8 +970,8 @@ /// @brief Return the (possibly new) ScopArrayInfo object for @p Access. const ScopArrayInfo * - getOrCreateScopArrayInfo(Value *BasePtr, Type *AccessType, - const SmallVector &Sizes); + getOrCreateScopArrayInfo(Value *BasePtr, llvm::Type *AccessType, + const llvm::SmallVector &Sizes); /// @brief Return the cached ScopArrayInfo object for @p BasePtr. const ScopArrayInfo *getScopArrayInfo(Value *BasePtr); @@ -997,7 +1019,7 @@ }; /// @brief Print Scop scop to raw_ostream O. -static inline raw_ostream &operator<<(raw_ostream &O, const Scop &scop) { +static inline llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const Scop &scop) { scop.print(O); return O; } @@ -1005,7 +1027,9 @@ ///===---------------------------------------------------------------------===// /// @brief Build the Polly IR (Scop and ScopStmt) on a Region. /// -class ScopInfo : public RegionPass { +class ScopInfo : public llvm::RegionPass { + using Region = llvm::Region; + //===-------------------------------------------------------------------===// ScopInfo(const ScopInfo &) = delete; const ScopInfo &operator=(const ScopInfo &) = delete; @@ -1037,10 +1061,10 @@ /// @name RegionPass interface //@{ - virtual bool runOnRegion(Region *R, RGPassManager &RGM); - virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual bool runOnRegion(Region *R, llvm::RGPassManager &RGM); + virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const; virtual void releaseMemory() { clear(); } - virtual void print(raw_ostream &OS, const Module *) const { + virtual void print(llvm::raw_ostream &OS, const llvm::Module *) const { if (scop) scop->print(OS); else @@ -1053,7 +1077,7 @@ namespace llvm { class PassRegistry; -void initializeScopInfoPass(llvm::PassRegistry &); +void initializeScopInfoPass(PassRegistry &); } #endif Index: include/polly/ScopPass.h =================================================================== --- include/polly/ScopPass.h +++ include/polly/ScopPass.h @@ -20,8 +20,6 @@ #include "llvm/Analysis/RegionPass.h" -using namespace llvm; - struct isl_ctx; namespace polly { @@ -30,7 +28,7 @@ /// ScopPass - This class adapts the RegionPass interface to allow convenient /// creation of passes that operate on the Polly IR. Instead of overriding /// runOnRegion, subclasses override runOnScop. -class ScopPass : public RegionPass { +class ScopPass : public llvm::RegionPass { Scop *S; protected: @@ -44,7 +42,7 @@ /// getAnalysisUsage - Subclasses that override getAnalysisUsage /// must call this. /// - virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const; public: Scop &getCurScop() const { @@ -53,11 +51,11 @@ } private: - virtual bool runOnRegion(Region *R, RGPassManager &RGM); - void print(raw_ostream &OS, const Module *) const; - virtual void printScop(raw_ostream &OS) const {} + virtual bool runOnRegion(llvm::Region *R, llvm::RGPassManager &RGM); + void print(llvm::raw_ostream &OS, const llvm::Module *) const; + virtual void printScop(llvm::raw_ostream &OS) const {} }; -} // End llvm namespace +} // End polly namespace #endif Index: include/polly/TempScopInfo.h =================================================================== --- include/polly/TempScopInfo.h +++ include/polly/TempScopInfo.h @@ -25,8 +25,6 @@ class DataLayout; } -using namespace llvm; - namespace polly { extern bool PollyDelinearize; @@ -34,6 +32,10 @@ //===---------------------------------------------------------------------===// /// @brief A memory access described by a SCEV expression and the access type. class IRAccess { + + using Value = llvm::Value; + using SCEV = llvm::SCEV; + public: Value *BaseAddress; @@ -52,6 +54,10 @@ bool IsAffine; public: + + template + using SmallVector = llvm::SmallVector; + SmallVector Subscripts, Sizes; explicit IRAccess(TypeKind Type, Value *BaseAddress, const SCEV *Offset, @@ -86,10 +92,14 @@ bool isScalar() const { return Subscripts.size() == 0; } - void print(raw_ostream &OS) const; + void print(llvm::raw_ostream &OS) const; }; class Comparison { + + using ICmpInst = llvm::ICmpInst; + using SCEV = llvm::SCEV; + const SCEV *LHS; const SCEV *RHS; @@ -103,13 +113,13 @@ const SCEV *getRHS() const { return RHS; } ICmpInst::Predicate getPred() const { return Pred; } - void print(raw_ostream &OS) const; + void print(llvm::raw_ostream &OS) const; }; //===---------------------------------------------------------------------===// /// Types // The condition of a Basicblock, combine brcond with "And" operator. -typedef SmallVector BBCond; +typedef llvm::SmallVector BBCond; /// Maps from a loop to the affine function expressing its backedge taken count. /// The backedge taken count already enough to express iteration domain as we @@ -117,13 +127,13 @@ /// A canonical induction variable is: /// an integer recurrence that starts at 0 and increments by one each time /// through the loop. -typedef std::map LoopBoundMapType; +typedef std::map LoopBoundMapType; /// Mapping BBs to its condition constrains -typedef std::map BBCondMapType; +typedef std::map BBCondMapType; -typedef std::vector> AccFuncSetType; -typedef std::map AccFuncMapType; +typedef std::vector> AccFuncSetType; +typedef std::map AccFuncMapType; //===---------------------------------------------------------------------===// /// @brief Scop represent with llvm objects. @@ -131,6 +141,13 @@ /// A helper class for remembering the parameter number and the max depth in /// this Scop, and others context. class TempScop { + + using ScalarEvolution = llvm::ScalarEvolution; + using LoopInfo = llvm::LoopInfo; + using Region = llvm::Region; + using BasicBlock = llvm::BasicBlock; + using raw_ostream = llvm::raw_ostream; + // The Region. Region &R; @@ -194,34 +211,36 @@ const Region *Reg, unsigned ind) const; }; -typedef std::map TempScopMapType; +typedef std::map TempScopMapType; //===----------------------------------------------------------------------===// /// @brief The Function Pass to extract temporary information for Static control /// part in llvm function. /// -class TempScopInfo : public FunctionPass { +class TempScopInfo : public llvm::FunctionPass { //===-------------------------------------------------------------------===// TempScopInfo(const TempScopInfo &) = delete; const TempScopInfo &operator=(const TempScopInfo &) = delete; + using Region = llvm::Region; + // The ScalarEvolution to help building Scop. - ScalarEvolution *SE; + llvm::ScalarEvolution *SE; // LoopInfo for information about loops - LoopInfo *LI; + llvm::LoopInfo *LI; // The AliasAnalysis to build AliasSetTracker. - AliasAnalysis *AA; + llvm::AliasAnalysis *AA; // Valid Regions for Scop ScopDetection *SD; // For condition extraction support. - DominatorTree *DT; - PostDominatorTree *PDT; + llvm::DominatorTree *DT; + llvm::PostDominatorTree *PDT; // Target data for element size computing. - const DataLayout *TD; + const llvm::DataLayout *TD; // And also Remember the constrains for BBs BBCondMapType BBConds; @@ -231,7 +250,7 @@ // Pre-created zero for the scalar accesses, with it we do not need create a // zero scev every time when we need it. - const SCEV *ZeroOffset; + const llvm::SCEV *ZeroOffset; // Mapping regions to the corresponding Scop in current function. TempScopMapType TempScops; @@ -243,10 +262,10 @@ /// /// @param BB The BasicBlock to build condition constrains /// @param R The region for the current TempScop. - void buildCondition(BasicBlock *BB, Region &R); + void buildCondition(llvm::BasicBlock *BB, Region &R); // Build the affine function of the given condition - void buildAffineCondition(Value &V, bool inverted, Comparison **Comp) const; + void buildAffineCondition(llvm::Value &V, bool inverted, Comparison **Comp) const; // Return the temporary Scop information of Region R, where R must be a valid // part of Scop @@ -264,7 +283,7 @@ /// /// @return The IRAccess to describe the access function of the /// instruction. - IRAccess buildIRAccess(Instruction *Inst, Loop *L, Region *R); + IRAccess buildIRAccess(llvm::Instruction *Inst, llvm::Loop *L, Region *R); /// @brief Analyze and extract the cross-BB scalar dependences (or, /// dataflow dependencies) of an instruction. @@ -274,16 +293,16 @@ /// /// @return True if the Instruction is used in other BB and a scalar write /// Access is required. - bool buildScalarDependences(Instruction *Inst, Region *R); + bool buildScalarDependences(llvm::Instruction *Inst, Region *R); /// @brief Create IRAccesses for the given PHI node in the given region. /// /// @param PHI The PHI node to be handled /// @param R The SCoP region /// @param Functions The access functions of the current BB - void buildPHIAccesses(PHINode *PHI, Region &R, AccFuncSetType &Functions); + void buildPHIAccesses(llvm::PHINode *PHI, Region &R, AccFuncSetType &Functions); - void buildAccessFunctions(Region &RefRegion, BasicBlock &BB); + void buildAccessFunctions(Region &RefRegion, llvm::BasicBlock &BB); public: static char ID; @@ -298,10 +317,10 @@ /// @name FunctionPass interface //@{ - virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const; virtual void releaseMemory() { clear(); } - virtual bool runOnFunction(Function &F); - virtual void print(raw_ostream &OS, const Module *) const; + virtual bool runOnFunction(llvm::Function &F); + virtual void print(llvm::raw_ostream &OS, const llvm::Module *) const; //@} }; Index: lib/Analysis/ScopDetectionDiagnostic.cpp =================================================================== --- lib/Analysis/ScopDetectionDiagnostic.cpp +++ lib/Analysis/ScopDetectionDiagnostic.cpp @@ -50,6 +50,8 @@ BADSCOP_STAT(SimpleLoop, "Loop not in -loop-simplify form"); BADSCOP_STAT(Other, "Others"); +using namespace llvm; + namespace polly { /// @brief Small string conversion via raw_string_stream. template std::string operator+(Twine LHS, const T &RHS) {