diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -1087,14 +1087,17 @@ /// \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 &Functions, InformationCache &InfoCache, CallGraphUpdater &CGUpdater, DenseSet *Allowed = nullptr, bool DeleteFns = true, - bool RewriteSignatures = true) + bool RewriteSignatures = true, unsigned MaxFixpointIterations = 32) : Allocator(InfoCache.Allocator), Functions(Functions), InfoCache(InfoCache), CGUpdater(CGUpdater), Allowed(Allowed), DeleteFns(DeleteFns), RewriteSignatures(RewriteSignatures), - OREGetter(None), PassName("") {} + MaxFixpointIterations(MaxFixpointIterations), OREGetter(None), + PassName("") {} /// Constructor /// @@ -1107,13 +1110,17 @@ /// \param OREGetter A callback function that returns an ORE object from a /// Function pointer. /// \param PassName The name of the pass emitting remarks. + /// \param MaxFixedPointIterations Maximum number of iterations to run until + /// fixpoint. Attributor(SetVector &Functions, InformationCache &InfoCache, CallGraphUpdater &CGUpdater, DenseSet *Allowed, bool DeleteFns, bool RewriteSignatures, + 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(OREGetter)), PassName(PassName) {} @@ -1820,6 +1827,9 @@ /// Whether to rewrite signatures. const bool RewriteSignatures; + /// Maximum number of fixedpoint iterations. + unsigned MaxFixpointIterations; + /// A set to remember the functions we already assume to be live and visited. DenseSet VisitedFunctions; diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -76,9 +76,9 @@ // This will become more evolved once we perform two interleaved fixpoint // iterations: bottom-up and top-down. static cl::opt - MaxFixpointIterations("attributor-max-iterations", cl::Hidden, + OverrideFixpointIterations("attributor-max-iterations", cl::Hidden, cl::desc("Maximal number of fixpoint iterations."), - cl::init(32)); + cl::init(0)); static cl::opt MaxInitializationChainLengthX( "attributor-max-initialization-chain-length", cl::Hidden, @@ -1024,6 +1024,8 @@ // the abstract analysis. unsigned IterationCounter = 1; + if (OverrideFixpointIterations) + MaxFixpointIterations = OverrideFixpointIterations.getValue(); SmallVector ChangedAAs; SetVector Worklist, InvalidAAs; diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -2697,7 +2697,8 @@ 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); @@ -2753,7 +2754,8 @@ 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); @@ -2830,8 +2832,9 @@ *(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);