aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-04-14 21:41:27 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-06-22 18:20:56 +0000
commitbdd1243df58e60e85101c09001d9812a789b6bc4 (patch)
treea1ce621c7301dd47ba2ddc3b8eaa63b441389481 /contrib/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp
parent781624ca2d054430052c828ba8d2c2eaf2d733e7 (diff)
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp59
1 files changed, 22 insertions, 37 deletions
diff --git a/contrib/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp b/contrib/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp
index b2e7422bbf8b..2de19884014c 100644
--- a/contrib/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/contrib/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -8,7 +8,6 @@
#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/PriorityWorklist.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
@@ -30,6 +29,7 @@
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <iterator>
+#include <optional>
#define DEBUG_TYPE "cgscc"
@@ -84,11 +84,7 @@ PassManager<LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &,
if (!PI.runBeforePass(*Pass, *C))
continue;
- PreservedAnalyses PassPA;
- {
- TimeTraceScope TimeScope(Pass->name());
- PassPA = Pass->run(*C, AM, G, UR);
- }
+ PreservedAnalyses PassPA = Pass->run(*C, AM, G, UR);
if (UR.InvalidatedSCCs.count(C))
PI.runAfterPassInvalidated<LazyCallGraph::SCC>(*Pass, PassPA);
@@ -104,22 +100,23 @@ PassManager<LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &,
ResultFAMCP->updateFAM(FAM);
}
+ // Intersect the final preserved analyses to compute the aggregate
+ // preserved set for this pass manager.
+ PA.intersect(PassPA);
+
// If the CGSCC pass wasn't able to provide a valid updated SCC, the
// current SCC may simply need to be skipped if invalid.
if (UR.InvalidatedSCCs.count(C)) {
LLVM_DEBUG(dbgs() << "Skipping invalidated root or island SCC!\n");
break;
}
+
// Check that we didn't miss any update scenario.
assert(C->begin() != C->end() && "Cannot have an empty SCC!");
// Update the analysis manager as each pass runs and potentially
// invalidates analyses.
AM.invalidate(*C, PassPA);
-
- // Finally, we intersect the final preserved analyses to compute the
- // aggregate preserved set for this pass manager.
- PA.intersect(std::move(PassPA));
}
// Before we mark all of *this* SCC's analyses as preserved below, intersect
@@ -277,11 +274,7 @@ ModuleToPostOrderCGSCCPassAdaptor::run(Module &M, ModuleAnalysisManager &AM) {
if (!PI.runBeforePass<LazyCallGraph::SCC>(*Pass, *C))
continue;
- PreservedAnalyses PassPA;
- {
- TimeTraceScope TimeScope(Pass->name());
- PassPA = Pass->run(*C, CGAM, CG, UR);
- }
+ PreservedAnalyses PassPA = Pass->run(*C, CGAM, CG, UR);
if (UR.InvalidatedSCCs.count(C))
PI.runAfterPassInvalidated<LazyCallGraph::SCC>(*Pass, PassPA);
@@ -298,12 +291,20 @@ ModuleToPostOrderCGSCCPassAdaptor::run(Module &M, ModuleAnalysisManager &AM) {
FAM);
}
+ // Intersect with the cross-SCC preserved set to capture any
+ // cross-SCC invalidation.
+ UR.CrossSCCPA.intersect(PassPA);
+ // Intersect the preserved set so that invalidation of module
+ // analyses will eventually occur when the module pass completes.
+ PA.intersect(PassPA);
+
// If the CGSCC pass wasn't able to provide a valid updated SCC,
// the current SCC may simply need to be skipped if invalid.
if (UR.InvalidatedSCCs.count(C)) {
LLVM_DEBUG(dbgs() << "Skipping invalidated root or island SCC!\n");
break;
}
+
// Check that we didn't miss any update scenario.
assert(C->begin() != C->end() && "Cannot have an empty SCC!");
@@ -315,13 +316,6 @@ ModuleToPostOrderCGSCCPassAdaptor::run(Module &M, ModuleAnalysisManager &AM) {
// processed.
CGAM.invalidate(*C, PassPA);
- // Then intersect the preserved set so that invalidation of module
- // analyses will eventually occur when the module pass completes.
- // Also intersect with the cross-SCC preserved set to capture any
- // cross-SCC invalidation.
- UR.CrossSCCPA.intersect(PassPA);
- PA.intersect(std::move(PassPA));
-
// The pass may have restructured the call graph and refined the
// current SCC and/or RefSCC. We need to update our current SCC and
// RefSCC pointers to follow these. Also, when the current SCC is
@@ -419,12 +413,12 @@ PreservedAnalyses DevirtSCCRepeatedPass::run(LazyCallGraph::SCC &InitialC,
else
PI.runAfterPass<LazyCallGraph::SCC>(*Pass, *C, PassPA);
+ PA.intersect(PassPA);
+
// If the SCC structure has changed, bail immediately and let the outer
// CGSCC layer handle any iteration to reflect the refined structure.
- if (UR.UpdatedC && UR.UpdatedC != C) {
- PA.intersect(std::move(PassPA));
+ if (UR.UpdatedC && UR.UpdatedC != C)
break;
- }
// If the CGSCC pass wasn't able to provide a valid updated SCC, the
// current SCC may simply need to be skipped if invalid.
@@ -476,7 +470,6 @@ PreservedAnalyses DevirtSCCRepeatedPass::run(LazyCallGraph::SCC &InitialC,
}
if (!Devirt) {
- PA.intersect(std::move(PassPA));
break;
}
@@ -488,7 +481,6 @@ PreservedAnalyses DevirtSCCRepeatedPass::run(LazyCallGraph::SCC &InitialC,
dbgs() << "Found another devirtualization after hitting the max "
"number of repetitions ("
<< MaxIterations << ") on SCC: " << *C << "\n");
- PA.intersect(std::move(PassPA));
break;
}
@@ -502,8 +494,6 @@ PreservedAnalyses DevirtSCCRepeatedPass::run(LazyCallGraph::SCC &InitialC,
// Update the analysis manager with each run and intersect the total set
// of preserved analyses so we're ready to iterate.
AM.invalidate(*C, PassPA);
-
- PA.intersect(std::move(PassPA));
}
// Note that we don't add any preserved entries here unlike a more normal
@@ -548,12 +538,7 @@ PreservedAnalyses CGSCCToFunctionPassAdaptor::run(LazyCallGraph::SCC &C,
if (!PI.runBeforePass<Function>(*Pass, F))
continue;
- PreservedAnalyses PassPA;
- {
- TimeTraceScope TimeScope(Pass->name());
- PassPA = Pass->run(F, FAM);
- }
-
+ PreservedAnalyses PassPA = Pass->run(F, FAM);
PI.runAfterPass<Function>(*Pass, F, PassPA);
// We know that the function pass couldn't have invalidated any other
@@ -628,7 +613,7 @@ bool CGSCCAnalysisManagerModuleProxy::Result::invalidate(
G->buildRefSCCs();
for (auto &RC : G->postorder_ref_sccs())
for (auto &C : RC) {
- Optional<PreservedAnalyses> InnerPA;
+ std::optional<PreservedAnalyses> InnerPA;
// Check to see whether the preserved set needs to be adjusted based on
// module-level analysis invalidation triggering deferred invalidation
@@ -731,7 +716,7 @@ bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
// necessary.
for (LazyCallGraph::Node &N : C) {
Function &F = N.getFunction();
- Optional<PreservedAnalyses> FunctionPA;
+ std::optional<PreservedAnalyses> FunctionPA;
// Check to see whether the preserved set needs to be pruned based on
// SCC-level analysis invalidation that triggers deferred invalidation