Index: include/llvm/CodeGen/EdgeBundles.h =================================================================== --- include/llvm/CodeGen/EdgeBundles.h +++ include/llvm/CodeGen/EdgeBundles.h @@ -37,6 +37,7 @@ public: static char ID; EdgeBundles() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS /// getBundle - Return the ingoing (Out = false) or outgoing (Out = true) /// bundle number for basic block #N Index: include/llvm/CodeGen/LiveIntervalAnalysis.h =================================================================== --- include/llvm/CodeGen/LiveIntervalAnalysis.h +++ include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -100,6 +100,7 @@ public: static char ID; // Pass identification, replacement for typeid LiveIntervals(); + SUPPORTS_VIRTUAL_REGISTERS ~LiveIntervals() override; // Calculate the spill weight to assign to a single instruction. Index: include/llvm/CodeGen/LiveRegMatrix.h =================================================================== --- include/llvm/CodeGen/LiveRegMatrix.h +++ include/llvm/CodeGen/LiveRegMatrix.h @@ -62,6 +62,7 @@ public: static char ID; LiveRegMatrix(); + SUPPORTS_VIRTUAL_REGISTERS //===--------------------------------------------------------------------===// // High-level interface. Index: include/llvm/CodeGen/LiveStackAnalysis.h =================================================================== --- include/llvm/CodeGen/LiveStackAnalysis.h +++ include/llvm/CodeGen/LiveStackAnalysis.h @@ -45,6 +45,7 @@ LiveStacks() : MachineFunctionPass(ID) { initializeLiveStacksPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS typedef SS2IntervalMap::iterator iterator; typedef SS2IntervalMap::const_iterator const_iterator; Index: include/llvm/CodeGen/LiveVariables.h =================================================================== --- include/llvm/CodeGen/LiveVariables.h +++ include/llvm/CodeGen/LiveVariables.h @@ -49,6 +49,7 @@ LiveVariables() : MachineFunctionPass(ID) { initializeLiveVariablesPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS /// VarInfo - This represents the regions where a virtual register is live in /// the program. We represent this with three different pieces of Index: include/llvm/CodeGen/MachineBlockFrequencyInfo.h =================================================================== --- include/llvm/CodeGen/MachineBlockFrequencyInfo.h +++ include/llvm/CodeGen/MachineBlockFrequencyInfo.h @@ -34,6 +34,7 @@ static char ID; MachineBlockFrequencyInfo(); + SUPPORTS_VIRTUAL_REGISTERS ~MachineBlockFrequencyInfo() override; Index: include/llvm/CodeGen/MachineDominanceFrontier.h =================================================================== --- include/llvm/CodeGen/MachineDominanceFrontier.h +++ include/llvm/CodeGen/MachineDominanceFrontier.h @@ -32,6 +32,7 @@ static char ID; MachineDominanceFrontier(); + SUPPORTS_VIRTUAL_REGISTERS DominanceFrontierBase &getBase() { return Base; Index: include/llvm/CodeGen/MachineDominators.h =================================================================== --- include/llvm/CodeGen/MachineDominators.h +++ include/llvm/CodeGen/MachineDominators.h @@ -68,6 +68,7 @@ public: static char ID; // Pass ID, replacement for typeid + SUPPORTS_VIRTUAL_REGISTERS DominatorTreeBase* DT; MachineDominatorTree(); Index: include/llvm/CodeGen/MachineFunctionPass.h =================================================================== --- include/llvm/CodeGen/MachineFunctionPass.h +++ include/llvm/CodeGen/MachineFunctionPass.h @@ -46,6 +46,9 @@ /// void getAnalysisUsage(AnalysisUsage &AU) const override; + const bool SupportsVirtualRegisters = false; + virtual bool getSupportsVirtualRegisters() const { return false;} + private: /// createPrinterPass - Get a machine function printer pass. Pass *createPrinterPass(raw_ostream &O, @@ -55,5 +58,6 @@ }; } // End llvm namespace +#define SUPPORTS_VIRTUAL_REGISTERS bool getSupportsVirtualRegisters() const override { return true; } #endif Index: include/llvm/CodeGen/MachineLoopInfo.h =================================================================== --- include/llvm/CodeGen/MachineLoopInfo.h +++ include/llvm/CodeGen/MachineLoopInfo.h @@ -78,6 +78,7 @@ MachineLoopInfo() : MachineFunctionPass(ID) { initializeMachineLoopInfoPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS LoopInfoBase& getBase() { return LI; } Index: include/llvm/CodeGen/MachinePostDominators.h =================================================================== --- include/llvm/CodeGen/MachinePostDominators.h +++ include/llvm/CodeGen/MachinePostDominators.h @@ -32,6 +32,7 @@ static char ID; MachinePostDominatorTree(); + SUPPORTS_VIRTUAL_REGISTERS ~MachinePostDominatorTree() override; Index: include/llvm/CodeGen/MachineTraceMetrics.h =================================================================== --- include/llvm/CodeGen/MachineTraceMetrics.h +++ include/llvm/CodeGen/MachineTraceMetrics.h @@ -77,6 +77,7 @@ class Trace; static char ID; MachineTraceMetrics(); + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage&) const override; bool runOnMachineFunction(MachineFunction&) override; void releaseMemory() override; Index: include/llvm/CodeGen/SlotIndexes.h =================================================================== --- include/llvm/CodeGen/SlotIndexes.h +++ include/llvm/CodeGen/SlotIndexes.h @@ -371,6 +371,7 @@ public: static char ID; + SUPPORTS_VIRTUAL_REGISTERS SlotIndexes() : MachineFunctionPass(ID) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); Index: include/llvm/CodeGen/VirtRegMap.h =================================================================== --- include/llvm/CodeGen/VirtRegMap.h +++ include/llvm/CodeGen/VirtRegMap.h @@ -70,6 +70,7 @@ static char ID; VirtRegMap() : MachineFunctionPass(ID), Virt2PhysMap(NO_PHYS_REG), Virt2StackSlotMap(NO_STACK_SLOT), Virt2SplitMap(0) { } + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override; void getAnalysisUsage(AnalysisUsage &AU) const override { Index: lib/CodeGen/BranchFolding.cpp =================================================================== --- lib/CodeGen/BranchFolding.cpp +++ lib/CodeGen/BranchFolding.cpp @@ -71,6 +71,7 @@ public: static char ID; explicit BranchFolderPass(): MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override; Index: lib/CodeGen/DeadMachineInstructionElim.cpp =================================================================== --- lib/CodeGen/DeadMachineInstructionElim.cpp +++ lib/CodeGen/DeadMachineInstructionElim.cpp @@ -41,6 +41,7 @@ DeadMachineInstructionElim() : MachineFunctionPass(ID) { initializeDeadMachineInstructionElimPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS private: bool isDead(const MachineInstr *MI) const; Index: lib/CodeGen/EarlyIfConversion.cpp =================================================================== --- lib/CodeGen/EarlyIfConversion.cpp +++ lib/CodeGen/EarlyIfConversion.cpp @@ -600,6 +600,7 @@ public: static char ID; EarlyIfConverter() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override; bool runOnMachineFunction(MachineFunction &MF) override; const char *getPassName() const override { return "Early If-Conversion"; } Index: lib/CodeGen/ExpandISelPseudos.cpp =================================================================== --- lib/CodeGen/ExpandISelPseudos.cpp +++ lib/CodeGen/ExpandISelPseudos.cpp @@ -36,6 +36,7 @@ void getAnalysisUsage(AnalysisUsage &AU) const override { MachineFunctionPass::getAnalysisUsage(AU); } + SUPPORTS_VIRTUAL_REGISTERS }; } // end anonymous namespace Index: lib/CodeGen/ExpandPostRAPseudos.cpp =================================================================== --- lib/CodeGen/ExpandPostRAPseudos.cpp +++ lib/CodeGen/ExpandPostRAPseudos.cpp @@ -36,6 +36,10 @@ public: static char ID; // Pass identification, replacement for typeid ExpandPostRA() : MachineFunctionPass(ID) {} + // LowerSubregToReg expects physical registers and has assertions to validate + // the expectation. LowerCopy delegates to the target and supports virtual + // registers if the target does. + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); Index: lib/CodeGen/LiveDebugVariables.h =================================================================== --- lib/CodeGen/LiveDebugVariables.h +++ lib/CodeGen/LiveDebugVariables.h @@ -40,6 +40,8 @@ LiveDebugVariables(); ~LiveDebugVariables() override; + SUPPORTS_VIRTUAL_REGISTERS + /// renameRegister - Move any user variables in OldReg to NewReg:SubIdx. /// @param OldReg Old virtual register that is going away. /// @param NewReg New register holding the user variables. Index: lib/CodeGen/LocalStackSlotAllocation.cpp =================================================================== --- lib/CodeGen/LocalStackSlotAllocation.cpp +++ lib/CodeGen/LocalStackSlotAllocation.cpp @@ -80,6 +80,7 @@ explicit LocalStackSlotPass() : MachineFunctionPass(ID) { initializeLocalStackSlotPassPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override; void getAnalysisUsage(AnalysisUsage &AU) const override { Index: lib/CodeGen/MIRPrintingPass.cpp =================================================================== --- lib/CodeGen/MIRPrintingPass.cpp +++ lib/CodeGen/MIRPrintingPass.cpp @@ -32,6 +32,7 @@ MIRPrintingPass() : MachineFunctionPass(ID), OS(dbgs()) {} MIRPrintingPass(raw_ostream &OS) : MachineFunctionPass(ID), OS(OS) {} + SUPPORTS_VIRTUAL_REGISTERS const char *getPassName() const override { return "MIR Printing Pass"; } Index: lib/CodeGen/MachineBlockPlacement.cpp =================================================================== --- lib/CodeGen/MachineBlockPlacement.cpp +++ lib/CodeGen/MachineBlockPlacement.cpp @@ -289,6 +289,7 @@ MachineBlockPlacement() : MachineFunctionPass(ID) { initializeMachineBlockPlacementPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &F) override; Index: lib/CodeGen/MachineCSE.cpp =================================================================== --- lib/CodeGen/MachineCSE.cpp +++ lib/CodeGen/MachineCSE.cpp @@ -51,6 +51,7 @@ MachineCSE() : MachineFunctionPass(ID), LookAheadLimit(0), CurrVN(0) { initializeMachineCSEPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override; Index: lib/CodeGen/MachineCombiner.cpp =================================================================== --- lib/CodeGen/MachineCombiner.cpp +++ lib/CodeGen/MachineCombiner.cpp @@ -54,6 +54,7 @@ MachineCombiner() : MachineFunctionPass(ID) { initializeMachineCombinerPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override; bool runOnMachineFunction(MachineFunction &MF) override; const char *getPassName() const override { return "Machine InstCombiner"; } Index: lib/CodeGen/MachineFunctionPass.cpp =================================================================== --- lib/CodeGen/MachineFunctionPass.cpp +++ lib/CodeGen/MachineFunctionPass.cpp @@ -22,6 +22,7 @@ #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/StackProtector.h" #include "llvm/IR/Dominators.h" @@ -40,6 +41,8 @@ return false; MachineFunction &MF = getAnalysis().getMF(); + assert(getSupportsVirtualRegisters() || !MF.getRegInfo().getNumVirtRegs() && + "Pass does not support virtual registers"); return runOnMachineFunction(MF); } Index: lib/CodeGen/MachineFunctionPrinterPass.cpp =================================================================== --- lib/CodeGen/MachineFunctionPrinterPass.cpp +++ lib/CodeGen/MachineFunctionPrinterPass.cpp @@ -48,6 +48,7 @@ MF.print(OS, getAnalysisIfAvailable()); return false; } + SUPPORTS_VIRTUAL_REGISTERS }; char MachineFunctionPrinterPass::ID = 0; Index: lib/CodeGen/MachineLICM.cpp =================================================================== --- lib/CodeGen/MachineLICM.cpp +++ lib/CodeGen/MachineLICM.cpp @@ -127,6 +127,7 @@ MachineFunctionPass(ID), PreRegAlloc(true) { initializeMachineLICMPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS explicit MachineLICM(bool PreRA) : MachineFunctionPass(ID), PreRegAlloc(PreRA) { Index: lib/CodeGen/MachineScheduler.cpp =================================================================== --- lib/CodeGen/MachineScheduler.cpp +++ lib/CodeGen/MachineScheduler.cpp @@ -118,6 +118,7 @@ class MachineScheduler : public MachineSchedulerBase { public: MachineScheduler(); + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override; Index: lib/CodeGen/MachineSink.cpp =================================================================== --- lib/CodeGen/MachineSink.cpp +++ lib/CodeGen/MachineSink.cpp @@ -82,6 +82,7 @@ MachineSinking() : MachineFunctionPass(ID) { initializeMachineSinkingPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override; Index: lib/CodeGen/MachineVerifier.cpp =================================================================== --- lib/CodeGen/MachineVerifier.cpp +++ lib/CodeGen/MachineVerifier.cpp @@ -249,6 +249,7 @@ : MachineFunctionPass(ID), Banner(banner) { initializeMachineVerifierPassPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesAll(); Index: lib/CodeGen/OptimizePHIs.cpp =================================================================== --- lib/CodeGen/OptimizePHIs.cpp +++ lib/CodeGen/OptimizePHIs.cpp @@ -38,6 +38,7 @@ OptimizePHIs() : MachineFunctionPass(ID) { initializeOptimizePHIsPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override; Index: lib/CodeGen/PHIElimination.cpp =================================================================== --- lib/CodeGen/PHIElimination.cpp +++ lib/CodeGen/PHIElimination.cpp @@ -62,6 +62,7 @@ PHIElimination() : MachineFunctionPass(ID) { initializePHIEliminationPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &Fn) override; void getAnalysisUsage(AnalysisUsage &AU) const override; Index: lib/CodeGen/PeepholeOptimizer.cpp =================================================================== --- lib/CodeGen/PeepholeOptimizer.cpp +++ lib/CodeGen/PeepholeOptimizer.cpp @@ -131,6 +131,7 @@ PeepholeOptimizer() : MachineFunctionPass(ID) { initializePeepholeOptimizerPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override; Index: lib/CodeGen/ProcessImplicitDefs.cpp =================================================================== --- lib/CodeGen/ProcessImplicitDefs.cpp +++ lib/CodeGen/ProcessImplicitDefs.cpp @@ -41,6 +41,7 @@ ProcessImplicitDefs() : MachineFunctionPass(ID) { initializeProcessImplicitDefsPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &au) const override; Index: lib/CodeGen/PrologEpilogInserter.cpp =================================================================== --- lib/CodeGen/PrologEpilogInserter.cpp +++ lib/CodeGen/PrologEpilogInserter.cpp @@ -216,7 +216,7 @@ // If register scavenging is needed, as we've enabled doing it as a // post-pass, scavenge the virtual registers that frame index elimination // inserted. - if (TRI->requiresRegisterScavenging(Fn) && FrameIndexVirtualScavenging) + if (FrameIndexVirtualScavenging) scavengeFrameVirtualRegs(Fn); // Clear any vregs created by virtual scavenging. Index: lib/CodeGen/RegAllocBasic.cpp =================================================================== --- lib/CodeGen/RegAllocBasic.cpp +++ lib/CodeGen/RegAllocBasic.cpp @@ -74,6 +74,7 @@ public: RABasic(); + SUPPORTS_VIRTUAL_REGISTERS /// Return the pass name. const char* getPassName() const override { Index: lib/CodeGen/RegAllocFast.cpp =================================================================== --- lib/CodeGen/RegAllocFast.cpp +++ lib/CodeGen/RegAllocFast.cpp @@ -52,6 +52,7 @@ static char ID; RAFast() : MachineFunctionPass(ID), StackSlotForVirtReg(-1), isBulkSpilling(false) {} + SUPPORTS_VIRTUAL_REGISTERS private: MachineFunction *MF; MachineRegisterInfo *MRI; Index: lib/CodeGen/RegAllocGreedy.cpp =================================================================== --- lib/CodeGen/RegAllocGreedy.cpp +++ lib/CodeGen/RegAllocGreedy.cpp @@ -314,6 +314,7 @@ public: RAGreedy(); + SUPPORTS_VIRTUAL_REGISTERS /// Return the pass name. const char* getPassName() const override { Index: lib/CodeGen/RegAllocPBQP.cpp =================================================================== --- lib/CodeGen/RegAllocPBQP.cpp +++ lib/CodeGen/RegAllocPBQP.cpp @@ -97,6 +97,7 @@ initializeLiveStacksPass(*PassRegistry::getPassRegistry()); initializeVirtRegMapPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS /// Return the pass name. const char* getPassName() const override { Index: lib/CodeGen/RegisterCoalescer.cpp =================================================================== --- lib/CodeGen/RegisterCoalescer.cpp +++ lib/CodeGen/RegisterCoalescer.cpp @@ -239,6 +239,7 @@ RegisterCoalescer() : MachineFunctionPass(ID) { initializeRegisterCoalescerPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override; Index: lib/CodeGen/SpillPlacement.h =================================================================== --- lib/CodeGen/SpillPlacement.h +++ lib/CodeGen/SpillPlacement.h @@ -71,6 +71,7 @@ SpillPlacement() : MachineFunctionPass(ID), nodes(nullptr) {} ~SpillPlacement() override { releaseMemory(); } + SUPPORTS_VIRTUAL_REGISTERS /// BorderConstraint - A basic block has separate constraints for entry and /// exit. Index: lib/CodeGen/StackColoring.cpp =================================================================== --- lib/CodeGen/StackColoring.cpp +++ lib/CodeGen/StackColoring.cpp @@ -132,6 +132,7 @@ StackColoring() : MachineFunctionPass(ID) { initializeStackColoringPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override; bool runOnMachineFunction(MachineFunction &MF) override; Index: lib/CodeGen/TailDuplication.cpp =================================================================== --- lib/CodeGen/TailDuplication.cpp +++ lib/CodeGen/TailDuplication.cpp @@ -75,7 +75,7 @@ // For each virtual register in SSAUpdateVals keep a list of source virtual // registers. DenseMap SSAUpdateVals; - + SUPPORTS_VIRTUAL_REGISTERS public: static char ID; explicit TailDuplicatePass() : Index: lib/CodeGen/TwoAddressInstructionPass.cpp =================================================================== --- lib/CodeGen/TwoAddressInstructionPass.cpp +++ lib/CodeGen/TwoAddressInstructionPass.cpp @@ -152,6 +152,7 @@ TwoAddressInstructionPass() : MachineFunctionPass(ID) { initializeTwoAddressInstructionPassPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); Index: lib/CodeGen/UnreachableBlockElim.cpp =================================================================== --- lib/CodeGen/UnreachableBlockElim.cpp +++ lib/CodeGen/UnreachableBlockElim.cpp @@ -100,6 +100,7 @@ public: static char ID; // Pass identification, replacement for typeid UnreachableMachineBlockElim() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS }; } char UnreachableMachineBlockElim::ID = 0; Index: lib/CodeGen/VirtRegMap.cpp =================================================================== --- lib/CodeGen/VirtRegMap.cpp +++ lib/CodeGen/VirtRegMap.cpp @@ -172,6 +172,7 @@ public: static char ID; VirtRegRewriter() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override; @@ -445,4 +446,3 @@ } } } - Index: lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp +++ lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp @@ -43,7 +43,8 @@ public: static char ID; // Pass identification, replacement for typeid WebAssemblyArgumentMove() : MachineFunctionPass(ID) {} - + //virtual bool getSupportsVirtualRegisters() const { return true; } + SUPPORTS_VIRTUAL_REGISTERS const char *getPassName() const override { return "WebAssembly Argument Move"; } Index: lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -47,6 +47,7 @@ public: WebAssemblyAsmPrinter(TargetMachine &TM, std::unique_ptr Streamer) : AsmPrinter(TM, std::move(Streamer)), MRI(nullptr), MFI(nullptr) {} + SUPPORTS_VIRTUAL_REGISTERS private: const char *getPassName() const override { Index: lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -62,6 +62,7 @@ public: static char ID; // Pass identification, replacement for typeid WebAssemblyCFGStackify() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS }; } // end anonymous namespace Index: lib/Target/WebAssembly/WebAssemblyLowerBrUnless.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyLowerBrUnless.cpp +++ lib/Target/WebAssembly/WebAssemblyLowerBrUnless.cpp @@ -43,6 +43,7 @@ public: static char ID; // Pass identification, replacement for typeid WebAssemblyLowerBrUnless() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS }; } // end anonymous namespace Index: lib/Target/WebAssembly/WebAssemblyPEI.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyPEI.cpp +++ lib/Target/WebAssembly/WebAssemblyPEI.cpp @@ -65,6 +65,7 @@ WasmPEI() : MachineFunctionPass(ID) { initializeWasmPEIPass(*PassRegistry::getPassRegistry()); } + SUPPORTS_VIRTUAL_REGISTERS void getAnalysisUsage(AnalysisUsage &AU) const override; Index: lib/Target/WebAssembly/WebAssemblyPeephole.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyPeephole.cpp +++ lib/Target/WebAssembly/WebAssemblyPeephole.cpp @@ -36,6 +36,7 @@ public: static char ID; WebAssemblyPeephole() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS }; } // end anonymous namespace Index: lib/Target/WebAssembly/WebAssemblyRegColoring.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegColoring.cpp +++ lib/Target/WebAssembly/WebAssemblyRegColoring.cpp @@ -34,6 +34,7 @@ public: static char ID; // Pass identification, replacement for typeid WebAssemblyRegColoring() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS const char *getPassName() const override { return "WebAssembly Register Coloring"; Index: lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp +++ lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp @@ -46,6 +46,7 @@ public: static char ID; // Pass identification, replacement for typeid WebAssemblyRegNumbering() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS }; } // end anonymous namespace Index: lib/Target/WebAssembly/WebAssemblyRegStackify.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -58,6 +58,7 @@ public: static char ID; // Pass identification, replacement for typeid WebAssemblyRegStackify() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS }; } // end anonymous namespace Index: lib/Target/WebAssembly/WebAssemblyStoreResults.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyStoreResults.cpp +++ lib/Target/WebAssembly/WebAssemblyStoreResults.cpp @@ -38,6 +38,7 @@ public: static char ID; // Pass identification, replacement for typeid WebAssemblyStoreResults() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS const char *getPassName() const override { return "WebAssembly Store Results"; Index: lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -106,6 +106,8 @@ bool addILPOpts() override; void addPreRegAlloc() override; void addPostRegAlloc() override; + void addMachineLateOptimization() override; + bool addGCPasses() override { return false; } void addPreEmitPass() override; }; } // end anonymous namespace @@ -175,6 +177,9 @@ // virtual registers. Consider removing their restrictions and re-enabling // them. // + + // Has no asserts of its own, but was not written to handle virtual regs. + disablePass(&ShrinkWrapID); // We use our own PrologEpilogInserter which is very slightly modified to // tolerate virtual registers. disablePass(&PrologEpilogCodeInserterID); @@ -195,9 +200,19 @@ addPass(createWebAssemblyPEI()); } +void WebAssemblyPassConfig::addMachineLateOptimization() { + disablePass(&MachineCopyPropagationID); + disablePass(&PostRASchedulerID); + TargetPassConfig::addMachineLateOptimization(); +} + void WebAssemblyPassConfig::addPreEmitPass() { TargetPassConfig::addPreEmitPass(); + disablePass(&FuncletLayoutID); + disablePass(&StackMapLivenessID); + disablePass(&LiveDebugValuesID); + // Put the CFG in structured form; insert BLOCK and LOOP markers. addPass(createWebAssemblyCFGStackify()); Index: lib/Target/X86/X86CallFrameOptimization.cpp =================================================================== --- lib/Target/X86/X86CallFrameOptimization.cpp +++ lib/Target/X86/X86CallFrameOptimization.cpp @@ -47,6 +47,7 @@ class X86CallFrameOptimization : public MachineFunctionPass { public: X86CallFrameOptimization() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override; Index: lib/Target/X86/X86InstrInfo.cpp =================================================================== --- lib/Target/X86/X86InstrInfo.cpp +++ lib/Target/X86/X86InstrInfo.cpp @@ -7151,6 +7151,7 @@ struct CGBR : public MachineFunctionPass { static char ID; CGBR() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override { const X86TargetMachine *TM = @@ -7221,6 +7222,7 @@ struct LDTLSCleanup : public MachineFunctionPass { static char ID; LDTLSCleanup() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS bool runOnMachineFunction(MachineFunction &MF) override { X86MachineFunctionInfo* MFI = MF.getInfo(); Index: lib/Target/X86/X86OptimizeLEAs.cpp =================================================================== --- lib/Target/X86/X86OptimizeLEAs.cpp +++ lib/Target/X86/X86OptimizeLEAs.cpp @@ -46,6 +46,7 @@ class OptimizeLEAPass : public MachineFunctionPass { public: OptimizeLEAPass() : MachineFunctionPass(ID) {} + SUPPORTS_VIRTUAL_REGISTERS const char *getPassName() const override { return "X86 LEA Optimize"; }