@@ -286,6 +286,8 @@ namespace {
286
286
// / user values are related if they are held by the same virtual register. The
287
287
// / equivalence class is the transitive closure of that relation.
288
288
class UserValue {
289
+ using LDVImpl = LiveDebugVariables::LDVImpl;
290
+
289
291
const DILocalVariable *Variable; // /< The debug info variable we are part of.
290
292
// / The part of the variable we describe.
291
293
const std::optional<DIExpression::FragmentInfo> Fragment;
@@ -534,7 +536,12 @@ class UserLabel {
534
536
namespace llvm {
535
537
536
538
// / 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 {
538
545
LocMap::Allocator allocator;
539
546
MachineFunction *MF = nullptr ;
540
547
LiveIntervals *LIS;
@@ -756,7 +763,7 @@ void UserLabel::print(raw_ostream &OS, const TargetRegisterInfo *TRI) {
756
763
OS << ' \n ' ;
757
764
}
758
765
759
- void LDVImpl::print (raw_ostream &OS) {
766
+ void LiveDebugVariables:: LDVImpl::print (raw_ostream &OS) {
760
767
OS << " ********** DEBUG VARIABLES **********\n " ;
761
768
for (auto &userValue : userValues)
762
769
userValue->print (OS, TRI);
@@ -765,16 +772,15 @@ void LDVImpl::print(raw_ostream &OS) {
765
772
userLabel->print (OS, TRI);
766
773
}
767
774
768
- void UserValue::mapVirtRegs (LDVImpl *LDV) {
775
+ void UserValue::mapVirtRegs (LiveDebugVariables:: LDVImpl *LDV) {
769
776
for (const MachineOperand &MO : locations)
770
777
if (MO.isReg () && MO.getReg ().isVirtual ())
771
778
LDV->mapVirtReg (MO.getReg (), this );
772
779
}
773
780
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) {
778
784
// FIXME: Handle partially overlapping fragments. See
779
785
// https://reviews.llvm.org/D70121#1849741.
780
786
DebugVariable ID (Var, Fragment, DL->getInlinedAt ());
@@ -787,19 +793,20 @@ LDVImpl::getUserValue(const DILocalVariable *Var,
787
793
return UV;
788
794
}
789
795
790
- void LDVImpl::mapVirtReg (Register VirtReg, UserValue *EC) {
796
+ void LiveDebugVariables:: LDVImpl::mapVirtReg (Register VirtReg, UserValue *EC) {
791
797
assert (VirtReg.isVirtual () && " Only map VirtRegs" );
792
798
UserValue *&Leader = virtRegToEqClass[VirtReg];
793
799
Leader = UserValue::merge (Leader, EC);
794
800
}
795
801
796
- UserValue *LDVImpl::lookupVirtReg (Register VirtReg) {
802
+ UserValue *LiveDebugVariables:: LDVImpl::lookupVirtReg (Register VirtReg) {
797
803
if (UserValue *UV = virtRegToEqClass.lookup (VirtReg))
798
804
return UV->getLeader ();
799
805
return nullptr ;
800
806
}
801
807
802
- bool LDVImpl::handleDebugValue (MachineInstr &MI, SlotIndex Idx) {
808
+ bool LiveDebugVariables::LDVImpl::handleDebugValue (MachineInstr &MI,
809
+ SlotIndex Idx) {
803
810
// DBG_VALUE loc, offset, variable, expr
804
811
// DBG_VALUE_LIST variable, expr, locs...
805
812
if (!MI.isDebugValue ()) {
@@ -875,8 +882,8 @@ bool LDVImpl::handleDebugValue(MachineInstr &MI, SlotIndex Idx) {
875
882
return true ;
876
883
}
877
884
878
- MachineBasicBlock::iterator LDVImpl::handleDebugInstr (MachineInstr &MI,
879
- SlotIndex Idx) {
885
+ MachineBasicBlock::iterator
886
+ LiveDebugVariables::LDVImpl::handleDebugInstr (MachineInstr &MI, SlotIndex Idx) {
880
887
assert (MI.isDebugValueLike () || MI.isDebugPHI ());
881
888
882
889
// In instruction referencing mode, there should be no DBG_VALUE instructions
@@ -896,7 +903,8 @@ MachineBasicBlock::iterator LDVImpl::handleDebugInstr(MachineInstr &MI,
896
903
return NextInst;
897
904
}
898
905
899
- bool LDVImpl::handleDebugLabel (MachineInstr &MI, SlotIndex Idx) {
906
+ bool LiveDebugVariables::LDVImpl::handleDebugLabel (MachineInstr &MI,
907
+ SlotIndex Idx) {
900
908
// DBG_LABEL label
901
909
if (MI.getNumOperands () != 1 || !MI.getOperand (0 ).isMetadata ()) {
902
910
LLVM_DEBUG (dbgs () << " Can't handle " << MI);
@@ -919,7 +927,8 @@ bool LDVImpl::handleDebugLabel(MachineInstr &MI, SlotIndex Idx) {
919
927
return true ;
920
928
}
921
929
922
- bool LDVImpl::collectDebugValues (MachineFunction &mf, bool InstrRef) {
930
+ bool LiveDebugVariables::LDVImpl::collectDebugValues (MachineFunction &mf,
931
+ bool InstrRef) {
923
932
bool Changed = false ;
924
933
for (MachineBasicBlock &MBB : mf) {
925
934
for (MachineBasicBlock::iterator MBBI = MBB.begin (), MBBE = MBB.end ();
@@ -1252,7 +1261,7 @@ void UserValue::computeIntervals(MachineRegisterInfo &MRI,
1252
1261
I.setStopUnchecked (PrevEnd);
1253
1262
}
1254
1263
1255
- void LDVImpl::computeIntervals () {
1264
+ void LiveDebugVariables:: LDVImpl::computeIntervals () {
1256
1265
LexicalScopes LS;
1257
1266
LS.initialize (*MF);
1258
1267
@@ -1262,7 +1271,8 @@ void LDVImpl::computeIntervals() {
1262
1271
}
1263
1272
}
1264
1273
1265
- bool LDVImpl::runOnMachineFunction (MachineFunction &mf, bool InstrRef) {
1274
+ bool LiveDebugVariables::LDVImpl::runOnMachineFunction (MachineFunction &mf,
1275
+ bool InstrRef) {
1266
1276
clear ();
1267
1277
MF = &mf;
1268
1278
TRI = mf.getSubtarget ().getRegisterInfo ();
@@ -1323,7 +1333,7 @@ PreservedAnalyses
1323
1333
LiveDebugVariablesPrinterPass::run (MachineFunction &MF,
1324
1334
MachineFunctionAnalysisManager &MFAM) {
1325
1335
auto &LDV = MFAM.getResult <LiveDebugVariablesAnalysis>(MF);
1326
- LDV.print (dbgs () );
1336
+ LDV.print (OS );
1327
1337
return PreservedAnalyses::all ();
1328
1338
}
1329
1339
@@ -1478,7 +1488,8 @@ UserValue::splitRegister(Register OldReg, ArrayRef<Register> NewRegs,
1478
1488
return DidChange;
1479
1489
}
1480
1490
1481
- void LDVImpl::splitPHIRegister (Register OldReg, ArrayRef<Register> NewRegs) {
1491
+ void LiveDebugVariables::LDVImpl::splitPHIRegister (Register OldReg,
1492
+ ArrayRef<Register> NewRegs) {
1482
1493
auto RegIt = RegToPHIIdx.find (OldReg);
1483
1494
if (RegIt == RegToPHIIdx.end ())
1484
1495
return ;
@@ -1516,7 +1527,8 @@ void LDVImpl::splitPHIRegister(Register OldReg, ArrayRef<Register> NewRegs) {
1516
1527
RegToPHIIdx[RegAndInstr.first ].push_back (RegAndInstr.second );
1517
1528
}
1518
1529
1519
- void LDVImpl::splitRegister (Register OldReg, ArrayRef<Register> NewRegs) {
1530
+ void LiveDebugVariables::LDVImpl::splitRegister (Register OldReg,
1531
+ ArrayRef<Register> NewRegs) {
1520
1532
// Consider whether this split range affects any PHI locations.
1521
1533
splitPHIRegister (OldReg, NewRegs);
1522
1534
@@ -1840,7 +1852,7 @@ void UserLabel::emitDebugLabel(LiveIntervals &LIS, const TargetInstrInfo &TII,
1840
1852
LLVM_DEBUG (dbgs () << ' \n ' );
1841
1853
}
1842
1854
1843
- void LDVImpl::emitDebugValues (VirtRegMap *VRM) {
1855
+ void LiveDebugVariables:: LDVImpl::emitDebugValues (VirtRegMap *VRM) {
1844
1856
LLVM_DEBUG (dbgs () << " ********** EMITTING LIVE DEBUG VARIABLES **********\n " );
1845
1857
if (!MF)
1846
1858
return ;
0 commit comments