Skip to content

Commit a9c61e0

Browse files
authored
[NewPM] LiveIntervals: Check dependencies for invalidation (#123563)
1 parent 3c79a04 commit a9c61e0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

llvm/include/llvm/CodeGen/LiveIntervals.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ class LiveIntervals {
113113
LiveIntervals(LiveIntervals &&) = default;
114114
~LiveIntervals();
115115

116+
bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA,
117+
MachineFunctionAnalysisManager::Invalidator &Inv);
118+
116119
/// Calculate the spill weight to assign to a single instruction.
117120
/// If \p PSI is provided the calculation is altered for optsize functions.
118121
static float getSpillWeight(bool isDef, bool isUse,

llvm/lib/CodeGen/LiveIntervals.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ LiveIntervalsWrapperPass::LiveIntervalsWrapperPass() : MachineFunctionPass(ID) {
127127

128128
LiveIntervals::~LiveIntervals() { clear(); }
129129

130+
bool LiveIntervals::invalidate(
131+
MachineFunction &MF, const PreservedAnalyses &PA,
132+
MachineFunctionAnalysisManager::Invalidator &Inv) {
133+
auto PAC = PA.getChecker<LiveIntervalsAnalysis>();
134+
135+
if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<MachineFunction>>())
136+
return true;
137+
138+
// LiveIntervals holds pointers to these results, so check for their
139+
// invalidation.
140+
return Inv.invalidate<SlotIndexesAnalysis>(MF, PA) ||
141+
Inv.invalidate<MachineDominatorTreeAnalysis>(MF, PA);
142+
}
143+
130144
void LiveIntervals::clear() {
131145
// Free the live intervals themselves.
132146
for (unsigned i = 0, e = VirtRegIntervals.size(); i != e; ++i)

0 commit comments

Comments
 (0)