[llvm] 414ceff - [NFC][AsmPrinter] Remove dead multi-MMI handling from DwarfFile::addScopeVariable
Scott Linder via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 10:33:04 PDT 2023
Author: Scott Linder
Date: 2023-09-11T17:31:59Z
New Revision: 414ceffc9e8bd2cf0f3e357e7f0509acec8a593c
URL: https://github.com/llvm/llvm-project/commit/414ceffc9e8bd2cf0f3e357e7f0509acec8a593c
DIFF: https://github.com/llvm/llvm-project/commit/414ceffc9e8bd2cf0f3e357e7f0509acec8a593c.diff
LOG: [NFC][AsmPrinter] Remove dead multi-MMI handling from DwarfFile::addScopeVariable
Differential Revision: https://reviews.llvm.org/D158676
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 5f48b51046290f..6abf5ff7dbae8f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -305,12 +305,8 @@ ArrayRef<FrameIndexExpr> DbgVariable::getFrameIndexExprs() const {
return FrameIndexExprs;
}
-void DbgVariable::addMMIEntry(const DbgVariable &V) {
- assert(V.getVariable() == getVariable() && "conflicting variable");
- assert(V.getInlinedAt() == getInlinedAt() && "conflicting inlined-at location");
-
+void DbgVariable::addMMIEntry(const DIExpression *Expr, int FI) {
auto &FrameIndexExprs = get<MMILoc>().FrameIndexExprs;
- auto &VFrameIndexExprs = V.get<MMILoc>().FrameIndexExprs;
// FIXME: This logic should not be necessary anymore, as we now have proper
// deduplication. However, without it, we currently run into the assertion
@@ -322,12 +318,10 @@ void DbgVariable::addMMIEntry(const DbgVariable &V) {
return;
}
- for (const auto &FIE : VFrameIndexExprs)
- // Ignore duplicate entries.
- if (llvm::none_of(FrameIndexExprs, [&](const FrameIndexExpr &Other) {
- return FIE.FI == Other.FI && FIE.Expr == Other.Expr;
- }))
- FrameIndexExprs.push_back(FIE);
+ if (llvm::none_of(FrameIndexExprs, [&](const FrameIndexExpr &Other) {
+ return FI == Other.FI && Expr == Other.Expr;
+ }))
+ FrameIndexExprs.push_back({FI, Expr});
assert((FrameIndexExprs.size() == 1 ||
llvm::all_of(FrameIndexExprs,
@@ -1574,6 +1568,15 @@ void DwarfDebug::collectVariableInfoFromMFTable(
}
ensureAbstractEntityIsCreatedIfScoped(TheCU, Var.first, Scope->getScopeNode());
+
+ if (DbgVariable *DbgVar = MFVars.lookup(Var)) {
+ if (DbgVar->hasFrameIndexExprs())
+ DbgVar->addMMIEntry(VI.Expr, VI.getStackSlot());
+ else
+ DbgVar->addEntryValueExpr(VI.getEntryValueRegister(), *VI.Expr);
+ continue;
+ }
+
auto RegVar = std::make_unique<DbgVariable>(
cast<DILocalVariable>(Var.first), Var.second);
if (VI.inStackSlot())
@@ -1582,16 +1585,9 @@ void DwarfDebug::collectVariableInfoFromMFTable(
RegVar->initializeEntryValue(VI.getEntryValueRegister(), *VI.Expr);
LLVM_DEBUG(dbgs() << "Created DbgVariable for " << VI.Var->getName()
<< "\n");
-
- if (DbgVariable *DbgVar = MFVars.lookup(Var)) {
- if (DbgVar->hasFrameIndexExprs())
- DbgVar->addMMIEntry(*RegVar);
- else
- DbgVar->addEntryValueExpr(VI.getEntryValueRegister(), *VI.Expr);
- } else if (InfoHolder.addScopeVariable(Scope, RegVar.get())) {
- MFVars.insert({Var, RegVar.get()});
- ConcreteEntities.push_back(std::move(RegVar));
- }
+ InfoHolder.addScopeVariable(Scope, RegVar.get());
+ MFVars.insert({Var, RegVar.get()});
+ ConcreteEntities.push_back(std::move(RegVar));
}
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 7bede4e0df9e05..a77a8b883284f3 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -278,7 +278,7 @@ class DbgVariable : public DbgEntity,
/// Get the FI entries, sorted by fragment offset.
ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
bool hasFrameIndexExprs() const { return holds<MMILoc>(); }
- void addMMIEntry(const DbgVariable &V);
+ void addMMIEntry(const DIExpression *Expr, int FI);
// Translate tag to proper Dwarf tag.
dwarf::Tag getTag() const {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
index 3fe437a07c9202..070fcf894f64f0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
@@ -102,21 +102,15 @@ void DwarfFile::emitStrings(MCSection *StrSection, MCSection *OffsetSection,
StrPool.emit(*Asm, StrSection, OffsetSection, UseRelativeOffsets);
}
-bool DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
+void DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
auto &ScopeVars = ScopeVariables[LS];
const DILocalVariable *DV = Var->getVariable();
if (unsigned ArgNum = DV->getArg()) {
- auto Cached = ScopeVars.Args.find(ArgNum);
- if (Cached == ScopeVars.Args.end())
- ScopeVars.Args[ArgNum] = Var;
- else {
- Cached->second->addMMIEntry(*Var);
- return false;
- }
+ auto Ret = ScopeVars.Args.insert({ArgNum, Var});
+ assert(Ret.second);
} else {
ScopeVars.Locals.push_back(Var);
}
- return true;
}
void DwarfFile::addScopeLabel(LexicalScope *LS, DbgLabel *Label) {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
index 464f4f048016df..f76858fc2f36a0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
@@ -150,8 +150,7 @@ class DwarfFile {
MCSymbol *getRnglistsTableBaseSym() const { return RnglistsTableBaseSym; }
void setRnglistsTableBaseSym(MCSymbol *Sym) { RnglistsTableBaseSym = Sym; }
- /// \returns false if the variable was merged with a previous one.
- bool addScopeVariable(LexicalScope *LS, DbgVariable *Var);
+ void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
void addScopeLabel(LexicalScope *LS, DbgLabel *Label);
More information about the llvm-commits
mailing list