[llvm] [NewPM] LiveIntervals: Check dependencies for invalidation (PR #123563)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 23 11:31:08 PST 2025


================
@@ -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));
+}
----------------
aeubanks wrote:

> Yes, it is related here [#123045 (comment)](https://github.com/llvm/llvm-project/pull/123045#issuecomment-2592793893)
> 
> New PM can't report such cases. Could add such a functionality behind a flag but I guess it's unlikely for more cases like this to exist, since they would lead to invalid reads (as the PM deletes the results).

I don't think it's easily trackable which analyses depend on other analyses without a bunch of extra infrastructure, so unless this is a problem that comes up a lot I'm inclined to say it's not worth the effort

https://github.com/llvm/llvm-project/pull/123563


More information about the llvm-commits mailing list