/// \param Allowed If not null, a set limiting the attribute opportunities.
/// \param DeleteFns Whether to delete functions.
/// \param RewriteSignatures Whether to rewrite function signatures.
+ /// \param MaxFixedPointIterations Maximum number of iterations to run until
+ /// fixpoint.
Attributor(SetVector<Function *> &Functions, InformationCache &InfoCache,
CallGraphUpdater &CGUpdater,
DenseSet<const char *> *Allowed = nullptr, bool DeleteFns = true,
: Allocator(InfoCache.Allocator), Functions(Functions),
InfoCache(InfoCache), CGUpdater(CGUpdater), Allowed(Allowed),
DeleteFns(DeleteFns), RewriteSignatures(RewriteSignatures),
- OREGetter(None), PassName("") {}
+ MaxFixpointIterations(None), OREGetter(None), PassName("") {}
/// Constructor
///
/// \param CGUpdater Helper to update an underlying call graph.
/// \param Allowed If not null, a set limiting the attribute opportunities.
/// \param DeleteFns Whether to delete functions
+ /// \param MaxFixedPointIterations Maximum number of iterations to run until
+ /// fixpoint.
/// \param OREGetter A callback function that returns an ORE object from a
/// Function pointer.
/// \param PassName The name of the pass emitting remarks.
Attributor(SetVector<Function *> &Functions, InformationCache &InfoCache,
CallGraphUpdater &CGUpdater, DenseSet<const char *> *Allowed,
bool DeleteFns, bool RewriteSignatures,
+ Optional<unsigned> MaxFixpointIterations,
OptimizationRemarkGetter OREGetter, const char *PassName)
: Allocator(InfoCache.Allocator), Functions(Functions),
InfoCache(InfoCache), CGUpdater(CGUpdater), Allowed(Allowed),
DeleteFns(DeleteFns), RewriteSignatures(RewriteSignatures),
+ MaxFixpointIterations(MaxFixpointIterations),
OREGetter(Optional<OptimizationRemarkGetter>(OREGetter)),
PassName(PassName) {}
/// Whether to rewrite signatures.
const bool RewriteSignatures;
+ /// Maximum number of fixedpoint iterations.
+ Optional<unsigned> MaxFixpointIterations;
+
/// A set to remember the functions we already assume to be live and visited.
DenseSet<const Function *> VisitedFunctions;
// This will become more evolved once we perform two interleaved fixpoint
// iterations: bottom-up and top-down.
static cl::opt<unsigned>
- MaxFixpointIterations("attributor-max-iterations", cl::Hidden,
+ SetFixpointIterations("attributor-max-iterations", cl::Hidden,
cl::desc("Maximal number of fixpoint iterations."),
cl::init(32));
// the abstract analysis.
unsigned IterationCounter = 1;
+ unsigned MaxFixedPointIterations;
+ if (MaxFixpointIterations)
+ MaxFixedPointIterations = MaxFixpointIterations.getValue();
+ else
+ MaxFixedPointIterations = SetFixpointIterations;
+
SmallVector<AbstractAttribute *, 32> ChangedAAs;
SetVector<AbstractAttribute *> Worklist, InvalidAAs;
Worklist.clear();
Worklist.insert(ChangedAAs.begin(), ChangedAAs.end());
- } while (!Worklist.empty() && (IterationCounter++ < MaxFixpointIterations ||
+ } while (!Worklist.empty() && (IterationCounter++ < MaxFixedPointIterations ||
VerifyMaxFixpointIterations));
LLVM_DEBUG(dbgs() << "\n[Attributor] Fixpoint iteration done after: "
});
if (VerifyMaxFixpointIterations &&
- IterationCounter != MaxFixpointIterations) {
+ IterationCounter != MaxFixedPointIterations) {
errs() << "\n[Attributor] Fixpoint iteration done after: "
- << IterationCounter << "/" << MaxFixpointIterations
+ << IterationCounter << "/" << MaxFixedPointIterations
<< " iterations\n";
llvm_unreachable("The fixpoint was not reached with exactly the number of "
"specified iterations!");
OMPInformationCache InfoCache(M, AG, Allocator, /*CGSCC*/ Functions,
OMPInModule.getKernels());
- Attributor A(Functions, InfoCache, CGUpdater, nullptr, true, false, OREGetter,
+ unsigned MaxFixponitIterations = (!OMPInModule.getKernels().empty()) ? 64 : 32;
+ Attributor A(Functions, InfoCache, CGUpdater, nullptr, true, false, MaxFixponitIterations, OREGetter,
DEBUG_TYPE);
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
OMPInformationCache InfoCache(*(Functions.back()->getParent()), AG, Allocator,
/*CGSCC*/ Functions, OMPInModule.getKernels());
- Attributor A(Functions, InfoCache, CGUpdater, nullptr, false, true, OREGetter,
+ unsigned MaxFixponitIterations = (!OMPInModule.getKernels().empty()) ? 64 : 32;
+ Attributor A(Functions, InfoCache, CGUpdater, nullptr, false, true, MaxFixponitIterations, OREGetter,
DEBUG_TYPE);
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
*(Functions.back()->getParent()), AG, Allocator,
/*CGSCC*/ Functions, OMPInModule.getKernels());
+ unsigned MaxFixponitIterations = (!OMPInModule.getKernels().empty()) ? 64 : 32;
Attributor A(Functions, InfoCache, CGUpdater, nullptr, false, true,
- OREGetter, DEBUG_TYPE);
+ MaxFixponitIterations, OREGetter, DEBUG_TYPE);
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
return OMPOpt.run(false);