================ @@ -77,36 +78,68 @@ class LiveDebugValues : public MachineFunctionPass { AU.setPreservesCFG(); MachineFunctionPass::getAnalysisUsage(AU); } +}; + +struct LiveDebugValues { + LiveDebugValues(); + ~LiveDebugValues() = default; + bool run(MachineFunction &MF, bool ShouldEmitDebugEntryValues); private: std::unique_ptr<LDVImpl> InstrRefImpl; std::unique_ptr<LDVImpl> VarLocImpl; - TargetPassConfig *TPC = nullptr; MachineDominatorTree MDT; }; } // namespace -char LiveDebugValues::ID = 0; +char LiveDebugValuesLegacy::ID = 0; -char &llvm::LiveDebugValuesID = LiveDebugValues::ID; +char &llvm::LiveDebugValuesID = LiveDebugValuesLegacy::ID; -INITIALIZE_PASS(LiveDebugValues, DEBUG_TYPE, "Live DEBUG_VALUE analysis", false, - false) +INITIALIZE_PASS(LiveDebugValuesLegacy, DEBUG_TYPE, "Live DEBUG_VALUE analysis", + false, false) /// Default construct and initialize the pass. -LiveDebugValues::LiveDebugValues() : MachineFunctionPass(ID) { - initializeLiveDebugValuesPass(*PassRegistry::getPassRegistry()); +LiveDebugValuesLegacy::LiveDebugValuesLegacy() : MachineFunctionPass(ID) { + initializeLiveDebugValuesLegacyPass(*PassRegistry::getPassRegistry()); +} + +LiveDebugValues::LiveDebugValues() { InstrRefImpl = std::unique_ptr<LDVImpl>(llvm::makeInstrRefBasedLiveDebugValues()); VarLocImpl = std::unique_ptr<LDVImpl>(llvm::makeVarLocBasedLiveDebugValues()); } -bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) { +PreservedAnalyses +LiveDebugValuesPass::run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM) { + if (!LiveDebugValues().run(MF, ShouldEmitDebugEntryValues)) + return PreservedAnalyses::all(); + auto PA = getMachineFunctionPassPreservedAnalyses(); + PA.preserveSet<CFGAnalyses>(); + return PA; +} + +void LiveDebugValuesPass::printPipeline( + raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) { + OS << MapClassName2PassName(name()); + if (ShouldEmitDebugEntryValues) + OS << "<emit-debug-entry-values>"; +} + +bool LiveDebugValuesLegacy::runOnMachineFunction(MachineFunction &MF) { + auto *TPC = getAnalysisIfAvailable<TargetPassConfig>(); + assert(TPC && "TargetPassConfig must be available"); ---------------- arsenm wrote:
This should not be an assert. Should just be getAnalysis https://github.com/llvm/llvm-project/pull/131563 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits