From 1b873e565eea97d02cdb2375c50ceea89a818e5b Mon Sep 17 00:00:00 2001 From: paperchalice Date: Wed, 17 Jul 2024 11:26:56 +0800 Subject: [PATCH] [CodeGen][NewPM] Port `phi-node-elimination` to new pass manager (#98867) - Add `PHIEliminationPass `. - Support new pass manager in `MachineBasicBlock:: SplitCriticalEdge ` --- llvm/include/llvm/CodeGen/MachineBasicBlock.h | 19 ++- llvm/include/llvm/CodeGen/PHIElimination.h | 24 ++++ llvm/include/llvm/Passes/CodeGenPassBuilder.h | 1 + .../llvm/Passes/MachinePassRegistry.def | 2 +- llvm/lib/CodeGen/MachineBasicBlock.cpp | 29 +++-- llvm/lib/CodeGen/PHIElimination.cpp | 118 ++++++++++++------ llvm/lib/Passes/PassBuilder.cpp | 1 + .../CodeGen/AArch64/PHIElimination-crash.mir | 3 + .../AArch64/PHIElimination-debugloc.mir | 4 + .../AMDGPU/phi-elimination-assertion.mir | 1 + .../CodeGen/AMDGPU/phi-elimination-end-cf.mir | 1 + .../CodeGen/AMDGPU/split-mbb-lis-subrange.mir | 1 + .../AMDGPU/stale-livevar-in-twoaddr-pass.mir | 1 + .../CodeGen/PowerPC/2013-07-01-PHIElimBug.mir | 1 + llvm/test/CodeGen/PowerPC/livevars-crash1.mir | 3 + llvm/test/CodeGen/PowerPC/livevars-crash2.mir | 3 + llvm/test/CodeGen/PowerPC/phi-eliminate.mir | 2 + .../CodeGen/PowerPC/two-address-crash.mir | 1 + llvm/test/CodeGen/Thumb2/phi_prevent_copy.mir | 1 + llvm/test/CodeGen/X86/callbr-asm-kill.mir | 1 + llvm/test/CodeGen/X86/phielim-undef.mir | 1 + 21 files changed, 168 insertions(+), 50 deletions(-) create mode 100644 llvm/include/llvm/CodeGen/PHIElimination.h diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h index 562d37ef32f5..b8153fd5d3fb 100644 --- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h +++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h @@ -43,6 +43,8 @@ class raw_ostream; class LiveIntervals; class TargetRegisterClass; class TargetRegisterInfo; +template class AnalysisManager; +using MachineFunctionAnalysisManager = AnalysisManager; // This structure uniquely identifies a basic block section. // Possible values are @@ -968,7 +970,16 @@ public: /// MachineLoopInfo, as applicable. MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, - std::vector> *LiveInSets = nullptr); + std::vector> *LiveInSets = nullptr) { + return SplitCriticalEdge(Succ, &P, nullptr, LiveInSets); + } + + MachineBasicBlock * + SplitCriticalEdge(MachineBasicBlock *Succ, + MachineFunctionAnalysisManager &MFAM, + std::vector> *LiveInSets = nullptr) { + return SplitCriticalEdge(Succ, nullptr, &MFAM, LiveInSets); + } /// Check if the edge between this block and the given successor \p /// Succ, can be split. If this returns true a subsequent call to @@ -1243,6 +1254,12 @@ private: /// unless you know what you're doing, because it doesn't update Pred's /// successors list. Use Pred->removeSuccessor instead. void removePredecessor(MachineBasicBlock *Pred); + + // Helper method for new pass manager migration. + MachineBasicBlock * + SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P, + MachineFunctionAnalysisManager *MFAM, + std::vector> *LiveInSets); }; raw_ostream& operator<<(raw_ostream &OS, const MachineBasicBlock &MBB); diff --git a/llvm/include/llvm/CodeGen/PHIElimination.h b/llvm/include/llvm/CodeGen/PHIElimination.h new file mode 100644 index 000000000000..3a1a4c5c6133 --- /dev/null +++ b/llvm/include/llvm/CodeGen/PHIElimination.h @@ -0,0 +1,24 @@ +//===- llvm/CodeGen/PHIElimination.h ----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_PHIELIMINATION_H +#define LLVM_CODEGEN_PHIELIMINATION_H + +#include "llvm/CodeGen/MachinePassManager.h" + +namespace llvm { + +class PHIEliminationPass : public PassInfoMixin { +public: + PreservedAnalyses run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM); +}; + +} // namespace llvm + +#endif // LLVM_CODEGEN_PHIELIMINATION_H diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h index 5b8e69b602e2..fb7a3c107d88 100644 --- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h +++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h @@ -43,6 +43,7 @@ #include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachinePassManager.h" +#include "llvm/CodeGen/PHIElimination.h" #include "llvm/CodeGen/PreISelIntrinsicLowering.h" #include "llvm/CodeGen/RegAllocFast.h" #include "llvm/CodeGen/ReplaceWithVeclib.h" diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def index a47d7494f2ee..03f0782de6fe 100644 --- a/llvm/include/llvm/Passes/MachinePassRegistry.def +++ b/llvm/include/llvm/Passes/MachinePassRegistry.def @@ -132,6 +132,7 @@ MACHINE_FUNCTION_PASS("dead-mi-elimination", DeadMachineInstructionElimPass()) MACHINE_FUNCTION_PASS("finalize-isel", FinalizeISelPass()) MACHINE_FUNCTION_PASS("localstackalloc", LocalStackSlotAllocationPass()) MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass()) +MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass()) MACHINE_FUNCTION_PASS("print", PrintMIRPass()) MACHINE_FUNCTION_PASS("print", LiveIntervalsPrinterPass(dbgs())) MACHINE_FUNCTION_PASS("print", LiveVariablesPrinterPass(dbgs())) @@ -231,7 +232,6 @@ DUMMY_MACHINE_FUNCTION_PASS("mirfs-discriminators", MIRAddFSDiscriminatorsPass) DUMMY_MACHINE_FUNCTION_PASS("opt-phis", OptimizePHIsPass) DUMMY_MACHINE_FUNCTION_PASS("patchable-function", PatchableFunctionPass) DUMMY_MACHINE_FUNCTION_PASS("peephole-opt", PeepholeOptimizerPass) -DUMMY_MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass) DUMMY_MACHINE_FUNCTION_PASS("post-RA-sched", PostRASchedulerPass) DUMMY_MACHINE_FUNCTION_PASS("postmisched", PostMachineSchedulerPass) DUMMY_MACHINE_FUNCTION_PASS("postra-machine-sink", PostRAMachineSinkingPass) diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 90d2edebedd7..d681d00b5d8c 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -1135,9 +1135,19 @@ public: } }; +#define GET_RESULT(RESULT, GETTER, INFIX) \ + [MF, P, MFAM]() { \ + if (P) { \ + auto *Wrapper = P->getAnalysisIfAvailable(); \ + return Wrapper ? &Wrapper->GETTER() : nullptr; \ + } \ + return MFAM->getCachedResult(*MF); \ + }() + MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge( - MachineBasicBlock *Succ, Pass &P, + MachineBasicBlock *Succ, Pass *P, MachineFunctionAnalysisManager *MFAM, std::vector> *LiveInSets) { + assert((P || MFAM) && "Need a way to get analysis results!"); if (!canSplitCriticalEdge(Succ)) return nullptr; @@ -1161,10 +1171,8 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge( << " -- " << printMBBReference(*NMBB) << " -- " << printMBBReference(*Succ) << '\n'); - auto *LISWrapper = P.getAnalysisIfAvailable(); - LiveIntervals *LIS = LISWrapper ? &LISWrapper->getLIS() : nullptr; - auto *SIWrapper = P.getAnalysisIfAvailable(); - SlotIndexes *Indexes = SIWrapper ? &SIWrapper->getSI() : nullptr; + LiveIntervals *LIS = GET_RESULT(LiveIntervals, getLIS, ); + SlotIndexes *Indexes = GET_RESULT(SlotIndexes, getSI, ); if (LIS) LIS->insertMBBInMaps(NMBB); else if (Indexes) @@ -1173,8 +1181,7 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge( // On some targets like Mips, branches may kill virtual registers. Make sure // that LiveVariables is properly updated after updateTerminator replaces the // terminators. - auto *LVWrapper = P.getAnalysisIfAvailable(); - LiveVariables *LV = LVWrapper ? &LVWrapper->getLV() : nullptr; + LiveVariables *LV = GET_RESULT(LiveVariables, getLV, ); // Collect a list of virtual registers killed by the terminators. SmallVector KilledRegs; @@ -1339,12 +1346,10 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge( LIS->repairIntervalsInRange(this, getFirstTerminator(), end(), UsedRegs); } - if (auto *MDTWrapper = - P.getAnalysisIfAvailable()) - MDTWrapper->getDomTree().recordSplitCriticalEdge(this, Succ, NMBB); + if (auto *MDT = GET_RESULT(MachineDominatorTree, getDomTree, )) + MDT->recordSplitCriticalEdge(this, Succ, NMBB); - auto *MLIWrapper = P.getAnalysisIfAvailable(); - if (MachineLoopInfo *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr) + if (MachineLoopInfo *MLI = GET_RESULT(MachineLoop, getLI, Info)) if (MachineLoop *TIL = MLI->getLoopFor(this)) { // If one or the other blocks were not in a loop, the new block is not // either, and thus LI doesn't need to be updated. diff --git a/llvm/lib/CodeGen/PHIElimination.cpp b/llvm/lib/CodeGen/PHIElimination.cpp index e392bb808732..e5f40771eda8 100644 --- a/llvm/lib/CodeGen/PHIElimination.cpp +++ b/llvm/lib/CodeGen/PHIElimination.cpp @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/CodeGen/PHIElimination.h" #include "PHIEliminationUtils.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" @@ -64,22 +65,13 @@ static cl::opt NoPhiElimLiveOutEarlyExit( namespace { -class PHIElimination : public MachineFunctionPass { +class PHIEliminationImpl { MachineRegisterInfo *MRI = nullptr; // Machine register information LiveVariables *LV = nullptr; LiveIntervals *LIS = nullptr; + MachineLoopInfo *MLI = nullptr; + MachineDominatorTree *MDT = nullptr; -public: - static char ID; // Pass identification, replacement for typeid - - PHIElimination() : MachineFunctionPass(ID) { - initializePHIEliminationPass(*PassRegistry::getPassRegistry()); - } - - bool runOnMachineFunction(MachineFunction &MF) override; - void getAnalysisUsage(AnalysisUsage &AU) const override; - -private: /// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions /// in predecessor basic blocks. bool EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB); @@ -118,10 +110,71 @@ private: using LoweredPHIMap = DenseMap; LoweredPHIMap LoweredPHIs; + + MachineFunctionPass *P = nullptr; + MachineFunctionAnalysisManager *MFAM = nullptr; + +public: + PHIEliminationImpl(MachineFunctionPass *P) : P(P) { + auto *LVWrapper = P->getAnalysisIfAvailable(); + auto *LISWrapper = P->getAnalysisIfAvailable(); + auto *MLIWrapper = P->getAnalysisIfAvailable(); + auto *MDTWrapper = + P->getAnalysisIfAvailable(); + LV = LVWrapper ? &LVWrapper->getLV() : nullptr; + LIS = LISWrapper ? &LISWrapper->getLIS() : nullptr; + MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr; + MDT = MDTWrapper ? &MDTWrapper->getDomTree() : nullptr; + } + + PHIEliminationImpl(MachineFunction &MF, MachineFunctionAnalysisManager &AM) + : LV(AM.getCachedResult(MF)), + LIS(AM.getCachedResult(MF)), + MLI(AM.getCachedResult(MF)), + MDT(AM.getCachedResult(MF)), MFAM(&AM) {} + + bool run(MachineFunction &MF); +}; + +class PHIElimination : public MachineFunctionPass { +public: + static char ID; // Pass identification, replacement for typeid + + PHIElimination() : MachineFunctionPass(ID) { + initializePHIEliminationPass(*PassRegistry::getPassRegistry()); + } + + bool runOnMachineFunction(MachineFunction &MF) override { + PHIEliminationImpl Impl(this); + return Impl.run(MF); + } + + MachineFunctionProperties getSetProperties() const override { + return MachineFunctionProperties().set( + MachineFunctionProperties::Property::NoPHIs); + } + + void getAnalysisUsage(AnalysisUsage &AU) const override; }; } // end anonymous namespace +PreservedAnalyses +PHIEliminationPass::run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM) { + PHIEliminationImpl Impl(MF, MFAM); + bool Changed = Impl.run(MF); + if (!Changed) + return PreservedAnalyses::all(); + auto PA = getMachineFunctionPassPreservedAnalyses(); + PA.preserve(); + PA.preserve(); + PA.preserve(); + PA.preserve(); + PA.preserve(); + return PA; +} + STATISTIC(NumLowered, "Number of phis lowered"); STATISTIC(NumCriticalEdgesSplit, "Number of critical edges split"); STATISTIC(NumReused, "Number of reused lowered phis"); @@ -147,12 +200,8 @@ void PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const { MachineFunctionPass::getAnalysisUsage(AU); } -bool PHIElimination::runOnMachineFunction(MachineFunction &MF) { +bool PHIEliminationImpl::run(MachineFunction &MF) { MRI = &MF.getRegInfo(); - auto *LVWrapper = getAnalysisIfAvailable(); - LV = LVWrapper ? &LVWrapper->getLV() : nullptr; - auto *LISWrapper = getAnalysisIfAvailable(); - LIS = LISWrapper ? &LISWrapper->getLIS() : nullptr; bool Changed = false; @@ -187,9 +236,6 @@ bool PHIElimination::runOnMachineFunction(MachineFunction &MF) { } } - MachineLoopInfoWrapperPass *MLIWrapper = - getAnalysisIfAvailable(); - MachineLoopInfo *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr; for (auto &MBB : MF) Changed |= SplitPHIEdges(MF, MBB, MLI, (LV ? &LiveInSets : nullptr)); } @@ -223,9 +269,8 @@ bool PHIElimination::runOnMachineFunction(MachineFunction &MF) { } // TODO: we should use the incremental DomTree updater here. - if (Changed) - if (auto *MDT = getAnalysisIfAvailable()) - MDT->getDomTree().getBase().recalculate(MF); + if (Changed && MDT) + MDT->getBase().recalculate(MF); LoweredPHIs.clear(); ImpDefs.clear(); @@ -238,8 +283,8 @@ bool PHIElimination::runOnMachineFunction(MachineFunction &MF) { /// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions in /// predecessor basic blocks. -bool PHIElimination::EliminatePHINodes(MachineFunction &MF, - MachineBasicBlock &MBB) { +bool PHIEliminationImpl::EliminatePHINodes(MachineFunction &MF, + MachineBasicBlock &MBB) { if (MBB.empty() || !MBB.front().isPHI()) return false; // Quick exit for basic blocks without PHIs. @@ -286,9 +331,9 @@ static bool allPhiOperandsUndefined(const MachineInstr &MPhi, return true; } /// LowerPHINode - Lower the PHI node at the top of the specified block. -void PHIElimination::LowerPHINode(MachineBasicBlock &MBB, - MachineBasicBlock::iterator LastPHIIt, - bool AllEdgesCritical) { +void PHIEliminationImpl::LowerPHINode(MachineBasicBlock &MBB, + MachineBasicBlock::iterator LastPHIIt, + bool AllEdgesCritical) { ++NumLowered; MachineBasicBlock::iterator AfterPHIsIt = std::next(LastPHIIt); @@ -689,7 +734,7 @@ void PHIElimination::LowerPHINode(MachineBasicBlock &MBB, /// particular, we want to map the number of uses of a virtual register which is /// used in a PHI node. We map that to the BB the vreg is coming from. This is /// used later to determine when the vreg is killed in the BB. -void PHIElimination::analyzePHINodes(const MachineFunction &MF) { +void PHIEliminationImpl::analyzePHINodes(const MachineFunction &MF) { for (const auto &MBB : MF) { for (const auto &BBI : MBB) { if (!BBI.isPHI()) @@ -705,9 +750,9 @@ void PHIElimination::analyzePHINodes(const MachineFunction &MF) { } } -bool PHIElimination::SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB, - MachineLoopInfo *MLI, - std::vector> *LiveInSets) { +bool PHIEliminationImpl::SplitPHIEdges( + MachineFunction &MF, MachineBasicBlock &MBB, MachineLoopInfo *MLI, + std::vector> *LiveInSets) { if (MBB.empty() || !MBB.front().isPHI() || MBB.isEHPad()) return false; // Quick exit for basic blocks without PHIs. @@ -774,7 +819,8 @@ bool PHIElimination::SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB, } if (!ShouldSplit && !SplitAllCriticalEdges) continue; - if (!PreMBB->SplitCriticalEdge(&MBB, *this, LiveInSets)) { + if (!(P ? PreMBB->SplitCriticalEdge(&MBB, *P, LiveInSets) + : PreMBB->SplitCriticalEdge(&MBB, *MFAM, LiveInSets))) { LLVM_DEBUG(dbgs() << "Failed to split critical edge.\n"); continue; } @@ -785,7 +831,7 @@ bool PHIElimination::SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB, return Changed; } -bool PHIElimination::isLiveIn(Register Reg, const MachineBasicBlock *MBB) { +bool PHIEliminationImpl::isLiveIn(Register Reg, const MachineBasicBlock *MBB) { assert((LV || LIS) && "isLiveIn() requires either LiveVariables or LiveIntervals"); if (LIS) @@ -794,8 +840,8 @@ bool PHIElimination::isLiveIn(Register Reg, const MachineBasicBlock *MBB) { return LV->isLiveIn(Reg, *MBB); } -bool PHIElimination::isLiveOutPastPHIs(Register Reg, - const MachineBasicBlock *MBB) { +bool PHIEliminationImpl::isLiveOutPastPHIs(Register Reg, + const MachineBasicBlock *MBB) { assert((LV || LIS) && "isLiveOutPastPHIs() requires either LiveVariables or LiveIntervals"); // LiveVariables considers uses in PHIs to be in the predecessor basic block, diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 929690c2c74d..a9d3f8ec3a4e 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -105,6 +105,7 @@ #include "llvm/CodeGen/MachinePostDominators.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/MachineVerifier.h" +#include "llvm/CodeGen/PHIElimination.h" #include "llvm/CodeGen/PreISelIntrinsicLowering.h" #include "llvm/CodeGen/RegAllocFast.h" #include "llvm/CodeGen/SafeStack.h" diff --git a/llvm/test/CodeGen/AArch64/PHIElimination-crash.mir b/llvm/test/CodeGen/AArch64/PHIElimination-crash.mir index 1a1ba154062b..8f4368642926 100644 --- a/llvm/test/CodeGen/AArch64/PHIElimination-crash.mir +++ b/llvm/test/CodeGen/AArch64/PHIElimination-crash.mir @@ -1,6 +1,9 @@ # RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o /dev/null %s \ # RUN: -run-pass=livevars,phi-node-elimination,twoaddressinstruction \ # RUN: -no-phi-elim-live-out-early-exit=1 -phi-elim-split-all-critical-edges=1 +# RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o /dev/null %s \ +# RUN: --passes='require,phi-node-elimination,two-address-instruction' \ +# RUN: -no-phi-elim-live-out-early-exit=1 -phi-elim-split-all-critical-edges=1 # Used to result in # diff --git a/llvm/test/CodeGen/AArch64/PHIElimination-debugloc.mir b/llvm/test/CodeGen/AArch64/PHIElimination-debugloc.mir index 61101491e9d9..9b8283352161 100644 --- a/llvm/test/CodeGen/AArch64/PHIElimination-debugloc.mir +++ b/llvm/test/CodeGen/AArch64/PHIElimination-debugloc.mir @@ -2,6 +2,10 @@ # RUN: -run-pass=livevars,phi-node-elimination,twoaddressinstruction \ # RUN: -no-phi-elim-live-out-early-exit=1 -phi-elim-split-all-critical-edges=1 \ # RUN: | FileCheck %s +# RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s \ +# RUN: --passes='require,phi-node-elimination,two-address-instruction' \ +# RUN: -no-phi-elim-live-out-early-exit=1 -phi-elim-split-all-critical-edges=1 \ +# RUN: | FileCheck %s --- | define void @test() !dbg !7 { diff --git a/llvm/test/CodeGen/AMDGPU/phi-elimination-assertion.mir b/llvm/test/CodeGen/AMDGPU/phi-elimination-assertion.mir index e2e6ea76103c..00828820f8ed 100644 --- a/llvm/test/CodeGen/AMDGPU/phi-elimination-assertion.mir +++ b/llvm/test/CodeGen/AMDGPU/phi-elimination-assertion.mir @@ -1,4 +1,5 @@ # RUN: llc -mtriple amdgcn -run-pass livevars -run-pass phi-node-elimination -o - %s | FileCheck %s +# RUN: llc -mtriple amdgcn --passes='require,phi-node-elimination' -o - %s | FileCheck %s ################################################################################ # This test used to hit an assert in PHIElimination: diff --git a/llvm/test/CodeGen/AMDGPU/phi-elimination-end-cf.mir b/llvm/test/CodeGen/AMDGPU/phi-elimination-end-cf.mir index 83c30507ce3c..8b009978055a 100644 --- a/llvm/test/CodeGen/AMDGPU/phi-elimination-end-cf.mir +++ b/llvm/test/CodeGen/AMDGPU/phi-elimination-end-cf.mir @@ -1,4 +1,5 @@ # RUN: llc -mtriple amdgcn -run-pass livevars -run-pass phi-node-elimination -verify-machineinstrs -o - %s | FileCheck %s +# RUN: llc -mtriple amdgcn --passes='require,phi-node-elimination' -o - %s | FileCheck %s # CHECK-LABEL: phi-cf-test # CHECK: bb.0: diff --git a/llvm/test/CodeGen/AMDGPU/split-mbb-lis-subrange.mir b/llvm/test/CodeGen/AMDGPU/split-mbb-lis-subrange.mir index 896986ff9b02..dfeca8db0b46 100644 --- a/llvm/test/CodeGen/AMDGPU/split-mbb-lis-subrange.mir +++ b/llvm/test/CodeGen/AMDGPU/split-mbb-lis-subrange.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2 # RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs -run-pass liveintervals,phi-node-elimination -o - %s | FileCheck -check-prefixes=GCN %s +# RUN: llc -mtriple=amdgcn -mcpu=gfx1100 --passes='require,phi-node-elimination' -o - %s | FileCheck -check-prefixes=GCN %s # This checks liveintervals pass verification and phi-node-elimination correctly preserves them. diff --git a/llvm/test/CodeGen/AMDGPU/stale-livevar-in-twoaddr-pass.mir b/llvm/test/CodeGen/AMDGPU/stale-livevar-in-twoaddr-pass.mir index 08bdec8871e1..4bb0046c0ee0 100644 --- a/llvm/test/CodeGen/AMDGPU/stale-livevar-in-twoaddr-pass.mir +++ b/llvm/test/CodeGen/AMDGPU/stale-livevar-in-twoaddr-pass.mir @@ -1,4 +1,5 @@ # RUN: llc -mtriple=amdgcn -mcpu=gfx900 -run-pass=livevars,phi-node-elimination,twoaddressinstruction -verify-machineinstrs -o - %s | FileCheck %s +# RUN: llc -mtriple=amdgcn -mcpu=gfx900 --passes='require,phi-node-elimination,two-address-instruction' -verify-machineinstrs -o - %s | FileCheck %s # This used to fail under ASAN enabled build because we didn't update LiveVariables in SIInstrInfo::convertToThreeAddress() # CHECK: _amdgpu_ps_main diff --git a/llvm/test/CodeGen/PowerPC/2013-07-01-PHIElimBug.mir b/llvm/test/CodeGen/PowerPC/2013-07-01-PHIElimBug.mir index 9e7c63a76ced..2a669ed6b03a 100644 --- a/llvm/test/CodeGen/PowerPC/2013-07-01-PHIElimBug.mir +++ b/llvm/test/CodeGen/PowerPC/2013-07-01-PHIElimBug.mir @@ -1,4 +1,5 @@ # RUN: llc -mtriple powerpc64-unknown-linux-gnu -run-pass livevars -run-pass phi-node-elimination -verify-machineinstrs -o - %s | FileCheck %s +# RUN: llc -mtriple powerpc64-unknown-linux-gnu --passes='require,phi-node-elimination' -o - %s | FileCheck %s # This test case was originally known as # test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll diff --git a/llvm/test/CodeGen/PowerPC/livevars-crash1.mir b/llvm/test/CodeGen/PowerPC/livevars-crash1.mir index 6ddc2b022e9b..68d2e5a627e9 100644 --- a/llvm/test/CodeGen/PowerPC/livevars-crash1.mir +++ b/llvm/test/CodeGen/PowerPC/livevars-crash1.mir @@ -1,6 +1,9 @@ # RUN: llc -mtriple powerpc64le-unknown-linux-gnu %s -o - 2>&1 \ # RUN: -run-pass=livevars,phi-node-elimination -verify-machineinstrs | \ # RUN: FileCheck %s +# RUN: llc -mtriple powerpc64le-unknown-linux-gnu %s -o - 2>&1 \ +# RUN: --passes='require,phi-node-elimination' | \ +# RUN: FileCheck %s --- | ; Function Attrs: noreturn nounwind diff --git a/llvm/test/CodeGen/PowerPC/livevars-crash2.mir b/llvm/test/CodeGen/PowerPC/livevars-crash2.mir index 1ae24fd0b701..e165c85d5b72 100644 --- a/llvm/test/CodeGen/PowerPC/livevars-crash2.mir +++ b/llvm/test/CodeGen/PowerPC/livevars-crash2.mir @@ -1,6 +1,9 @@ # RUN: llc -mtriple powerpc64le-unknown-linux-gnu %s -o - 2>&1 \ # RUN: -run-pass=livevars,phi-node-elimination -verify-machineinstrs | \ # RUN: FileCheck %s +# RUN: llc -mtriple powerpc64le-unknown-linux-gnu %s -o - 2>&1 \ +# RUN: --passes='require,phi-node-elimination' | \ +# RUN: FileCheck %s --- | define float @testfloatslt(float %c1, float %c2, float %c3, float %c4, float %a1, float %a2) { diff --git a/llvm/test/CodeGen/PowerPC/phi-eliminate.mir b/llvm/test/CodeGen/PowerPC/phi-eliminate.mir index f50d92772e34..72f778286abe 100644 --- a/llvm/test/CodeGen/PowerPC/phi-eliminate.mir +++ b/llvm/test/CodeGen/PowerPC/phi-eliminate.mir @@ -1,5 +1,7 @@ # RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 %s -o - \ # RUN: -run-pass=livevars,phi-node-elimination | FileCheck %s +# RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 %s -o - \ +# RUN: --passes='require,phi-node-elimination' | FileCheck %s --- | define void @phi_eliminate(i32 %0, i32 %1, ptr %2) { diff --git a/llvm/test/CodeGen/PowerPC/two-address-crash.mir b/llvm/test/CodeGen/PowerPC/two-address-crash.mir index eda0a93e37f9..cd2e69d8612b 100644 --- a/llvm/test/CodeGen/PowerPC/two-address-crash.mir +++ b/llvm/test/CodeGen/PowerPC/two-address-crash.mir @@ -1,5 +1,6 @@ # RUN: llc -mtriple=ppc32-- %s -run-pass=phi-node-elimination \ # RUN: -verify-machineinstrs -o /dev/null 2>&1 +# RUN: llc -mtriple=ppc32-- %s --passes=phi-node-elimination -o /dev/null 2>&1 # RUN: llc -mtriple=ppc32-- %s -start-before=phi-node-elimination \ # RUN: -verify-machineinstrs -o /dev/null 2>&1 diff --git a/llvm/test/CodeGen/Thumb2/phi_prevent_copy.mir b/llvm/test/CodeGen/Thumb2/phi_prevent_copy.mir index 201972fae8cb..0bd9f1c766e4 100644 --- a/llvm/test/CodeGen/Thumb2/phi_prevent_copy.mir +++ b/llvm/test/CodeGen/Thumb2/phi_prevent_copy.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -mtriple=thumbv8.1m.main-none-eabi -mattr=+mve -simplify-mir -run-pass=phi-node-elimination %s -o - | FileCheck %s +# RUN: llc -mtriple=thumbv8.1m.main-none-eabi -mattr=+mve -simplify-mir --passes=phi-node-elimination %s -o - | FileCheck %s --- | ; ModuleID = '' target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" diff --git a/llvm/test/CodeGen/X86/callbr-asm-kill.mir b/llvm/test/CodeGen/X86/callbr-asm-kill.mir index 0dded37c97af..5aabeade52da 100644 --- a/llvm/test/CodeGen/X86/callbr-asm-kill.mir +++ b/llvm/test/CodeGen/X86/callbr-asm-kill.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs -O2 -run-pass=livevars,phi-node-elimination -o - %s | FileCheck %s +# RUN: llc -mtriple=x86_64-unknown-linux-gnu -O2 --passes='require,phi-node-elimination' -o - %s | FileCheck %s # Check that the COPY from [[MOV64rm]] is not killed, because there is a # subsequent use of [[MOV64rm]] in the INLINEASM_BR instruction which should be diff --git a/llvm/test/CodeGen/X86/phielim-undef.mir b/llvm/test/CodeGen/X86/phielim-undef.mir index 005ee3739815..cebc725537d0 100644 --- a/llvm/test/CodeGen/X86/phielim-undef.mir +++ b/llvm/test/CodeGen/X86/phielim-undef.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -mtriple=x86_64-- -verify-machineinstrs -o - %s -run-pass=livevars,phi-node-elimination,twoaddressinstruction | FileCheck %s +# RUN: llc -mtriple=x86_64-- -verify-machineinstrs -o - %s --passes='require,phi-node-elimination,two-address-instruction' | FileCheck %s --- | @b114 = external global i16, align 1