@@ -286,6 +286,8 @@ namespace {
286286// / user values are related if they are held by the same virtual register. The
287287// / equivalence class is the transitive closure of that relation.
288288class UserValue {
289+ using LDVImpl = LiveDebugVariables::LDVImpl;
290+
289291 const DILocalVariable *Variable; // /< The debug info variable we are part of.
290292 // / The part of the variable we describe.
291293 const std::optional<DIExpression::FragmentInfo> Fragment;
@@ -534,7 +536,12 @@ class UserLabel {
534536namespace llvm {
535537
536538// / Implementation of the LiveDebugVariables pass.
537- class LDVImpl {
539+
540+ LiveDebugVariables::LiveDebugVariables () = default ;
541+ LiveDebugVariables::~LiveDebugVariables () = default ;
542+ LiveDebugVariables::LiveDebugVariables (LiveDebugVariables &&) = default ;
543+
544+ class LiveDebugVariables ::LDVImpl {
538545 LocMap::Allocator allocator;
539546 MachineFunction *MF = nullptr ;
540547 LiveIntervals *LIS;
@@ -756,7 +763,7 @@ void UserLabel::print(raw_ostream &OS, const TargetRegisterInfo *TRI) {
756763 OS << ' \n ' ;
757764}
758765
759- void LDVImpl::print (raw_ostream &OS) {
766+ void LiveDebugVariables:: LDVImpl::print (raw_ostream &OS) {
760767 OS << " ********** DEBUG VARIABLES **********\n " ;
761768 for (auto &userValue : userValues)
762769 userValue->print (OS, TRI);
@@ -765,16 +772,15 @@ void LDVImpl::print(raw_ostream &OS) {
765772 userLabel->print (OS, TRI);
766773}
767774
768- void UserValue::mapVirtRegs (LDVImpl *LDV) {
775+ void UserValue::mapVirtRegs (LiveDebugVariables:: LDVImpl *LDV) {
769776 for (const MachineOperand &MO : locations)
770777 if (MO.isReg () && MO.getReg ().isVirtual ())
771778 LDV->mapVirtReg (MO.getReg (), this );
772779}
773780
774- UserValue *
775- LDVImpl::getUserValue (const DILocalVariable *Var,
776- std::optional<DIExpression::FragmentInfo> Fragment,
777- const DebugLoc &DL) {
781+ UserValue *LiveDebugVariables::LDVImpl::getUserValue (
782+ const DILocalVariable *Var,
783+ std::optional<DIExpression::FragmentInfo> Fragment, const DebugLoc &DL) {
778784 // FIXME: Handle partially overlapping fragments. See
779785 // https://reviews.llvm.org/D70121#1849741.
780786 DebugVariable ID (Var, Fragment, DL->getInlinedAt ());
@@ -787,19 +793,20 @@ LDVImpl::getUserValue(const DILocalVariable *Var,
787793 return UV;
788794}
789795
790- void LDVImpl::mapVirtReg (Register VirtReg, UserValue *EC) {
796+ void LiveDebugVariables:: LDVImpl::mapVirtReg (Register VirtReg, UserValue *EC) {
791797 assert (VirtReg.isVirtual () && " Only map VirtRegs" );
792798 UserValue *&Leader = virtRegToEqClass[VirtReg];
793799 Leader = UserValue::merge (Leader, EC);
794800}
795801
796- UserValue *LDVImpl::lookupVirtReg (Register VirtReg) {
802+ UserValue *LiveDebugVariables:: LDVImpl::lookupVirtReg (Register VirtReg) {
797803 if (UserValue *UV = virtRegToEqClass.lookup (VirtReg))
798804 return UV->getLeader ();
799805 return nullptr ;
800806}
801807
802- bool LDVImpl::handleDebugValue (MachineInstr &MI, SlotIndex Idx) {
808+ bool LiveDebugVariables::LDVImpl::handleDebugValue (MachineInstr &MI,
809+ SlotIndex Idx) {
803810 // DBG_VALUE loc, offset, variable, expr
804811 // DBG_VALUE_LIST variable, expr, locs...
805812 if (!MI.isDebugValue ()) {
@@ -875,8 +882,8 @@ bool LDVImpl::handleDebugValue(MachineInstr &MI, SlotIndex Idx) {
875882 return true ;
876883}
877884
878- MachineBasicBlock::iterator LDVImpl::handleDebugInstr (MachineInstr &MI,
879- SlotIndex Idx) {
885+ MachineBasicBlock::iterator
886+ LiveDebugVariables::LDVImpl::handleDebugInstr (MachineInstr &MI, SlotIndex Idx) {
880887 assert (MI.isDebugValueLike () || MI.isDebugPHI ());
881888
882889 // In instruction referencing mode, there should be no DBG_VALUE instructions
@@ -896,7 +903,8 @@ MachineBasicBlock::iterator LDVImpl::handleDebugInstr(MachineInstr &MI,
896903 return NextInst;
897904}
898905
899- bool LDVImpl::handleDebugLabel (MachineInstr &MI, SlotIndex Idx) {
906+ bool LiveDebugVariables::LDVImpl::handleDebugLabel (MachineInstr &MI,
907+ SlotIndex Idx) {
900908 // DBG_LABEL label
901909 if (MI.getNumOperands () != 1 || !MI.getOperand (0 ).isMetadata ()) {
902910 LLVM_DEBUG (dbgs () << " Can't handle " << MI);
@@ -919,7 +927,8 @@ bool LDVImpl::handleDebugLabel(MachineInstr &MI, SlotIndex Idx) {
919927 return true ;
920928}
921929
922- bool LDVImpl::collectDebugValues (MachineFunction &mf, bool InstrRef) {
930+ bool LiveDebugVariables::LDVImpl::collectDebugValues (MachineFunction &mf,
931+ bool InstrRef) {
923932 bool Changed = false ;
924933 for (MachineBasicBlock &MBB : mf) {
925934 for (MachineBasicBlock::iterator MBBI = MBB.begin (), MBBE = MBB.end ();
@@ -1252,7 +1261,7 @@ void UserValue::computeIntervals(MachineRegisterInfo &MRI,
12521261 I.setStopUnchecked (PrevEnd);
12531262}
12541263
1255- void LDVImpl::computeIntervals () {
1264+ void LiveDebugVariables:: LDVImpl::computeIntervals () {
12561265 LexicalScopes LS;
12571266 LS.initialize (*MF);
12581267
@@ -1262,7 +1271,8 @@ void LDVImpl::computeIntervals() {
12621271 }
12631272}
12641273
1265- bool LDVImpl::runOnMachineFunction (MachineFunction &mf, bool InstrRef) {
1274+ bool LiveDebugVariables::LDVImpl::runOnMachineFunction (MachineFunction &mf,
1275+ bool InstrRef) {
12661276 clear ();
12671277 MF = &mf;
12681278 TRI = mf.getSubtarget ().getRegisterInfo ();
@@ -1323,7 +1333,7 @@ PreservedAnalyses
13231333LiveDebugVariablesPrinterPass::run (MachineFunction &MF,
13241334 MachineFunctionAnalysisManager &MFAM) {
13251335 auto &LDV = MFAM.getResult <LiveDebugVariablesAnalysis>(MF);
1326- LDV.print (dbgs () );
1336+ LDV.print (OS );
13271337 return PreservedAnalyses::all ();
13281338}
13291339
@@ -1478,7 +1488,8 @@ UserValue::splitRegister(Register OldReg, ArrayRef<Register> NewRegs,
14781488 return DidChange;
14791489}
14801490
1481- void LDVImpl::splitPHIRegister (Register OldReg, ArrayRef<Register> NewRegs) {
1491+ void LiveDebugVariables::LDVImpl::splitPHIRegister (Register OldReg,
1492+ ArrayRef<Register> NewRegs) {
14821493 auto RegIt = RegToPHIIdx.find (OldReg);
14831494 if (RegIt == RegToPHIIdx.end ())
14841495 return ;
@@ -1516,7 +1527,8 @@ void LDVImpl::splitPHIRegister(Register OldReg, ArrayRef<Register> NewRegs) {
15161527 RegToPHIIdx[RegAndInstr.first ].push_back (RegAndInstr.second );
15171528}
15181529
1519- void LDVImpl::splitRegister (Register OldReg, ArrayRef<Register> NewRegs) {
1530+ void LiveDebugVariables::LDVImpl::splitRegister (Register OldReg,
1531+ ArrayRef<Register> NewRegs) {
15201532 // Consider whether this split range affects any PHI locations.
15211533 splitPHIRegister (OldReg, NewRegs);
15221534
@@ -1840,7 +1852,7 @@ void UserLabel::emitDebugLabel(LiveIntervals &LIS, const TargetInstrInfo &TII,
18401852 LLVM_DEBUG (dbgs () << ' \n ' );
18411853}
18421854
1843- void LDVImpl::emitDebugValues (VirtRegMap *VRM) {
1855+ void LiveDebugVariables:: LDVImpl::emitDebugValues (VirtRegMap *VRM) {
18441856 LLVM_DEBUG (dbgs () << " ********** EMITTING LIVE DEBUG VARIABLES **********\n " );
18451857 if (!MF)
18461858 return ;
0 commit comments