[llvm] a9c61e0 - [NewPM] LiveIntervals: Check dependencies for invalidation (#123563)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 21:53:50 PST 2025
Author: Akshat Oke
Date: 2025-01-24T11:23:46+05:30
New Revision: a9c61e0d7655a11f45f8e94b9481193fba11302e
URL: https://github.com/llvm/llvm-project/commit/a9c61e0d7655a11f45f8e94b9481193fba11302e
DIFF: https://github.com/llvm/llvm-project/commit/a9c61e0d7655a11f45f8e94b9481193fba11302e.diff
LOG: [NewPM] LiveIntervals: Check dependencies for invalidation (#123563)
Added:
Modified:
llvm/include/llvm/CodeGen/LiveIntervals.h
llvm/lib/CodeGen/LiveIntervals.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index 161bb247a0e968..540651ea114427 100644
--- a/llvm/include/llvm/CodeGen/LiveIntervals.h
+++ b/llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -113,6 +113,9 @@ class LiveIntervals {
LiveIntervals(LiveIntervals &&) = default;
~LiveIntervals();
+ bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA,
+ MachineFunctionAnalysisManager::Invalidator &Inv);
+
/// Calculate the spill weight to assign to a single instruction.
/// If \p PSI is provided the calculation is altered for optsize functions.
static float getSpillWeight(bool isDef, bool isUse,
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index f38527a3ce6a31..4fdfcf547542d6 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -127,6 +127,20 @@ LiveIntervalsWrapperPass::LiveIntervalsWrapperPass() : MachineFunctionPass(ID) {
LiveIntervals::~LiveIntervals() { clear(); }
+bool LiveIntervals::invalidate(
+ MachineFunction &MF, const PreservedAnalyses &PA,
+ MachineFunctionAnalysisManager::Invalidator &Inv) {
+ auto PAC = PA.getChecker<LiveIntervalsAnalysis>();
+
+ if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<MachineFunction>>())
+ return true;
+
+ // LiveIntervals holds pointers to these results, so check for their
+ // invalidation.
+ return Inv.invalidate<SlotIndexesAnalysis>(MF, PA) ||
+ Inv.invalidate<MachineDominatorTreeAnalysis>(MF, PA);
+}
+
void LiveIntervals::clear() {
// Free the live intervals themselves.
for (unsigned i = 0, e = VirtRegIntervals.size(); i != e; ++i)
More information about the llvm-commits
mailing list