@@ -144,60 +144,6 @@ class LiveDebugValues : public MachineFunctionPass {
144
144
using FragmentInfo = DIExpression::FragmentInfo;
145
145
using OptFragmentInfo = Optional<DIExpression::FragmentInfo>;
146
146
147
- // / Storage for identifying a potentially inlined instance of a variable,
148
- // / or a fragment thereof.
149
- class DebugVariable {
150
- const DILocalVariable *Variable;
151
- OptFragmentInfo Fragment;
152
- const DILocation *InlinedAt;
153
-
154
- // / Fragment that will overlap all other fragments. Used as default when
155
- // / caller demands a fragment.
156
- static const FragmentInfo DefaultFragment;
157
-
158
- public:
159
- DebugVariable (const DILocalVariable *Var, OptFragmentInfo &&FragmentInfo,
160
- const DILocation *InlinedAt)
161
- : Variable(Var), Fragment(FragmentInfo), InlinedAt(InlinedAt) {}
162
-
163
- DebugVariable (const DILocalVariable *Var, OptFragmentInfo &FragmentInfo,
164
- const DILocation *InlinedAt)
165
- : Variable(Var), Fragment(FragmentInfo), InlinedAt(InlinedAt) {}
166
-
167
- DebugVariable (const DILocalVariable *Var, const DIExpression *DIExpr,
168
- const DILocation *InlinedAt)
169
- : DebugVariable(Var, DIExpr->getFragmentInfo (), InlinedAt) {}
170
-
171
- DebugVariable (const MachineInstr &MI)
172
- : DebugVariable(MI.getDebugVariable(),
173
- MI.getDebugExpression()->getFragmentInfo(),
174
- MI.getDebugLoc()->getInlinedAt()) {}
175
-
176
- const DILocalVariable *getVar () const { return Variable; }
177
- const OptFragmentInfo &getFragment () const { return Fragment; }
178
- const DILocation *getInlinedAt () const { return InlinedAt; }
179
-
180
- const FragmentInfo getFragmentDefault () const {
181
- return Fragment.getValueOr (DefaultFragment);
182
- }
183
-
184
- static bool isFragmentDefault (FragmentInfo &F) {
185
- return F == DefaultFragment;
186
- }
187
-
188
- bool operator ==(const DebugVariable &Other) const {
189
- return std::tie (Variable, Fragment, InlinedAt) ==
190
- std::tie (Other.Variable , Other.Fragment , Other.InlinedAt );
191
- }
192
-
193
- bool operator <(const DebugVariable &Other) const {
194
- return std::tie (Variable, Fragment, InlinedAt) <
195
- std::tie (Other.Variable , Other.Fragment , Other.InlinedAt );
196
- }
197
- };
198
-
199
- friend struct llvm ::DenseMapInfo<DebugVariable>;
200
-
201
147
// / A pair of debug variable and value location.
202
148
struct VarLoc {
203
149
// The location at which a spilled variable resides. It consists of a
@@ -241,8 +187,9 @@ class LiveDebugValues : public MachineFunctionPass {
241
187
} Loc;
242
188
243
189
VarLoc (const MachineInstr &MI, LexicalScopes &LS)
244
- : Var(MI), Expr(MI.getDebugExpression()), MI(MI),
245
- UVS (MI.getDebugLoc(), LS) {
190
+ : Var(MI.getDebugVariable(), MI.getDebugExpression(),
191
+ MI.getDebugLoc()->getInlinedAt ()),
192
+ Expr(MI.getDebugExpression()), MI(MI), UVS(MI.getDebugLoc(), LS) {
246
193
static_assert ((sizeof (Loc) == sizeof (uint64_t )),
247
194
" hash does not cover all members of Loc" );
248
195
assert (MI.isDebugValue () && " not a DBG_VALUE" );
@@ -370,7 +317,8 @@ class LiveDebugValues : public MachineFunctionPass {
370
317
llvm_unreachable (" Invalid VarLoc in dump method" );
371
318
}
372
319
373
- dbgs () << " , \" " << Var.getVar ()->getName () << " \" , " << *Expr << " , " ;
320
+ dbgs () << " , \" " << Var.getVariable ()->getName () << " \" , " << *Expr
321
+ << " , " ;
374
322
if (Var.getInlinedAt ())
375
323
dbgs () << " !" << Var.getInlinedAt ()->getMetadataID () << " )\n " ;
376
324
else
@@ -559,46 +507,10 @@ class LiveDebugValues : public MachineFunctionPass {
559
507
560
508
} // end anonymous namespace
561
509
562
- namespace llvm {
563
-
564
- template <> struct DenseMapInfo <LiveDebugValues::DebugVariable> {
565
- using DV = LiveDebugValues::DebugVariable;
566
- using OptFragmentInfo = LiveDebugValues::OptFragmentInfo;
567
- using FragmentInfo = LiveDebugValues::FragmentInfo;
568
-
569
- // Empty key: no key should be generated that has no DILocalVariable.
570
- static inline DV getEmptyKey () {
571
- return DV (nullptr , OptFragmentInfo (), nullptr );
572
- }
573
-
574
- // Difference in tombstone is that the Optional is meaningful
575
- static inline DV getTombstoneKey () {
576
- return DV (nullptr , OptFragmentInfo ({0 , 0 }), nullptr );
577
- }
578
-
579
- static unsigned getHashValue (const DV &D) {
580
- unsigned HV = 0 ;
581
- const OptFragmentInfo &Fragment = D.getFragment ();
582
- if (Fragment)
583
- HV = DenseMapInfo<FragmentInfo>::getHashValue (*Fragment);
584
-
585
- return hash_combine (D.getVar (), HV, D.getInlinedAt ());
586
- }
587
-
588
- static bool isEqual (const DV &A, const DV &B) { return A == B; }
589
- };
590
-
591
- } // namespace llvm
592
-
593
510
// ===----------------------------------------------------------------------===//
594
511
// Implementation
595
512
// ===----------------------------------------------------------------------===//
596
513
597
- const DIExpression::FragmentInfo
598
- LiveDebugValues::DebugVariable::DefaultFragment = {
599
- std::numeric_limits<uint64_t >::max (),
600
- std::numeric_limits<uint64_t >::min ()};
601
-
602
514
char LiveDebugValues::ID = 0 ;
603
515
604
516
char &llvm::LiveDebugValuesID = LiveDebugValues::ID;
@@ -636,17 +548,17 @@ void LiveDebugValues::OpenRangesSet::erase(DebugVariable Var) {
636
548
637
549
// Extract the fragment. Interpret an empty fragment as one that covers all
638
550
// possible bits.
639
- FragmentInfo ThisFragment = Var.getFragmentDefault ();
551
+ FragmentInfo ThisFragment = Var.getFragmentOrDefault ();
640
552
641
553
// There may be fragments that overlap the designated fragment. Look them up
642
554
// in the pre-computed overlap map, and erase them too.
643
- auto MapIt = OverlappingFragments.find ({Var.getVar (), ThisFragment});
555
+ auto MapIt = OverlappingFragments.find ({Var.getVariable (), ThisFragment});
644
556
if (MapIt != OverlappingFragments.end ()) {
645
557
for (auto Fragment : MapIt->second ) {
646
558
LiveDebugValues::OptFragmentInfo FragmentHolder;
647
- if (!DebugVariable::isFragmentDefault (Fragment))
559
+ if (!DebugVariable::isDefaultFragment (Fragment))
648
560
FragmentHolder = LiveDebugValues::OptFragmentInfo (Fragment);
649
- DoErase ({Var.getVar (), FragmentHolder, Var.getInlinedAt ()});
561
+ DoErase ({Var.getVariable (), FragmentHolder, Var.getInlinedAt ()});
650
562
}
651
563
}
652
564
}
@@ -669,7 +581,7 @@ void LiveDebugValues::printVarLocInMBB(const MachineFunction &MF,
669
581
Out << " MBB: " << BB.getNumber () << " :\n " ;
670
582
for (unsigned VLL : L) {
671
583
const VarLoc &VL = VarLocIDs[VLL];
672
- Out << " Var: " << VL.Var .getVar ()->getName ();
584
+ Out << " Var: " << VL.Var .getVariable ()->getName ();
673
585
Out << " MI: " ;
674
586
VL.dump (TRI, Out);
675
587
}
@@ -735,7 +647,7 @@ void LiveDebugValues::emitEntryValues(MachineInstr &MI,
735
647
DebugParamMap &DebugEntryVals,
736
648
SparseBitVector<> &KillSet) {
737
649
for (unsigned ID : KillSet) {
738
- if (!VarLocIDs[ID].Var .getVar ()->isParameter ())
650
+ if (!VarLocIDs[ID].Var .getVariable ()->isParameter ())
739
651
continue ;
740
652
741
653
const MachineInstr *CurrDebugInstr = &VarLocIDs[ID].MI ;
@@ -773,7 +685,9 @@ void LiveDebugValues::insertTransferDebugPair(
773
685
unsigned LocId = VarLocIDs.insert (VL);
774
686
775
687
// Close this variable's previous location range.
776
- DebugVariable V (*DebugInstr);
688
+ DebugVariable V (DebugInstr->getDebugVariable (),
689
+ DebugInstr->getDebugExpression (),
690
+ DebugInstr->getDebugLoc ()->getInlinedAt ());
777
691
OpenRanges.erase (V);
778
692
779
693
// Record the new location as an open range, and a postponed transfer
@@ -1005,12 +919,12 @@ void LiveDebugValues::transferSpillOrRestoreInst(MachineInstr &MI,
1005
919
if (TKind == TransferKind::TransferSpill &&
1006
920
VarLocIDs[ID].isDescribedByReg () == Reg) {
1007
921
LLVM_DEBUG (dbgs () << " Spilling Register " << printReg (Reg, TRI) << ' ('
1008
- << VarLocIDs[ID].Var .getVar ()->getName () << " )\n " );
922
+ << VarLocIDs[ID].Var .getVariable ()->getName () << " )\n " );
1009
923
} else if (TKind == TransferKind::TransferRestore &&
1010
924
VarLocIDs[ID].Kind == VarLoc::SpillLocKind &&
1011
925
VarLocIDs[ID].Loc .SpillLocation == *Loc) {
1012
926
LLVM_DEBUG (dbgs () << " Restoring Register " << printReg (Reg, TRI) << ' ('
1013
- << VarLocIDs[ID].Var .getVar ()->getName () << " )\n " );
927
+ << VarLocIDs[ID].Var .getVariable ()->getName () << " )\n " );
1014
928
} else
1015
929
continue ;
1016
930
insertTransferDebugPair (MI, OpenRanges, Transfers, VarLocIDs, ID, TKind,
@@ -1099,26 +1013,27 @@ bool LiveDebugValues::transferTerminator(MachineBasicBlock *CurMBB,
1099
1013
void LiveDebugValues::accumulateFragmentMap (MachineInstr &MI,
1100
1014
VarToFragments &SeenFragments,
1101
1015
OverlapMap &OverlappingFragments) {
1102
- DebugVariable MIVar (MI);
1103
- FragmentInfo ThisFragment = MIVar.getFragmentDefault ();
1016
+ DebugVariable MIVar (MI.getDebugVariable (), MI.getDebugExpression (),
1017
+ MI.getDebugLoc ()->getInlinedAt ());
1018
+ FragmentInfo ThisFragment = MIVar.getFragmentOrDefault ();
1104
1019
1105
1020
// If this is the first sighting of this variable, then we are guaranteed
1106
1021
// there are currently no overlapping fragments either. Initialize the set
1107
1022
// of seen fragments, record no overlaps for the current one, and return.
1108
- auto SeenIt = SeenFragments.find (MIVar.getVar ());
1023
+ auto SeenIt = SeenFragments.find (MIVar.getVariable ());
1109
1024
if (SeenIt == SeenFragments.end ()) {
1110
1025
SmallSet<FragmentInfo, 4 > OneFragment;
1111
1026
OneFragment.insert (ThisFragment);
1112
- SeenFragments.insert ({MIVar.getVar (), OneFragment});
1027
+ SeenFragments.insert ({MIVar.getVariable (), OneFragment});
1113
1028
1114
- OverlappingFragments.insert ({{MIVar.getVar (), ThisFragment}, {}});
1029
+ OverlappingFragments.insert ({{MIVar.getVariable (), ThisFragment}, {}});
1115
1030
return ;
1116
1031
}
1117
1032
1118
1033
// If this particular Variable/Fragment pair already exists in the overlap
1119
1034
// map, it has already been accounted for.
1120
1035
auto IsInOLapMap =
1121
- OverlappingFragments.insert ({{MIVar.getVar (), ThisFragment}, {}});
1036
+ OverlappingFragments.insert ({{MIVar.getVariable (), ThisFragment}, {}});
1122
1037
if (!IsInOLapMap.second )
1123
1038
return ;
1124
1039
@@ -1136,7 +1051,7 @@ void LiveDebugValues::accumulateFragmentMap(MachineInstr &MI,
1136
1051
// Mark the previously seen fragment as being overlapped by the current
1137
1052
// one.
1138
1053
auto ASeenFragmentsOverlaps =
1139
- OverlappingFragments.find ({MIVar.getVar (), ASeenFragment});
1054
+ OverlappingFragments.find ({MIVar.getVariable (), ASeenFragment});
1140
1055
assert (ASeenFragmentsOverlaps != OverlappingFragments.end () &&
1141
1056
" Previously seen var fragment has no vector of overlaps" );
1142
1057
ASeenFragmentsOverlaps->second .push_back (ThisFragment);
@@ -1201,7 +1116,7 @@ bool LiveDebugValues::join(
1201
1116
if (!InLocsT.empty ()) {
1202
1117
for (auto ID : InLocsT)
1203
1118
dbgs () << " gathered candidate incoming var: "
1204
- << VarLocIDs[ID].Var .getVar ()->getName () << " \n " ;
1119
+ << VarLocIDs[ID].Var .getVariable ()->getName () << " \n " ;
1205
1120
}
1206
1121
});
1207
1122
@@ -1216,7 +1131,7 @@ bool LiveDebugValues::join(
1216
1131
if (!VarLocIDs[ID].dominates (MBB)) {
1217
1132
KillSet.set (ID);
1218
1133
LLVM_DEBUG ({
1219
- auto Name = VarLocIDs[ID].Var .getVar ()->getName ();
1134
+ auto Name = VarLocIDs[ID].Var .getVariable ()->getName ();
1220
1135
dbgs () << " killing " << Name << " , it doesn't dominate MBB\n " ;
1221
1136
});
1222
1137
}
0 commit comments