[llvm] [MachineModuleInfo] add a grouping mechanism to defer deletion MF (PR #214525)
Diana Picus via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 00:58:09 PDT 2026
================
@@ -103,10 +103,31 @@ MachineFunction &MachineModuleInfo::getOrCreateMachineFunction(Function &F) {
return *MF;
}
+// When a function is not grouped with any other function, we can delete its
+// MachineFunction immediately. When a function is grouped with other functions,
+// we can only delete its MachineFunction when all functions in the same group
+// have been finalized.
void MachineModuleInfo::deleteMachineFunctionFor(Function &F) {
- MachineFunctions.erase(&F);
+ FinalizedMFs.insert(&F);
LastRequest = nullptr;
LastResult = nullptr;
+ auto Leader = MFDeletionGrouping.findLeader(&F);
+ if (Leader == MFDeletionGrouping.member_end()) {
----------------
rovka wrote:
Can you just do an `|| std::all_of(MFDeletionGrouping.members(Leader), lambda to check FinalizedMFs.count)` here?
https://github.com/llvm/llvm-project/pull/214525
More information about the llvm-commits
mailing list