[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)

Juan Manuel Martinez CaamaƱo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 9 07:34:33 PST 2023


jmmartinez added a comment.

Just a few minor comments. Everything else seems good to me.



================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:698
+  // an inlined function: if a local variable has a templated type with
+  // a function-local type as a template parameter. See PR55680 for details.
+  if (!Scope->isAbstractScope() && !Scope->getInlinedAt()) {
----------------
I cannot find the link to PR55680. Would you mind sharing it?

You could also reference `local-type-as-template-parameter.ll`, your test depicts the issue very clearly.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:700-701
+  if (!Scope->isAbstractScope() && !Scope->getInlinedAt()) {
+    if (LexicalBlockDIEs.count(DS)) {
+      ScopeDIE = LexicalBlockDIEs[DS];
+      assert(!ScopeDIE->findAttribute(dwarf::DW_AT_low_pc) &&
----------------
NIT: You could use `find` to avoid searching in `LexicalBlockDIEs` twice.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:712-714
+      assert(!getAbstractScopeDIEs().count(DS) &&
+             "Abstract DIE for this scope exists!");
+      getAbstractScopeDIEs()[DS] = ScopeDIE;
----------------
NIT: You could use `insert/try_emplace` instead of using `count` and `operator[]`. The assertion would become something like:
```
auto Inserted = getAbstractScopeDIEs().try_emplace(DS, ScopeDIE);
assert(Inserted.second && "Abstract DIE for this scope exists!");
return ScopeDIE;
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144006/new/

https://reviews.llvm.org/D144006



More information about the cfe-commits mailing list