Michael137 added a comment.

In D131335#3709788 <https://reviews.llvm.org/D131335#3709788>, @labath wrote:

> I haven't been able to keep up with all the lldb happenings lately, so it's 
> possible I have missed something, but can you give a summary (or point me to 
> one) of what is the problem with abi tags in lldb. For example, why isn't the 
> DW_AT_linkage_name string sufficient to find the correct function?
>
> I am somewhat sceptical that this is the best way to fix this problem. As 
> you've said yourself, the "alternate name" machinery is a last resort, and 
> the things that it's doing are wrong on several levels (and quite slow). To 
> tell the truth, I've been hoping that we could get rid of it completely one 
> day. Relying on this mechanism for "core" functionality would preclude that 
> from happening...

Unqualified lookup of template functions currently always resorts this 
"fall-back" mechanism. I investigated this mainly with `import-std-module` 
enabled since those were the tests that failed due to D127444 
<https://reviews.llvm.org/D127444>. There are two parts to it:

1. During unqualified lookup `clang::Sema` asks LLDB for the decl corresponding 
to the template in question. `DWARFASTParserClang` adds two decls to the AST, 
one non-template `FunctionDecl` marked `extern` and another 
`TemplateFunctionDecl`. Because of unqualified lookup rules in C++ 
`clang::Sema` picks the extern FunctionDecl. This is why the generated IR has 
an unresolved symbol that we then try to find in the object files.

2. When resolving this external symbol we try to match mangled function names 
using the hand-rolled `CPlusPlusNameParser` which doesn't support ABI tags and 
we fail to find a suitable symbol.

We can fish out the ABI tag from the `DW_AT_linkage_name` when parsing DWARF 
but we would still fail at (2). The plan was to address both. First reduce the 
reliance on `CPlusPlusNameParser` since that fixes the unqualified lookup issue 
trivially and is more robust to C++ syntax changes/attribute additions/etc. And 
then address the unqualified template lookup which has had numerous workarounds 
added to it over the years (https://reviews.llvm.org/D33025, 
 https://reviews.llvm.org/D61044, https://reviews.llvm.org/D75761, etc.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131335

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to