From 33af7a8f50d6de317aa86849d7593c4cc31bb23e Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 30 Mar 2015 23:21:21 +0000 Subject: LexicalScopes: Use debug info hierarchy pervasively Pervasively use the types provided by the debug info hierarchy rather than `MDNode` in `LexicalScopes`. I noticed (again, I guess, based on comments in the implementation?) that `DILexicalBlockFile::getScope()` returns something different from `DILexicalBlockFile::getContext()`. I created a local helper for getting the same logic from `MDLexicalBlockFile` called `getScopeOfScope()`. I still don't really understand it, but I've added some FIXMEs and I'll come back to it (I suspect the way we encode these objects isn't really ideal). Note that my previous commit r233610 accidentally changed behaviour in `findLexicalScope()` -- it transitioned from a call to `DILexicalBlockFile::getScope()` to `MDLexicalBlockFile::getScope()` (sounds right, doesn't it?) -- so I've fixed that as a drive-by. No tests failed with my error, so it looks like we're missing some coverage here... when I come back to understand the logic, I'll see if I can add some. Other than the fix to `findLexicalScope()`, no functionality change. llvm-svn: 233640 --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 9303865d7ca..00bd0ec660a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -704,7 +704,8 @@ void DwarfDebug::ensureAbstractVariableIsCreated(const DIVariable &DV, if (getExistingAbstractVariable(DV, Cleansed)) return; - createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope(ScopeNode)); + createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope( + cast(ScopeNode))); } void @@ -714,7 +715,8 @@ DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(const DIVariable &DV, if (getExistingAbstractVariable(DV, Cleansed)) return; - if (LexicalScope *Scope = LScopes.findAbstractScope(ScopeNode)) + if (LexicalScope *Scope = + LScopes.findAbstractScope(cast_or_null(ScopeNode))) createAbstractVariable(Cleansed, Scope); } @@ -901,10 +903,10 @@ DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP, continue; LexicalScope *Scope = nullptr; - if (MDNode *IA = DV.getInlinedAt()) - Scope = LScopes.findInlinedScope(DV.getContext(), IA); + if (MDLocation *IA = DV.get()->getInlinedAt()) + Scope = LScopes.findInlinedScope(DV.get()->getScope(), IA); else - Scope = LScopes.findLexicalScope(DV.getContext()); + Scope = LScopes.findLexicalScope(DV.get()->getScope()); // If variable scope is not found then skip this variable. if (!Scope) continue; @@ -943,7 +945,7 @@ DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP, assert(DV.isVariable()); if (!Processed.insert(DV).second) continue; - if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext())) { + if (LexicalScope *Scope = LScopes.findLexicalScope(DV.get()->getScope())) { ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode()); DIExpression NoExpr; ConcreteVariables.push_back(make_unique(DV, NoExpr, this)); -- cgit v1.2.3