Skip to content

Commit 414ceff

Browse files
committed
[NFC][AsmPrinter] Remove dead multi-MMI handling from DwarfFile::addScopeVariable
Differential Revision: https://reviews.llvm.org/D158676
1 parent 58c108c commit 414ceff

File tree

4 files changed

+22
-33
lines changed

4 files changed

+22
-33
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,8 @@ ArrayRef<FrameIndexExpr> DbgVariable::getFrameIndexExprs() const {
305305
return FrameIndexExprs;
306306
}
307307

308-
void DbgVariable::addMMIEntry(const DbgVariable &V) {
309-
assert(V.getVariable() == getVariable() && "conflicting variable");
310-
assert(V.getInlinedAt() == getInlinedAt() && "conflicting inlined-at location");
311-
308+
void DbgVariable::addMMIEntry(const DIExpression *Expr, int FI) {
312309
auto &FrameIndexExprs = get<MMILoc>().FrameIndexExprs;
313-
auto &VFrameIndexExprs = V.get<MMILoc>().FrameIndexExprs;
314310

315311
// FIXME: This logic should not be necessary anymore, as we now have proper
316312
// deduplication. However, without it, we currently run into the assertion
@@ -322,12 +318,10 @@ void DbgVariable::addMMIEntry(const DbgVariable &V) {
322318
return;
323319
}
324320

325-
for (const auto &FIE : VFrameIndexExprs)
326-
// Ignore duplicate entries.
327-
if (llvm::none_of(FrameIndexExprs, [&](const FrameIndexExpr &Other) {
328-
return FIE.FI == Other.FI && FIE.Expr == Other.Expr;
329-
}))
330-
FrameIndexExprs.push_back(FIE);
321+
if (llvm::none_of(FrameIndexExprs, [&](const FrameIndexExpr &Other) {
322+
return FI == Other.FI && Expr == Other.Expr;
323+
}))
324+
FrameIndexExprs.push_back({FI, Expr});
331325

332326
assert((FrameIndexExprs.size() == 1 ||
333327
llvm::all_of(FrameIndexExprs,
@@ -1574,6 +1568,15 @@ void DwarfDebug::collectVariableInfoFromMFTable(
15741568
}
15751569

15761570
ensureAbstractEntityIsCreatedIfScoped(TheCU, Var.first, Scope->getScopeNode());
1571+
1572+
if (DbgVariable *DbgVar = MFVars.lookup(Var)) {
1573+
if (DbgVar->hasFrameIndexExprs())
1574+
DbgVar->addMMIEntry(VI.Expr, VI.getStackSlot());
1575+
else
1576+
DbgVar->addEntryValueExpr(VI.getEntryValueRegister(), *VI.Expr);
1577+
continue;
1578+
}
1579+
15771580
auto RegVar = std::make_unique<DbgVariable>(
15781581
cast<DILocalVariable>(Var.first), Var.second);
15791582
if (VI.inStackSlot())
@@ -1582,16 +1585,9 @@ void DwarfDebug::collectVariableInfoFromMFTable(
15821585
RegVar->initializeEntryValue(VI.getEntryValueRegister(), *VI.Expr);
15831586
LLVM_DEBUG(dbgs() << "Created DbgVariable for " << VI.Var->getName()
15841587
<< "\n");
1585-
1586-
if (DbgVariable *DbgVar = MFVars.lookup(Var)) {
1587-
if (DbgVar->hasFrameIndexExprs())
1588-
DbgVar->addMMIEntry(*RegVar);
1589-
else
1590-
DbgVar->addEntryValueExpr(VI.getEntryValueRegister(), *VI.Expr);
1591-
} else if (InfoHolder.addScopeVariable(Scope, RegVar.get())) {
1592-
MFVars.insert({Var, RegVar.get()});
1593-
ConcreteEntities.push_back(std::move(RegVar));
1594-
}
1588+
InfoHolder.addScopeVariable(Scope, RegVar.get());
1589+
MFVars.insert({Var, RegVar.get()});
1590+
ConcreteEntities.push_back(std::move(RegVar));
15951591
}
15961592
}
15971593

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class DbgVariable : public DbgEntity,
278278
/// Get the FI entries, sorted by fragment offset.
279279
ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
280280
bool hasFrameIndexExprs() const { return holds<MMILoc>(); }
281-
void addMMIEntry(const DbgVariable &V);
281+
void addMMIEntry(const DIExpression *Expr, int FI);
282282

283283
// Translate tag to proper Dwarf tag.
284284
dwarf::Tag getTag() const {

llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,15 @@ void DwarfFile::emitStrings(MCSection *StrSection, MCSection *OffsetSection,
102102
StrPool.emit(*Asm, StrSection, OffsetSection, UseRelativeOffsets);
103103
}
104104

105-
bool DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
105+
void DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
106106
auto &ScopeVars = ScopeVariables[LS];
107107
const DILocalVariable *DV = Var->getVariable();
108108
if (unsigned ArgNum = DV->getArg()) {
109-
auto Cached = ScopeVars.Args.find(ArgNum);
110-
if (Cached == ScopeVars.Args.end())
111-
ScopeVars.Args[ArgNum] = Var;
112-
else {
113-
Cached->second->addMMIEntry(*Var);
114-
return false;
115-
}
109+
auto Ret = ScopeVars.Args.insert({ArgNum, Var});
110+
assert(Ret.second);
116111
} else {
117112
ScopeVars.Locals.push_back(Var);
118113
}
119-
return true;
120114
}
121115

122116
void DwarfFile::addScopeLabel(LexicalScope *LS, DbgLabel *Label) {

llvm/lib/CodeGen/AsmPrinter/DwarfFile.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ class DwarfFile {
150150
MCSymbol *getRnglistsTableBaseSym() const { return RnglistsTableBaseSym; }
151151
void setRnglistsTableBaseSym(MCSymbol *Sym) { RnglistsTableBaseSym = Sym; }
152152

153-
/// \returns false if the variable was merged with a previous one.
154-
bool addScopeVariable(LexicalScope *LS, DbgVariable *Var);
153+
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
155154

156155
void addScopeLabel(LexicalScope *LS, DbgLabel *Label);
157156

0 commit comments

Comments
 (0)