From ad84c6f657894d98bfb9f71a69574e4b24df6174 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Wed, 16 Feb 2022 11:56:25 -0600 Subject: [PATCH] [polly] Match function definitions and header declarations. NFC. Ensure that function definitions match their declrations in header files, even if they have no effect on linking. This includes 1. Both have the same __isl_* annotations 2. Both use the same type alias 3. Remove unused declarations that have no definition 4. Use explicit polly namespace qualifier for definitions; generally, the .cpp file should use at most an anon namespace region since only symbols declared in the header file can be accessed from other translation units anyway. For defintions that have been declared in the header file, the explicit namespace qualifier ensures that both match. --- polly/include/polly/CodeGen/IslAst.h | 3 -- polly/include/polly/ScopDetection.h | 13 --------- polly/include/polly/ScopInfo.h | 42 --------------------------- polly/lib/Analysis/DependenceInfo.cpp | 8 +++-- polly/lib/Analysis/ScopBuilder.cpp | 2 +- polly/lib/Analysis/ScopDetection.cpp | 3 +- polly/lib/CodeGen/BlockGenerators.cpp | 4 +-- polly/lib/CodeGen/IslExprBuilder.cpp | 4 +-- polly/lib/CodeGen/IslNodeBuilder.cpp | 8 ++--- polly/lib/Support/SCEVValidator.cpp | 41 +++++++++++++------------- polly/lib/Transform/DeLICM.cpp | 21 +++++++------- polly/lib/Transform/ForwardOpTree.cpp | 12 ++++---- 12 files changed, 54 insertions(+), 107 deletions(-) diff --git a/polly/include/polly/CodeGen/IslAst.h b/polly/include/polly/CodeGen/IslAst.h index bab4fce864a8..0dc947c07800 100644 --- a/polly/include/polly/CodeGen/IslAst.h +++ b/polly/include/polly/CodeGen/IslAst.h @@ -40,9 +40,6 @@ public: static IslAst create(Scop &Scop, const Dependences &D); - /// Print a source code representation of the program. - void pprint(raw_ostream &OS); - isl::ast_node getAst(); const std::shared_ptr getSharedIslCtx() const { return Ctx; } diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h index e1195c92b96e..578555f84f8c 100644 --- a/polly/include/polly/ScopDetection.h +++ b/polly/include/polly/ScopDetection.h @@ -408,16 +408,6 @@ private: /// @return True if the memory access is valid, false otherwise. bool isValidMemoryAccess(MemAccInst Inst, DetectionContext &Context) const; - /// Check if an instruction has any non trivial scalar dependencies as part of - /// a Scop. - /// - /// @param Inst The instruction to check. - /// @param RefRegion The region in respect to which we check the access - /// function. - /// - /// @return True if the instruction has scalar dependences, false otherwise. - bool hasScalarDependency(Instruction &Inst, Region &RefRegion) const; - /// Check if an instruction can be part of a Scop. /// /// @param Inst The instruction to check. @@ -562,9 +552,6 @@ public: /// Return the set of rejection causes for @p R. const RejectLog *lookupRejectionLog(const Region *R) const; - /// Return true if @p SubR is a non-affine subregion in @p ScopR. - bool isNonAffineSubRegion(const Region *SubR, const Region *ScopR) const; - /// Get a message why a region is invalid /// /// @param R The region for which we get the error message diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 9739e3310dac..84bf442e80a7 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1614,44 +1614,6 @@ public: /// Print ScopStmt S to raw_ostream OS. raw_ostream &operator<<(raw_ostream &OS, const ScopStmt &S); -/// Build the conditions sets for the branch condition @p Condition in -/// the @p Domain. -/// -/// This will fill @p ConditionSets with the conditions under which control -/// will be moved from @p TI to its successors. Hence, @p ConditionSets will -/// have as many elements as @p TI has successors. If @p TI is nullptr the -/// context under which @p Condition is true/false will be returned as the -/// new elements of @p ConditionSets. -bool buildConditionSets(Scop &S, BasicBlock *BB, Value *Condition, - Instruction *TI, Loop *L, __isl_keep isl_set *Domain, - DenseMap &InvalidDomainMap, - SmallVectorImpl<__isl_give isl_set *> &ConditionSets); - -/// Build condition sets for unsigned ICmpInst(s). -/// Special handling is required for unsigned operands to ensure that if -/// MSB (aka the Sign bit) is set for an operands in an unsigned ICmpInst -/// it should wrap around. -/// -/// @param IsStrictUpperBound holds information on the predicate relation -/// between TestVal and UpperBound, i.e, -/// TestVal < UpperBound OR TestVal <= UpperBound -__isl_give isl_set * -buildUnsignedConditionSets(Scop &S, BasicBlock *BB, Value *Condition, - __isl_keep isl_set *Domain, const SCEV *SCEV_TestVal, - const SCEV *SCEV_UpperBound, - DenseMap &InvalidDomainMap, - bool IsStrictUpperBound); - -/// Build the conditions sets for the terminator @p TI in the @p Domain. -/// -/// This will fill @p ConditionSets with the conditions under which control -/// will be moved from @p TI to its successors. Hence, @p ConditionSets will -/// have as many elements as @p TI has successors. -bool buildConditionSets(Scop &S, BasicBlock *BB, Instruction *TI, Loop *L, - __isl_keep isl_set *Domain, - DenseMap &InvalidDomainMap, - SmallVectorImpl<__isl_give isl_set *> &ConditionSets); - /// Static Control Part /// /// A Scop is the polyhedral representation of a control flow region detected @@ -1918,10 +1880,6 @@ private: //@} - /// Initialize this ScopBuilder. - void init(AAResults &AA, AssumptionCache &AC, DominatorTree &DT, - LoopInfo &LI); - /// Return the access for the base ptr of @p MA if any. MemoryAccess *lookupBasePtrAccess(MemoryAccess *MA); diff --git a/polly/lib/Analysis/DependenceInfo.cpp b/polly/lib/Analysis/DependenceInfo.cpp index b8798a1c761e..b9f1aae9ddf6 100644 --- a/polly/lib/Analysis/DependenceInfo.cpp +++ b/polly/lib/Analysis/DependenceInfo.cpp @@ -709,8 +709,9 @@ bool Dependences::isValidSchedule( // dimension, then the loop is parallel. The distance is zero in the current // dimension if it is a subset of a map with equal values for the current // dimension. -bool Dependences::isParallel(isl_union_map *Schedule, isl_union_map *Deps, - isl_pw_aff **MinDistancePtr) const { +bool Dependences::isParallel(__isl_keep isl_union_map *Schedule, + __isl_take isl_union_map *Deps, + __isl_give isl_pw_aff **MinDistancePtr) const { isl_set *Deltas, *Distance; isl_map *ScheduleDeps; unsigned Dimension; @@ -827,7 +828,8 @@ Dependences::getReductionDependences(MemoryAccess *MA) const { return isl_map_copy(ReductionDependences.lookup(MA)); } -void Dependences::setReductionDependences(MemoryAccess *MA, isl_map *D) { +void Dependences::setReductionDependences(MemoryAccess *MA, + __isl_take isl_map *D) { assert(ReductionDependences.count(MA) == 0 && "Reduction dependences set twice!"); ReductionDependences[MA] = D; diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp index d06d5b72b71c..e5c12f16b8e6 100644 --- a/polly/lib/Analysis/ScopBuilder.cpp +++ b/polly/lib/Analysis/ScopBuilder.cpp @@ -3611,7 +3611,7 @@ void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) { #endif } -ScopBuilder::ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA, +ScopBuilder::ScopBuilder(Region *R, AssumptionCache &AC, AAResults &AA, const DataLayout &DL, DominatorTree &DT, LoopInfo &LI, ScopDetection &SD, ScalarEvolution &SE, OptimizationRemarkEmitter &ORE) diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 8b3af67a596b..e62323a85c95 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -338,11 +338,12 @@ static bool doesStringMatchAnyRegex(StringRef Str, } return false; } + //===----------------------------------------------------------------------===// // ScopDetection. ScopDetection::ScopDetection(const DominatorTree &DT, ScalarEvolution &SE, - LoopInfo &LI, RegionInfo &RI, AliasAnalysis &AA, + LoopInfo &LI, RegionInfo &RI, AAResults &AA, OptimizationRemarkEmitter &ORE) : DT(DT), SE(SE), LI(LI), RI(RI), AA(AA), ORE(ORE) {} diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index e946c7ef960c..718e31117b1f 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -416,7 +416,7 @@ void BlockGenerator::removeDeadInstructions(BasicBlock *BB, ValueMapT &BBMap) { } void BlockGenerator::copyStmt(ScopStmt &Stmt, LoopToScevMapT <S, - isl_id_to_ast_expr *NewAccesses) { + __isl_keep isl_id_to_ast_expr *NewAccesses) { assert(Stmt.isBlockStmt() && "Only block statements can be copied by the block generator"); @@ -1453,7 +1453,7 @@ static BasicBlock *findExitDominator(DominatorTree &DT, Region *R) { } void RegionGenerator::copyStmt(ScopStmt &Stmt, LoopToScevMapT <S, - isl_id_to_ast_expr *IdToAstExp) { + __isl_keep isl_id_to_ast_expr *IdToAstExp) { assert(Stmt.isRegionStmt() && "Only region statements can be copied by the region generator"); diff --git a/polly/lib/CodeGen/IslExprBuilder.cpp b/polly/lib/CodeGen/IslExprBuilder.cpp index 4d1094cf3eff..37a9e070ce21 100644 --- a/polly/lib/CodeGen/IslExprBuilder.cpp +++ b/polly/lib/CodeGen/IslExprBuilder.cpp @@ -232,7 +232,7 @@ Value *IslExprBuilder::createOpNAry(__isl_take isl_ast_expr *Expr) { } std::pair -IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) { +IslExprBuilder::createAccessAddress(__isl_take isl_ast_expr *Expr) { assert(isl_ast_expr_get_type(Expr) == isl_ast_expr_op && "isl ast expression not of type isl_ast_op"); assert(isl_ast_expr_get_op_type(Expr) == isl_ast_op_access && @@ -343,7 +343,7 @@ IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) { return {Access, SAI->getElementType()}; } -Value *IslExprBuilder::createOpAccess(isl_ast_expr *Expr) { +Value *IslExprBuilder::createOpAccess(__isl_take isl_ast_expr *Expr) { auto Info = createAccessAddress(Expr); assert(Info.first && "Could not create op access address"); return Builder.CreateLoad(Info.second, Info.first, diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp index 77c6cd4cadbc..92d710f08878 100644 --- a/polly/lib/CodeGen/IslNodeBuilder.cpp +++ b/polly/lib/CodeGen/IslNodeBuilder.cpp @@ -1058,7 +1058,7 @@ void IslNodeBuilder::create(__isl_take isl_ast_node *Node) { llvm_unreachable("Unknown isl_ast_node type"); } -bool IslNodeBuilder::materializeValue(isl_id *Id) { +bool IslNodeBuilder::materializeValue(__isl_take isl_id *Id) { // If the Id is already mapped, skip it. if (!IDToValue.count(Id)) { auto *ParamSCEV = (const SCEV *)isl_id_get_user(Id); @@ -1122,7 +1122,7 @@ bool IslNodeBuilder::materializeValue(isl_id *Id) { return true; } -bool IslNodeBuilder::materializeParameters(isl_set *Set) { +bool IslNodeBuilder::materializeParameters(__isl_take isl_set *Set) { for (unsigned i = 0, e = isl_set_dim(Set, isl_dim_param); i < e; ++i) { if (!isl_set_involves_dims(Set, isl_dim_param, i, 1)) continue; @@ -1142,7 +1142,7 @@ bool IslNodeBuilder::materializeParameters() { return true; } -Value *IslNodeBuilder::preloadUnconditionally(isl_set *AccessRange, +Value *IslNodeBuilder::preloadUnconditionally(__isl_take isl_set *AccessRange, isl_ast_build *Build, Instruction *AccInst) { isl_pw_multi_aff *PWAccRel = isl_pw_multi_aff_from_set(AccessRange); @@ -1173,7 +1173,7 @@ Value *IslNodeBuilder::preloadUnconditionally(isl_set *AccessRange, } Value *IslNodeBuilder::preloadInvariantLoad(const MemoryAccess &MA, - isl_set *Domain) { + __isl_take isl_set *Domain) { isl_set *AccessRange = isl_map_range(MA.getAddressFunction().release()); AccessRange = isl_set_gist_params(AccessRange, S.getContext().release()); diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp index e2236fe1d2ac..2ca41c3ee46f 100644 --- a/polly/lib/Support/SCEVValidator.cpp +++ b/polly/lib/Support/SCEVValidator.cpp @@ -519,7 +519,6 @@ public: bool hasDependences() { return HasInRegionDeps; } }; -namespace polly { /// Find all loops referenced in SCEVAddRecExprs. class SCEVFindLoops { SetVector &Loops; @@ -535,7 +534,7 @@ public: bool isDone() { return false; } }; -void findLoops(const SCEV *Expr, SetVector &Loops) { +void polly::findLoops(const SCEV *Expr, SetVector &Loops) { SCEVFindLoops FindLoops(Loops); SCEVTraversal ST(FindLoops); ST.visitAll(Expr); @@ -576,24 +575,24 @@ public: bool isDone() { return false; } }; -void findValues(const SCEV *Expr, ScalarEvolution &SE, - SetVector &Values) { +void polly::findValues(const SCEV *Expr, ScalarEvolution &SE, + SetVector &Values) { SCEVFindValues FindValues(SE, Values); SCEVTraversal ST(FindValues); ST.visitAll(Expr); } -bool hasScalarDepsInsideRegion(const SCEV *Expr, const Region *R, - llvm::Loop *Scope, bool AllowLoops, - const InvariantLoadsSetTy &ILS) { +bool polly::hasScalarDepsInsideRegion(const SCEV *Expr, const Region *R, + llvm::Loop *Scope, bool AllowLoops, + const InvariantLoadsSetTy &ILS) { SCEVInRegionDependences InRegionDeps(R, Scope, AllowLoops, ILS); SCEVTraversal ST(InRegionDeps); ST.visitAll(Expr); return InRegionDeps.hasDependences(); } -bool isAffineExpr(const Region *R, llvm::Loop *Scope, const SCEV *Expr, - ScalarEvolution &SE, InvariantLoadsSetTy *ILS) { +bool polly::isAffineExpr(const Region *R, llvm::Loop *Scope, const SCEV *Expr, + ScalarEvolution &SE, InvariantLoadsSetTy *ILS) { if (isa(Expr)) return false; @@ -633,9 +632,9 @@ static bool isAffineExpr(Value *V, const Region *R, Loop *Scope, return true; } -bool isAffineConstraint(Value *V, const Region *R, llvm::Loop *Scope, - ScalarEvolution &SE, ParameterSetTy &Params, - bool OrExpr) { +bool polly::isAffineConstraint(Value *V, const Region *R, Loop *Scope, + ScalarEvolution &SE, ParameterSetTy &Params, + bool OrExpr) { if (auto *ICmp = dyn_cast(V)) { return isAffineConstraint(ICmp->getOperand(0), R, Scope, SE, Params, true) && @@ -653,11 +652,12 @@ bool isAffineConstraint(Value *V, const Region *R, llvm::Loop *Scope, if (!OrExpr) return false; - return isAffineExpr(V, R, Scope, SE, Params); + return ::isAffineExpr(V, R, Scope, SE, Params); } -ParameterSetTy getParamsInAffineExpr(const Region *R, Loop *Scope, - const SCEV *Expr, ScalarEvolution &SE) { +ParameterSetTy polly::getParamsInAffineExpr(const Region *R, Loop *Scope, + const SCEV *Expr, + ScalarEvolution &SE) { if (isa(Expr)) return ParameterSetTy(); @@ -670,7 +670,7 @@ ParameterSetTy getParamsInAffineExpr(const Region *R, Loop *Scope, } std::pair -extractConstantFactor(const SCEV *S, ScalarEvolution &SE) { +polly::extractConstantFactor(const SCEV *S, ScalarEvolution &SE) { auto *ConstPart = cast(SE.getConstant(S->getType(), 1)); if (auto *Constant = dyn_cast(S)) @@ -729,8 +729,9 @@ extractConstantFactor(const SCEV *S, ScalarEvolution &SE) { return std::make_pair(ConstPart, SE.getMulExpr(LeftOvers)); } -const SCEV *tryForwardThroughPHI(const SCEV *Expr, Region &R, - ScalarEvolution &SE, ScopDetection *SD) { +const SCEV *polly::tryForwardThroughPHI(const SCEV *Expr, Region &R, + ScalarEvolution &SE, + ScopDetection *SD) { if (auto *Unknown = dyn_cast(Expr)) { Value *V = Unknown->getValue(); auto *PHI = dyn_cast(V); @@ -754,7 +755,8 @@ const SCEV *tryForwardThroughPHI(const SCEV *Expr, Region &R, return Expr; } -Value *getUniqueNonErrorValue(PHINode *PHI, Region *R, ScopDetection *SD) { +Value *polly::getUniqueNonErrorValue(PHINode *PHI, Region *R, + ScopDetection *SD) { Value *V = nullptr; for (unsigned i = 0; i < PHI->getNumIncomingValues(); i++) { BasicBlock *BB = PHI->getIncomingBlock(i); @@ -767,4 +769,3 @@ Value *getUniqueNonErrorValue(PHINode *PHI, Region *R, ScopDetection *SD) { return V; } -} // namespace polly diff --git a/polly/lib/Transform/DeLICM.cpp b/polly/lib/Transform/DeLICM.cpp index d5a54cd7c705..ab41cafab996 100644 --- a/polly/lib/Transform/DeLICM.cpp +++ b/polly/lib/Transform/DeLICM.cpp @@ -1461,16 +1461,10 @@ char DeLICMWrapperPass::ID; Pass *polly::createDeLICMWrapperPass() { return new DeLICMWrapperPass(); } -INITIALIZE_PASS_BEGIN(DeLICMWrapperPass, "polly-delicm", "Polly - DeLICM/DePRE", - false, false) -INITIALIZE_PASS_DEPENDENCY(ScopInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) -INITIALIZE_PASS_END(DeLICMWrapperPass, "polly-delicm", "Polly - DeLICM/DePRE", - false, false) - -llvm::PreservedAnalyses DeLICMPass::run(Scop &S, ScopAnalysisManager &SAM, - ScopStandardAnalysisResults &SAR, - SPMUpdater &U) { +llvm::PreservedAnalyses polly::DeLICMPass::run(Scop &S, + ScopAnalysisManager &SAM, + ScopStandardAnalysisResults &SAR, + SPMUpdater &U) { return runDeLICMUsingNPM(S, SAM, SAR, U, nullptr); } @@ -1494,3 +1488,10 @@ bool polly::isConflicting( return Knowledge::isConflicting(Existing, Proposed, OS, Indent); } + +INITIALIZE_PASS_BEGIN(DeLICMWrapperPass, "polly-delicm", "Polly - DeLICM/DePRE", + false, false) +INITIALIZE_PASS_DEPENDENCY(ScopInfoWrapperPass) +INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) +INITIALIZE_PASS_END(DeLICMWrapperPass, "polly-delicm", "Polly - DeLICM/DePRE", + false, false) diff --git a/polly/lib/Transform/ForwardOpTree.cpp b/polly/lib/Transform/ForwardOpTree.cpp index b54683993e7e..dbe25c33d001 100644 --- a/polly/lib/Transform/ForwardOpTree.cpp +++ b/polly/lib/Transform/ForwardOpTree.cpp @@ -1149,12 +1149,6 @@ Pass *polly::createForwardOpTreeWrapperPass() { return new ForwardOpTreeWrapperPass(); } -INITIALIZE_PASS_BEGIN(ForwardOpTreeWrapperPass, "polly-optree", - "Polly - Forward operand tree", false, false) -INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) -INITIALIZE_PASS_END(ForwardOpTreeWrapperPass, "polly-optree", - "Polly - Forward operand tree", false, false) - llvm::PreservedAnalyses ForwardOpTreePass::run(Scop &S, ScopAnalysisManager &SAM, ScopStandardAnalysisResults &SAR, @@ -1167,3 +1161,9 @@ ForwardOpTreePrinterPass::run(Scop &S, ScopAnalysisManager &SAM, ScopStandardAnalysisResults &SAR, SPMUpdater &U) { return runForwardOpTreeUsingNPM(S, SAM, SAR, U, &OS); } + +INITIALIZE_PASS_BEGIN(ForwardOpTreeWrapperPass, "polly-optree", + "Polly - Forward operand tree", false, false) +INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) +INITIALIZE_PASS_END(ForwardOpTreeWrapperPass, "polly-optree", + "Polly - Forward operand tree", false, false)