mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
[Attributor] Add an option to increase the max number of iterations
Right now the Attributor defaults to 32 fixed point iterations unless it is set explicitly by a command line flag. This patch allows this to be configured when the attributor instance is created. The maximum is then increased in OpenMPOpt if the target is a kernel. This is because the globalization analysis can result in larger iteration counts due to many dependent instances running at once. Depends on D102444 Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D104416
This commit is contained in:
parent
296b173595
commit
141815765c
@ -1090,6 +1090,8 @@ struct Attributor {
|
|||||||
/// \param Allowed If not null, a set limiting the attribute opportunities.
|
/// \param Allowed If not null, a set limiting the attribute opportunities.
|
||||||
/// \param DeleteFns Whether to delete functions.
|
/// \param DeleteFns Whether to delete functions.
|
||||||
/// \param RewriteSignatures Whether to rewrite function signatures.
|
/// \param RewriteSignatures Whether to rewrite function signatures.
|
||||||
|
/// \param MaxFixedPointIterations Maximum number of iterations to run until
|
||||||
|
/// fixpoint.
|
||||||
Attributor(SetVector<Function *> &Functions, InformationCache &InfoCache,
|
Attributor(SetVector<Function *> &Functions, InformationCache &InfoCache,
|
||||||
CallGraphUpdater &CGUpdater,
|
CallGraphUpdater &CGUpdater,
|
||||||
DenseSet<const char *> *Allowed = nullptr, bool DeleteFns = true,
|
DenseSet<const char *> *Allowed = nullptr, bool DeleteFns = true,
|
||||||
@ -1097,7 +1099,7 @@ struct Attributor {
|
|||||||
: Allocator(InfoCache.Allocator), Functions(Functions),
|
: Allocator(InfoCache.Allocator), Functions(Functions),
|
||||||
InfoCache(InfoCache), CGUpdater(CGUpdater), Allowed(Allowed),
|
InfoCache(InfoCache), CGUpdater(CGUpdater), Allowed(Allowed),
|
||||||
DeleteFns(DeleteFns), RewriteSignatures(RewriteSignatures),
|
DeleteFns(DeleteFns), RewriteSignatures(RewriteSignatures),
|
||||||
OREGetter(None), PassName("") {}
|
MaxFixpointIterations(None), OREGetter(None), PassName("") {}
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
@ -1107,16 +1109,20 @@ struct Attributor {
|
|||||||
/// \param CGUpdater Helper to update an underlying call graph.
|
/// \param CGUpdater Helper to update an underlying call graph.
|
||||||
/// \param Allowed If not null, a set limiting the attribute opportunities.
|
/// \param Allowed If not null, a set limiting the attribute opportunities.
|
||||||
/// \param DeleteFns Whether to delete functions
|
/// \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
|
/// \param OREGetter A callback function that returns an ORE object from a
|
||||||
/// Function pointer.
|
/// Function pointer.
|
||||||
/// \param PassName The name of the pass emitting remarks.
|
/// \param PassName The name of the pass emitting remarks.
|
||||||
Attributor(SetVector<Function *> &Functions, InformationCache &InfoCache,
|
Attributor(SetVector<Function *> &Functions, InformationCache &InfoCache,
|
||||||
CallGraphUpdater &CGUpdater, DenseSet<const char *> *Allowed,
|
CallGraphUpdater &CGUpdater, DenseSet<const char *> *Allowed,
|
||||||
bool DeleteFns, bool RewriteSignatures,
|
bool DeleteFns, bool RewriteSignatures,
|
||||||
|
Optional<unsigned> MaxFixpointIterations,
|
||||||
OptimizationRemarkGetter OREGetter, const char *PassName)
|
OptimizationRemarkGetter OREGetter, const char *PassName)
|
||||||
: Allocator(InfoCache.Allocator), Functions(Functions),
|
: Allocator(InfoCache.Allocator), Functions(Functions),
|
||||||
InfoCache(InfoCache), CGUpdater(CGUpdater), Allowed(Allowed),
|
InfoCache(InfoCache), CGUpdater(CGUpdater), Allowed(Allowed),
|
||||||
DeleteFns(DeleteFns), RewriteSignatures(RewriteSignatures),
|
DeleteFns(DeleteFns), RewriteSignatures(RewriteSignatures),
|
||||||
|
MaxFixpointIterations(MaxFixpointIterations),
|
||||||
OREGetter(Optional<OptimizationRemarkGetter>(OREGetter)),
|
OREGetter(Optional<OptimizationRemarkGetter>(OREGetter)),
|
||||||
PassName(PassName) {}
|
PassName(PassName) {}
|
||||||
|
|
||||||
@ -1859,6 +1865,9 @@ private:
|
|||||||
/// Whether to rewrite signatures.
|
/// Whether to rewrite signatures.
|
||||||
const bool RewriteSignatures;
|
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.
|
/// A set to remember the functions we already assume to be live and visited.
|
||||||
DenseSet<const Function *> VisitedFunctions;
|
DenseSet<const Function *> VisitedFunctions;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ STATISTIC(NumAttributesManifested,
|
|||||||
// This will become more evolved once we perform two interleaved fixpoint
|
// This will become more evolved once we perform two interleaved fixpoint
|
||||||
// iterations: bottom-up and top-down.
|
// iterations: bottom-up and top-down.
|
||||||
static cl::opt<unsigned>
|
static cl::opt<unsigned>
|
||||||
MaxFixpointIterations("attributor-max-iterations", cl::Hidden,
|
SetFixpointIterations("attributor-max-iterations", cl::Hidden,
|
||||||
cl::desc("Maximal number of fixpoint iterations."),
|
cl::desc("Maximal number of fixpoint iterations."),
|
||||||
cl::init(32));
|
cl::init(32));
|
||||||
|
|
||||||
@ -1069,6 +1069,12 @@ void Attributor::runTillFixpoint() {
|
|||||||
// the abstract analysis.
|
// the abstract analysis.
|
||||||
|
|
||||||
unsigned IterationCounter = 1;
|
unsigned IterationCounter = 1;
|
||||||
|
unsigned MaxFixedPointIterations;
|
||||||
|
if (MaxFixpointIterations)
|
||||||
|
MaxFixedPointIterations = MaxFixpointIterations.getValue();
|
||||||
|
else
|
||||||
|
MaxFixedPointIterations = SetFixpointIterations;
|
||||||
|
|
||||||
|
|
||||||
SmallVector<AbstractAttribute *, 32> ChangedAAs;
|
SmallVector<AbstractAttribute *, 32> ChangedAAs;
|
||||||
SetVector<AbstractAttribute *> Worklist, InvalidAAs;
|
SetVector<AbstractAttribute *> Worklist, InvalidAAs;
|
||||||
@ -1148,7 +1154,7 @@ void Attributor::runTillFixpoint() {
|
|||||||
Worklist.clear();
|
Worklist.clear();
|
||||||
Worklist.insert(ChangedAAs.begin(), ChangedAAs.end());
|
Worklist.insert(ChangedAAs.begin(), ChangedAAs.end());
|
||||||
|
|
||||||
} while (!Worklist.empty() && (IterationCounter++ < MaxFixpointIterations ||
|
} while (!Worklist.empty() && (IterationCounter++ < MaxFixedPointIterations ||
|
||||||
VerifyMaxFixpointIterations));
|
VerifyMaxFixpointIterations));
|
||||||
|
|
||||||
LLVM_DEBUG(dbgs() << "\n[Attributor] Fixpoint iteration done after: "
|
LLVM_DEBUG(dbgs() << "\n[Attributor] Fixpoint iteration done after: "
|
||||||
@ -1187,9 +1193,9 @@ void Attributor::runTillFixpoint() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (VerifyMaxFixpointIterations &&
|
if (VerifyMaxFixpointIterations &&
|
||||||
IterationCounter != MaxFixpointIterations) {
|
IterationCounter != MaxFixedPointIterations) {
|
||||||
errs() << "\n[Attributor] Fixpoint iteration done after: "
|
errs() << "\n[Attributor] Fixpoint iteration done after: "
|
||||||
<< IterationCounter << "/" << MaxFixpointIterations
|
<< IterationCounter << "/" << MaxFixedPointIterations
|
||||||
<< " iterations\n";
|
<< " iterations\n";
|
||||||
llvm_unreachable("The fixpoint was not reached with exactly the number of "
|
llvm_unreachable("The fixpoint was not reached with exactly the number of "
|
||||||
"specified iterations!");
|
"specified iterations!");
|
||||||
|
@ -2666,7 +2666,8 @@ PreservedAnalyses OpenMPOptPass::run(Module &M, ModuleAnalysisManager &AM) {
|
|||||||
OMPInformationCache InfoCache(M, AG, Allocator, /*CGSCC*/ Functions,
|
OMPInformationCache InfoCache(M, AG, Allocator, /*CGSCC*/ Functions,
|
||||||
OMPInModule.getKernels());
|
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);
|
DEBUG_TYPE);
|
||||||
|
|
||||||
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
|
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
|
||||||
@ -2722,7 +2723,8 @@ PreservedAnalyses OpenMPOptCGSCCPass::run(LazyCallGraph::SCC &C,
|
|||||||
OMPInformationCache InfoCache(*(Functions.back()->getParent()), AG, Allocator,
|
OMPInformationCache InfoCache(*(Functions.back()->getParent()), AG, Allocator,
|
||||||
/*CGSCC*/ Functions, OMPInModule.getKernels());
|
/*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);
|
DEBUG_TYPE);
|
||||||
|
|
||||||
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
|
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
|
||||||
@ -2799,8 +2801,9 @@ struct OpenMPOptCGSCCLegacyPass : public CallGraphSCCPass {
|
|||||||
*(Functions.back()->getParent()), AG, Allocator,
|
*(Functions.back()->getParent()), AG, Allocator,
|
||||||
/*CGSCC*/ Functions, OMPInModule.getKernels());
|
/*CGSCC*/ Functions, OMPInModule.getKernels());
|
||||||
|
|
||||||
|
unsigned MaxFixponitIterations = (!OMPInModule.getKernels().empty()) ? 64 : 32;
|
||||||
Attributor A(Functions, InfoCache, CGUpdater, nullptr, false, true,
|
Attributor A(Functions, InfoCache, CGUpdater, nullptr, false, true,
|
||||||
OREGetter, DEBUG_TYPE);
|
MaxFixponitIterations, OREGetter, DEBUG_TYPE);
|
||||||
|
|
||||||
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
|
OpenMPOpt OMPOpt(SCC, CGUpdater, OREGetter, InfoCache, A);
|
||||||
return OMPOpt.run(false);
|
return OMPOpt.run(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user