@@ -74,25 +74,27 @@ EnableLDV("live-debug-variables", cl::init(true),
7474STATISTIC (NumInsertedDebugValues, " Number of DBG_VALUEs inserted" );
7575STATISTIC (NumInsertedDebugLabels, " Number of DBG_LABELs inserted" );
7676
77- char LiveDebugVariablesWrapperPass ::ID = 0 ;
77+ char LiveDebugVariablesWrapperLegacy ::ID = 0 ;
7878
79- INITIALIZE_PASS_BEGIN (LiveDebugVariablesWrapperPass , DEBUG_TYPE,
79+ INITIALIZE_PASS_BEGIN (LiveDebugVariablesWrapperLegacy , DEBUG_TYPE,
8080 " Debug Variable Analysis" , false , false )
8181INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
8282INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
83- INITIALIZE_PASS_END(LiveDebugVariablesWrapperPass , DEBUG_TYPE,
83+ INITIALIZE_PASS_END(LiveDebugVariablesWrapperLegacy , DEBUG_TYPE,
8484 " Debug Variable Analysis" , false , false )
8585
86- void LiveDebugVariablesWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
86+ void LiveDebugVariablesWrapperLegacy::getAnalysisUsage(
87+ AnalysisUsage &AU) const {
8788 AU.addRequired <MachineDominatorTreeWrapperPass>();
8889 AU.addRequiredTransitive <LiveIntervalsWrapperPass>();
8990 AU.setPreservesAll ();
9091 MachineFunctionPass::getAnalysisUsage (AU);
9192}
9293
93- LiveDebugVariablesWrapperPass::LiveDebugVariablesWrapperPass ()
94+ LiveDebugVariablesWrapperLegacy::LiveDebugVariablesWrapperLegacy ()
9495 : MachineFunctionPass(ID) {
95- initializeLiveDebugVariablesWrapperPassPass (*PassRegistry::getPassRegistry ());
96+ initializeLiveDebugVariablesWrapperLegacyPass (
97+ *PassRegistry::getPassRegistry ());
9698}
9799
98100enum : unsigned { UndefLocNo = ~0U };
@@ -673,7 +675,6 @@ class LDVImpl {
673675
674676} // end anonymous namespace
675677
676- #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
677678static void printDebugLoc (const DebugLoc &DL, raw_ostream &CommentOS,
678679 const LLVMContext &Ctx) {
679680 if (!DL)
@@ -761,7 +762,6 @@ void LDVImpl::print(raw_ostream &OS) {
761762 for (auto &userLabel : userLabels)
762763 userLabel->print (OS, TRI);
763764}
764- #endif
765765
766766void UserValue::mapVirtRegs (LDVImpl *LDV) {
767767 for (const MachineOperand &MO : locations)
@@ -1297,7 +1297,8 @@ static void removeDebugInstrs(MachineFunction &mf) {
12971297 }
12981298}
12991299
1300- bool LiveDebugVariablesWrapperPass::runOnMachineFunction (MachineFunction &mf) {
1300+ bool LiveDebugVariablesWrapperLegacy::runOnMachineFunction (
1301+ MachineFunction &mf) {
13011302 auto *LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS ();
13021303
13031304 Impl = std::make_unique<LiveDebugVariables>();
@@ -1316,6 +1317,14 @@ LiveDebugVariablesAnalysis::run(MachineFunction &MF,
13161317 return LDV;
13171318}
13181319
1320+ PreservedAnalyses
1321+ LiveDebugVariablesPrinterPass::run (MachineFunction &MF,
1322+ MachineFunctionAnalysisManager &MFAM) {
1323+ auto &LDV = MFAM.getResult <LiveDebugVariablesAnalysis>(MF);
1324+ LDV.print (dbgs ());
1325+ return PreservedAnalyses::all ();
1326+ }
1327+
13191328void LiveDebugVariables::Deleter::operator ()(void *Ptr) const {
13201329 delete static_cast <LDVImpl *>(Ptr);
13211330}
@@ -1325,6 +1334,16 @@ void LiveDebugVariables::releaseMemory() {
13251334 static_cast <LDVImpl *>(PImpl.get ())->clear ();
13261335}
13271336
1337+ bool LiveDebugVariables::invalidate (
1338+ MachineFunction &, const PreservedAnalyses &PA,
1339+ MachineFunctionAnalysisManager::Invalidator &) {
1340+ auto PAC = PA.getChecker <LiveDebugVariablesAnalysis>();
1341+ // Some architectures split the register allocation into multiple phases based
1342+ // on register classes. This requires preserving analyses between the phases
1343+ // by default.
1344+ return PAC.preservedWhenStateless ();
1345+ }
1346+
13281347void LiveDebugVariables::analyze (MachineFunction &MF, LiveIntervals *LIS) {
13291348 if (!EnableLDV)
13301349 return ;
@@ -1977,8 +1996,10 @@ void LiveDebugVariables::emitDebugValues(VirtRegMap *VRM) {
19771996}
19781997
19791998#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1980- LLVM_DUMP_METHOD void LiveDebugVariables::dump () const {
1999+ LLVM_DUMP_METHOD void LiveDebugVariables::dump () const { print (dbgs ()); }
2000+ #endif
2001+
2002+ void LiveDebugVariables::print (raw_ostream &OS) const {
19812003 if (PImpl)
1982- static_cast <LDVImpl *>(PImpl.get ())->print (dbgs () );
2004+ static_cast <LDVImpl *>(PImpl.get ())->print (OS );
19832005}
1984- #endif
0 commit comments