[PATCH] D111575: [NewPM] Add PipelineTuningOption to eagerly invalidate analyses
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 18 12:49:28 PDT 2021
aeubanks updated this revision to Diff 380499.
aeubanks added a comment.
Herald added a subscriber: dexonsmith.
make this affect all cgscc/module->function adaptors
just to simplify this change, now the flag isn't in PTO, it's just a global cl flag
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111575/new/
https://reviews.llvm.org/D111575
Files:
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/lib/IR/PassManager.cpp
llvm/test/Other/new-pm-eager-invalidate.ll
Index: llvm/test/Other/new-pm-eager-invalidate.ll
===================================================================
--- /dev/null
+++ llvm/test/Other/new-pm-eager-invalidate.ll
@@ -0,0 +1,8 @@
+; RUN: opt -disable-verify -debug-pass-manager -passes='function(require<no-op-function>)' -disable-output -eagerly-invalidate-analyses %s 2>&1 | FileCheck %s
+; RUN: opt -disable-verify -debug-pass-manager -passes='cgscc(function(require<no-op-function>))' -disable-output -eagerly-invalidate-analyses %s 2>&1 | FileCheck %s
+
+; CHECK: Invalidating analysis: NoOpFunctionAnalysis
+
+define void @foo() {
+ unreachable
+}
Index: llvm/lib/IR/PassManager.cpp
===================================================================
--- llvm/lib/IR/PassManager.cpp
+++ llvm/lib/IR/PassManager.cpp
@@ -10,12 +10,24 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/PassManagerImpl.h"
+#include "llvm/Support/CommandLine.h"
using namespace llvm;
+namespace llvm {
+// Experimental option to eagerly invalidate more analyses. This has the
+// potential to decrease max memory usage in exchange for more compile time.
+// This may affect codegen due to either passes using analyses only when
+// cached, or invalidating and recalculating an analysis that was
+// stale/imprecise but still valid. Currently this invalidates all function
+// analyses after a module->function or cgscc->function adaptor.
+// TODO: make this a PipelineTuningOption.
+cl::opt<bool> EagerlyInvalidateAnalyses(
+ "eagerly-invalidate-analyses", cl::init(false), cl::Hidden,
+ cl::desc("Eagerly invalidate more analyses in default pipelines"));
+
// Explicit template instantiations and specialization defininitions for core
// template typedefs.
-namespace llvm {
template class AllAnalysesOn<Module>;
template class AllAnalysesOn<Function>;
template class PassManager<Module>;
@@ -129,7 +141,8 @@
// We know that the function pass couldn't have invalidated any other
// function's analyses (that's the contract of a function pass), so
// directly handle the function analysis manager's invalidation here.
- FAM.invalidate(F, PassPA);
+ FAM.invalidate(F, EagerlyInvalidateAnalyses ? PreservedAnalyses::none()
+ : PassPA);
// Then intersect the preserved set so that invalidation of module
// analyses will eventually occur when the module pass completes.
Index: llvm/lib/Analysis/CGSCCPassManager.cpp
===================================================================
--- llvm/lib/Analysis/CGSCCPassManager.cpp
+++ llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -38,6 +38,7 @@
// Explicit template instantiations and specialization definitions for core
// template typedefs.
namespace llvm {
+extern cl::opt<bool> EagerlyInvalidateAnalyses;
static cl::opt<bool> AbortOnMaxDevirtIterationsReached(
"abort-on-max-devirt-iterations-reached",
@@ -556,7 +557,8 @@
// We know that the function pass couldn't have invalidated any other
// function's analyses (that's the contract of a function pass), so
// directly handle the function analysis manager's invalidation here.
- FAM.invalidate(F, PassPA);
+ FAM.invalidate(F, EagerlyInvalidateAnalyses ? PreservedAnalyses::none()
+ : PassPA);
// Then intersect the preserved set so that invalidation of module
// analyses will eventually occur when the module pass completes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111575.380499.patch
Type: text/x-patch
Size: 3500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211018/fdd32886/attachment.bin>
More information about the llvm-commits
mailing list