@@ -1429,7 +1429,7 @@ bool InstrRefBasedLDV::transferDebugValue(const MachineInstr &MI) {
1429
1429
1430
1430
std::optional<ValueIDNum> InstrRefBasedLDV::getValueForInstrRef (
1431
1431
unsigned InstNo, unsigned OpNo, MachineInstr &MI,
1432
- const ValueTable *MLiveOuts, const ValueTable *MLiveIns) {
1432
+ const FuncValueTable *MLiveOuts, const FuncValueTable *MLiveIns) {
1433
1433
// Various optimizations may have happened to the value during codegen,
1434
1434
// recorded in the value substitution table. Apply any substitutions to
1435
1435
// the instruction / operand number in this DBG_INSTR_REF, and collect
@@ -1495,7 +1495,8 @@ std::optional<ValueIDNum> InstrRefBasedLDV::getValueForInstrRef(
1495
1495
} else if (PHIIt != DebugPHINumToValue.end () && PHIIt->InstrNum == InstNo) {
1496
1496
// It's actually a PHI value. Which value it is might not be obvious, use
1497
1497
// the resolver helper to find out.
1498
- NewID = resolveDbgPHIs (*MI.getParent ()->getParent (), MLiveOuts, MLiveIns,
1498
+ assert (MLiveOuts && MLiveIns);
1499
+ NewID = resolveDbgPHIs (*MI.getParent ()->getParent (), *MLiveOuts, *MLiveIns,
1499
1500
MI, InstNo);
1500
1501
}
1501
1502
@@ -1574,8 +1575,8 @@ std::optional<ValueIDNum> InstrRefBasedLDV::getValueForInstrRef(
1574
1575
}
1575
1576
1576
1577
bool InstrRefBasedLDV::transferDebugInstrRef (MachineInstr &MI,
1577
- const ValueTable *MLiveOuts,
1578
- const ValueTable *MLiveIns) {
1578
+ const FuncValueTable *MLiveOuts,
1579
+ const FuncValueTable *MLiveIns) {
1579
1580
if (!MI.isDebugRef ())
1580
1581
return false ;
1581
1582
@@ -2245,8 +2246,9 @@ void InstrRefBasedLDV::accumulateFragmentMap(MachineInstr &MI) {
2245
2246
AllSeenFragments.insert (ThisFragment);
2246
2247
}
2247
2248
2248
- void InstrRefBasedLDV::process (MachineInstr &MI, const ValueTable *MLiveOuts,
2249
- const ValueTable *MLiveIns) {
2249
+ void InstrRefBasedLDV::process (MachineInstr &MI,
2250
+ const FuncValueTable *MLiveOuts,
2251
+ const FuncValueTable *MLiveIns) {
2250
2252
// Try to interpret an MI as a debug or transfer instruction. Only if it's
2251
2253
// none of these should we interpret it's register defs as new value
2252
2254
// definitions.
@@ -3503,7 +3505,10 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit(
3503
3505
// Helper lambda for ejecting a block -- if nothing is going to use the block,
3504
3506
// we can translate the variable location information into DBG_VALUEs and then
3505
3507
// free all of InstrRefBasedLDV's data structures.
3508
+ SmallPtrSet<const MachineBasicBlock *, 8 > EjectedBBs;
3506
3509
auto EjectBlock = [&](MachineBasicBlock &MBB) -> void {
3510
+ if (EjectedBBs.insert (&MBB).second == false )
3511
+ return ;
3507
3512
unsigned BBNum = MBB.getNumber ();
3508
3513
AllTheVLocs[BBNum].clear ();
3509
3514
@@ -3517,14 +3522,14 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit(
3517
3522
CurBB = BBNum;
3518
3523
CurInst = 1 ;
3519
3524
for (auto &MI : MBB) {
3520
- process (MI, MOutLocs. get (), MInLocs. get () );
3525
+ process (MI, & MOutLocs, & MInLocs);
3521
3526
TTracker->checkInstForNewValues (CurInst, MI.getIterator ());
3522
3527
++CurInst;
3523
3528
}
3524
3529
3525
3530
// Free machine-location tables for this block.
3526
- MInLocs[BBNum]. reset ();
3527
- MOutLocs[BBNum]. reset ();
3531
+ MInLocs[BBNum] = ValueTable ();
3532
+ MOutLocs[BBNum] = ValueTable ();
3528
3533
// We don't need live-in variable values for this block either.
3529
3534
Output[BBNum].clear ();
3530
3535
AllTheVLocs[BBNum].clear ();
@@ -3589,8 +3594,7 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit(
3589
3594
// anything for such out-of-scope blocks, but for the sake of being similar
3590
3595
// to VarLocBasedLDV, eject these too.
3591
3596
for (auto *MBB : ArtificialBlocks)
3592
- if (MOutLocs[MBB->getNumber ()])
3593
- EjectBlock (*MBB);
3597
+ EjectBlock (*MBB);
3594
3598
3595
3599
return emitTransfers (AllVarsNumbering);
3596
3600
}
@@ -3688,14 +3692,9 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
3688
3692
// Allocate and initialize two array-of-arrays for the live-in and live-out
3689
3693
// machine values. The outer dimension is the block number; while the inner
3690
3694
// dimension is a LocIdx from MLocTracker.
3691
- FuncValueTable MOutLocs = std::make_unique<ValueTable[]>(MaxNumBlocks);
3692
- FuncValueTable MInLocs = std::make_unique<ValueTable[]>(MaxNumBlocks);
3693
3695
unsigned NumLocs = MTracker->getNumLocs ();
3694
- for (int i = 0 ; i < MaxNumBlocks; ++i) {
3695
- // These all auto-initialize to ValueIDNum::EmptyValue
3696
- MOutLocs[i] = std::make_unique<ValueIDNum[]>(NumLocs);
3697
- MInLocs[i] = std::make_unique<ValueIDNum[]>(NumLocs);
3698
- }
3696
+ FuncValueTable MOutLocs (MaxNumBlocks, ValueTable (NumLocs));
3697
+ FuncValueTable MInLocs (MaxNumBlocks, ValueTable (NumLocs));
3699
3698
3700
3699
// Solve the machine value dataflow problem using the MLocTransfer function,
3701
3700
// storing the computed live-ins / live-outs into the array-of-arrays. We use
@@ -3736,7 +3735,7 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
3736
3735
MTracker->loadFromArray (MInLocs[CurBB], CurBB);
3737
3736
CurInst = 1 ;
3738
3737
for (auto &MI : MBB) {
3739
- process (MI, MOutLocs. get (), MInLocs. get () );
3738
+ process (MI, & MOutLocs, & MInLocs);
3740
3739
++CurInst;
3741
3740
}
3742
3741
MTracker->reset ();
@@ -3917,9 +3916,9 @@ class LDVSSAUpdater {
3917
3916
// / Machine location where any PHI must occur.
3918
3917
LocIdx Loc;
3919
3918
// / Table of live-in machine value numbers for blocks / locations.
3920
- const ValueTable * MLiveIns;
3919
+ const FuncValueTable & MLiveIns;
3921
3920
3922
- LDVSSAUpdater (LocIdx L, const ValueTable * MLiveIns)
3921
+ LDVSSAUpdater (LocIdx L, const FuncValueTable & MLiveIns)
3923
3922
: Loc(L), MLiveIns(MLiveIns) {}
3924
3923
3925
3924
void reset () {
@@ -4075,12 +4074,8 @@ template <> class SSAUpdaterTraits<LDVSSAUpdater> {
4075
4074
} // end namespace llvm
4076
4075
4077
4076
std::optional<ValueIDNum> InstrRefBasedLDV::resolveDbgPHIs (
4078
- MachineFunction &MF, const ValueTable *MLiveOuts,
4079
- const ValueTable *MLiveIns, MachineInstr &Here, uint64_t InstrNum) {
4080
- assert (MLiveOuts && MLiveIns &&
4081
- " Tried to resolve DBG_PHI before location "
4082
- " tables allocated?" );
4083
-
4077
+ MachineFunction &MF, const FuncValueTable &MLiveOuts,
4078
+ const FuncValueTable &MLiveIns, MachineInstr &Here, uint64_t InstrNum) {
4084
4079
// This function will be called twice per DBG_INSTR_REF, and might end up
4085
4080
// computing lots of SSA information: memoize it.
4086
4081
auto SeenDbgPHIIt = SeenDbgPHIs.find (std::make_pair (&Here, InstrNum));
@@ -4094,8 +4089,8 @@ std::optional<ValueIDNum> InstrRefBasedLDV::resolveDbgPHIs(
4094
4089
}
4095
4090
4096
4091
std::optional<ValueIDNum> InstrRefBasedLDV::resolveDbgPHIsImpl (
4097
- MachineFunction &MF, const ValueTable * MLiveOuts,
4098
- const ValueTable * MLiveIns, MachineInstr &Here, uint64_t InstrNum) {
4092
+ MachineFunction &MF, const FuncValueTable & MLiveOuts,
4093
+ const FuncValueTable & MLiveIns, MachineInstr &Here, uint64_t InstrNum) {
4099
4094
// Pick out records of DBG_PHI instructions that have been observed. If there
4100
4095
// are none, then we cannot compute a value number.
4101
4096
auto RangePair = std::equal_range (DebugPHINumToValue.begin (),
0 commit comments