@@ -257,44 +257,23 @@ static DbgValueLoc getDebugLocValue(const MachineInstr *MI) {
257
257
return DbgValueLoc (Expr, DbgValueLocEntries, IsVariadic);
258
258
}
259
259
260
- // / Initialize from the MMI table.
261
- void DbgVariable::initializeMMI (const DIExpression *E, int FI) {
262
- assert (holds<std::monostate>() && " Already initialized" );
263
- assert ((!E || E->isValid ()) && " Expected valid expression" );
264
- assert (FI != std::numeric_limits<int >::max () && " Expected valid index" );
265
- emplace<MMILoc>().FrameIndexExprs .push_back ({FI, E});
260
+ Loc::Single::Single (DbgValueLoc ValueLoc)
261
+ : ValueLoc(std::make_unique<DbgValueLoc>(ValueLoc)),
262
+ Expr(ValueLoc.getExpression()) {
263
+ if (!Expr->getNumElements ())
264
+ Expr = nullptr ;
266
265
}
267
266
268
- void DbgVariable::initializeDbgValue (DbgValueLoc Value) {
269
- assert (holds<std::monostate>() && " Already initialized" );
270
- assert (!Value.getExpression ()->isFragment () && " Fragments not supported" );
271
- emplace<SingleLoc>(Value);
272
- }
273
-
274
- void DbgVariable::initializeDbgValue (const MachineInstr *DbgValue) {
275
- assert (holds<std::monostate>() && " Already initialized" );
276
- assert (getVariable () == DbgValue->getDebugVariable () && " Wrong variable" );
277
- assert (getInlinedAt () == DbgValue->getDebugLoc ()->getInlinedAt () &&
278
- " Wrong inlined-at" );
279
- emplace<SingleLoc>(getDebugLocValue (DbgValue));
280
- }
281
-
282
- void DbgVariable::initializeEntryValue (MCRegister Reg,
283
- const DIExpression &Expr) {
284
- assert (holds<std::monostate>() && " Already initialized?" );
285
- emplace<EntryValueLoc>(Reg, Expr);
286
- }
287
-
288
- ArrayRef<FrameIndexExpr> DbgVariable::getFrameIndexExprs () const {
289
- auto &FrameIndexExprs = get<MMILoc>().FrameIndexExprs ;
267
+ Loc::Single::Single (const MachineInstr *DbgValue)
268
+ : Single(getDebugLocValue(DbgValue)) {}
290
269
270
+ ArrayRef<FrameIndexExpr> Loc::MMI::getFrameIndexExprs () const {
291
271
if (FrameIndexExprs.size () == 1 )
292
272
return FrameIndexExprs;
293
273
294
- assert (llvm::all_of (FrameIndexExprs,
295
- [](const FrameIndexExpr &A) {
296
- return A.Expr ->isFragment ();
297
- }) &&
274
+ assert (llvm::all_of (
275
+ FrameIndexExprs,
276
+ [](const FrameIndexExpr &A) { return A.Expr ->isFragment (); }) &&
298
277
" multiple FI expressions without DW_OP_LLVM_fragment" );
299
278
llvm::sort (FrameIndexExprs,
300
279
[](const FrameIndexExpr &A, const FrameIndexExpr &B) -> bool {
@@ -305,9 +284,7 @@ ArrayRef<FrameIndexExpr> DbgVariable::getFrameIndexExprs() const {
305
284
return FrameIndexExprs;
306
285
}
307
286
308
- void DbgVariable::addMMIEntry (const DIExpression *Expr, int FI) {
309
- auto &FrameIndexExprs = get<MMILoc>().FrameIndexExprs ;
310
-
287
+ void Loc::MMI::addFrameIndexExpr (const DIExpression *Expr, int FI) {
311
288
// FIXME: This logic should not be necessary anymore, as we now have proper
312
289
// deduplication. However, without it, we currently run into the assertion
313
290
// below, which means that we are likely dealing with broken input, i.e. two
@@ -1570,19 +1547,20 @@ void DwarfDebug::collectVariableInfoFromMFTable(
1570
1547
ensureAbstractEntityIsCreatedIfScoped (TheCU, Var.first , Scope->getScopeNode ());
1571
1548
1572
1549
if (DbgVariable *DbgVar = MFVars.lookup (Var)) {
1573
- if (DbgVar-> hasFrameIndexExprs ( ))
1574
- DbgVar-> addMMIEntry (VI.Expr , VI.getStackSlot ());
1550
+ if (auto *MMI = std::get_if<Loc::MMI>(DbgVar ))
1551
+ MMI-> addFrameIndexExpr (VI.Expr , VI.getStackSlot ());
1575
1552
else
1576
- DbgVar->addEntryValueExpr (VI.getEntryValueRegister (), *VI.Expr );
1553
+ DbgVar->get <Loc::EntryValue>().addExpr (VI.getEntryValueRegister (),
1554
+ *VI.Expr );
1577
1555
continue ;
1578
1556
}
1579
1557
1580
1558
auto RegVar = std::make_unique<DbgVariable>(
1581
1559
cast<DILocalVariable>(Var.first ), Var.second );
1582
1560
if (VI.inStackSlot ())
1583
- RegVar->initializeMMI (VI.Expr , VI.getStackSlot ());
1561
+ RegVar->emplace <Loc::MMI> (VI.Expr , VI.getStackSlot ());
1584
1562
else
1585
- RegVar->initializeEntryValue (VI.getEntryValueRegister (), *VI.Expr );
1563
+ RegVar->emplace <Loc::EntryValue> (VI.getEntryValueRegister (), *VI.Expr );
1586
1564
LLVM_DEBUG (dbgs () << " Created DbgVariable for " << VI.Var ->getName ()
1587
1565
<< " \n " );
1588
1566
InfoHolder.addScopeVariable (Scope, RegVar.get ());
@@ -1921,7 +1899,7 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
1921
1899
const auto *End =
1922
1900
SingleValueWithClobber ? HistoryMapEntries[1 ].getInstr () : nullptr ;
1923
1901
if (validThroughout (LScopes, MInsn, End, getInstOrdering ())) {
1924
- RegVar->initializeDbgValue (MInsn);
1902
+ RegVar->emplace <Loc::Single> (MInsn);
1925
1903
continue ;
1926
1904
}
1927
1905
}
@@ -1931,7 +1909,7 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
1931
1909
continue ;
1932
1910
1933
1911
// Handle multiple DBG_VALUE instructions describing one variable.
1934
- DebugLocStream::ListBuilder List (DebugLocs, TheCU, *Asm, *RegVar, *MInsn );
1912
+ DebugLocStream::ListBuilder List (DebugLocs, TheCU, *Asm, *RegVar);
1935
1913
1936
1914
// Build the location list for this variable.
1937
1915
SmallVector<DebugLocEntry, 8 > Entries;
@@ -1941,7 +1919,7 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
1941
1919
// that is valid throughout the variable's scope. If so, produce single
1942
1920
// value location.
1943
1921
if (isValidSingleLocation) {
1944
- RegVar->initializeDbgValue (Entries[0 ].getValues ()[0 ]);
1922
+ RegVar->emplace <Loc::Single> (Entries[0 ].getValues ()[0 ]);
1945
1923
continue ;
1946
1924
}
1947
1925
0 commit comments