From 756ac65987b84b7427c25d76f069a04a4a817a5c Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Wed, 23 Jul 2025 11:35:57 +0100 Subject: [CodeGen] Add a pass for testing finalizeBundle (#149813) This allows for unit testing of finalizeBundle with standard MIR tests using update_mir_test_checks.py. --- llvm/lib/CodeGen/MachineInstrBundle.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'llvm/lib/CodeGen/MachineInstrBundle.cpp') diff --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp index 34896c67144b..44b648ae65e8 100644 --- a/llvm/lib/CodeGen/MachineInstrBundle.cpp +++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp @@ -359,3 +359,13 @@ PhysRegInfo llvm::AnalyzePhysRegInBundle(const MachineInstr &MI, Register Reg, return PRI; } + +PreservedAnalyses +llvm::FinalizeBundleTestPass::run(MachineFunction &MF, + MachineFunctionAnalysisManager &) { + // For testing purposes, bundle the entire contents of each basic block + // except for terminators. + for (MachineBasicBlock &MBB : MF) + finalizeBundle(MBB, MBB.instr_begin(), MBB.getFirstInstrTerminator()); + return PreservedAnalyses::none(); +} -- cgit v1.2.3 From d449d3dc13daff388cbf6a7bb910e0511804eb84 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Wed, 23 Jul 2025 11:36:49 +0100 Subject: [CodeGen] Remove FinalizeMachineBundles pass (#149806) Replace its only use in the AMDGPU R600 backend with a call to finalizeBundles. --- llvm/lib/CodeGen/MachineInstrBundle.cpp | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'llvm/lib/CodeGen/MachineInstrBundle.cpp') diff --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp index 44b648ae65e8..4da0184a0cc7 100644 --- a/llvm/lib/CodeGen/MachineInstrBundle.cpp +++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp @@ -83,27 +83,6 @@ llvm::createUnpackMachineBundles( return new UnpackMachineBundles(std::move(Ftor)); } -namespace { - class FinalizeMachineBundles : public MachineFunctionPass { - public: - static char ID; // Pass identification - FinalizeMachineBundles() : MachineFunctionPass(ID) { - initializeFinalizeMachineBundlesPass(*PassRegistry::getPassRegistry()); - } - - bool runOnMachineFunction(MachineFunction &MF) override; - }; -} // end anonymous namespace - -char FinalizeMachineBundles::ID = 0; -char &llvm::FinalizeMachineBundlesID = FinalizeMachineBundles::ID; -INITIALIZE_PASS(FinalizeMachineBundles, "finalize-mi-bundles", - "Finalize machine instruction bundles", false, false) - -bool FinalizeMachineBundles::runOnMachineFunction(MachineFunction &MF) { - return llvm::finalizeBundles(MF); -} - /// Return the first found DebugLoc that has a DILocation, given a range of /// instructions. The search range is from FirstMI to LastMI (exclusive). If no /// DILocation is found, then an empty location is returned. -- cgit v1.2.3