[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.
This commit is contained in:
Michael Kruse 2022-02-16 11:56:25 -06:00
parent e027c00821
commit ad84c6f657
12 changed files with 54 additions and 107 deletions

View File

@ -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<isl_ctx> getSharedIslCtx() const { return Ctx; }

View File

@ -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

View File

@ -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<BasicBlock *, isl::set> &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<BasicBlock *, isl::set> &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<BasicBlock *, isl::set> &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);

View File

@ -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;

View File

@ -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)

View File

@ -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) {}

View File

@ -416,7 +416,7 @@ void BlockGenerator::removeDeadInstructions(BasicBlock *BB, ValueMapT &BBMap) {
}
void BlockGenerator::copyStmt(ScopStmt &Stmt, LoopToScevMapT &LTS,
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 &LTS,
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");

View File

@ -232,7 +232,7 @@ Value *IslExprBuilder::createOpNAry(__isl_take isl_ast_expr *Expr) {
}
std::pair<Value *, Type *>
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,

View File

@ -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());

View File

@ -519,7 +519,6 @@ public:
bool hasDependences() { return HasInRegionDeps; }
};
namespace polly {
/// Find all loops referenced in SCEVAddRecExprs.
class SCEVFindLoops {
SetVector<const Loop *> &Loops;
@ -535,7 +534,7 @@ public:
bool isDone() { return false; }
};
void findLoops(const SCEV *Expr, SetVector<const Loop *> &Loops) {
void polly::findLoops(const SCEV *Expr, SetVector<const Loop *> &Loops) {
SCEVFindLoops FindLoops(Loops);
SCEVTraversal<SCEVFindLoops> ST(FindLoops);
ST.visitAll(Expr);
@ -576,24 +575,24 @@ public:
bool isDone() { return false; }
};
void findValues(const SCEV *Expr, ScalarEvolution &SE,
SetVector<Value *> &Values) {
void polly::findValues(const SCEV *Expr, ScalarEvolution &SE,
SetVector<Value *> &Values) {
SCEVFindValues FindValues(SE, Values);
SCEVTraversal<SCEVFindValues> 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<SCEVInRegionDependences> 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<SCEVCouldNotCompute>(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<ICmpInst>(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<SCEVCouldNotCompute>(Expr))
return ParameterSetTy();
@ -670,7 +670,7 @@ ParameterSetTy getParamsInAffineExpr(const Region *R, Loop *Scope,
}
std::pair<const SCEVConstant *, const SCEV *>
extractConstantFactor(const SCEV *S, ScalarEvolution &SE) {
polly::extractConstantFactor(const SCEV *S, ScalarEvolution &SE) {
auto *ConstPart = cast<SCEVConstant>(SE.getConstant(S->getType(), 1));
if (auto *Constant = dyn_cast<SCEVConstant>(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<SCEVUnknown>(Expr)) {
Value *V = Unknown->getValue();
auto *PHI = dyn_cast<PHINode>(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

View File

@ -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)

View File

@ -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)