[llvm] [NewPM] LiveIntervals: Check dependencies for invalidation (PR #123563)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 03:31:36 PST 2025
https://github.com/optimisan updated https://github.com/llvm/llvm-project/pull/123563
>From 02db00b78f9cc653df87fd908bfa2f51b21c1f47 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Mon, 20 Jan 2025 06:35:48 +0000
Subject: [PATCH 1/2] [NewPM] LiveIntervals: Check dependencies for
invalidation
---
llvm/include/llvm/CodeGen/LiveIntervals.h | 3 +++
llvm/lib/CodeGen/LiveIntervals.cpp | 14 ++++++++++++++
2 files changed, 17 insertions(+)
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..64c184f5553ab2 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)
>From 1549605490723ee0514cfc5f1fdba5a03a11cf89 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Mon, 20 Jan 2025 11:30:44 +0000
Subject: [PATCH 2/2] remove parenthesis
---
llvm/lib/CodeGen/LiveIntervals.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index 64c184f5553ab2..4fdfcf547542d6 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -137,8 +137,8 @@ bool LiveIntervals::invalidate(
// LiveIntervals holds pointers to these results, so check for their
// invalidation.
- return (Inv.invalidate<SlotIndexesAnalysis>(MF, PA) ||
- Inv.invalidate<MachineDominatorTreeAnalysis>(MF, PA));
+ return Inv.invalidate<SlotIndexesAnalysis>(MF, PA) ||
+ Inv.invalidate<MachineDominatorTreeAnalysis>(MF, PA);
}
void LiveIntervals::clear() {
More information about the llvm-commits
mailing list