[llvm] [NewPM] Adds a port for AArch64PostCoalescerPass (PR #189520)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 19:04:24 PDT 2026
================
@@ -100,6 +65,58 @@ bool AArch64PostCoalescer::runOnMachineFunction(MachineFunction &MF) {
return Changed;
}
+struct AArch64PostCoalescerLegacy : public MachineFunctionPass {
+ static char ID;
+
+ AArch64PostCoalescerLegacy() : MachineFunctionPass(ID) {}
+
+ bool runOnMachineFunction(MachineFunction &MF) override;
+
+ StringRef getPassName() const override {
+ return "AArch64 Post Coalescer pass";
+ }
+
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.setPreservesCFG();
+ AU.addRequired<LiveIntervalsWrapperPass>();
+ AU.addPreserved<LiveIntervalsWrapperPass>();
+ AU.addPreserved<SlotIndexesWrapperPass>();
+ MachineFunctionPass::getAnalysisUsage(AU);
+ }
+};
+
+char AArch64PostCoalescerLegacy::ID = 0;
+
+} // end anonymous namespace
+
+INITIALIZE_PASS_BEGIN(AArch64PostCoalescerLegacy, "aarch64-post-coalescer",
+ "AArch64 Post Coalescer Pass", false, false)
+INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
+INITIALIZE_PASS_END(AArch64PostCoalescerLegacy, "aarch64-post-coalescer",
+ "AArch64 Post Coalescer Pass", false, false)
+
+bool AArch64PostCoalescerLegacy::runOnMachineFunction(MachineFunction &MF) {
+ if (skipFunction(MF.getFunction()))
+ return false;
+
+ auto &LIS = getAnalysis<LiveIntervalsWrapperPass>().getLIS();
+ return runAArch64PostCoalescer(MF, LIS);
+}
+
+PreservedAnalyses
+AArch64PostCoalescerPass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ auto &LIS = MFAM.getResult<LiveIntervalsAnalysis>(MF);
+ const bool Changed = runAArch64PostCoalescer(MF, LIS);
+ if (!Changed)
+ return PreservedAnalyses::all();
+ PreservedAnalyses PA = getMachineFunctionPassPreservedAnalyses();
+ PA.preserveSet<CFGAnalyses>();
+ PA.preserve<LiveIntervalsAnalysis>();
+ PA.preserve<SlotIndexesAnalysis>();
----------------
boomanaiden154 wrote:
We should probably add a TODO here that eventually `SlotIndexes` should only invalidate itself if `LiveIntervals` is invalidated.
https://github.com/llvm/llvm-project/pull/189520
More information about the llvm-commits
mailing list