[llvm] [AsmPrinter][DebugNames] Implement DW_IDX_parent entries (PR #77457)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 14:10:11 PST 2024


dwblaikie wrote:

> > > C++ doesn't allow it, but clang does generate this for C++ when using type homing/`-fno-standalone-debug`. Try this:
> > > ```
> > > struct A {
> > >   A();
> > >   struct B { };
> > > };
> > > A::B b;
> > > ```
> > > 
> > > 
> > >     
> > >       
> > >     
> > > 
> > >       
> > >     
> > > 
> > >     
> > >   
> > > compiled with `-fno-standalone-debug` (or on a non-mac platform, where that's the default): https://godbolt.org/z/rYvPxPMcY
> > 
> > 
> > I was hoping to hear this response as I figured it must be, but wanted to make sure.
> 
> I wasn't aware of that flag, but we can probably fix it by saying: "If B's parent is a declaration, don't add B's parent offset" to the table, i.e., B won't have an IDX_Parent. This is needed so that we fallback to the mechanism of parsing the entire CU ([this upcoming commit](https://github.com/llvm/llvm-project/pull/77121/commits/996fcbf4edc27b657540ee27742408e886b54959) implements the query itself and the fallback mechanism)
> 
> Isn't this flag making it impossible to find `A` / destroying accelerator tables? Looking at the godbolt link, any queries for `A` in the accelerator table will return false, and debuggers will never find it, since accelerator tables are not allowed to produce false negatives (and they are not allowed to return declarations either)

Given that .debug_names were derived from .apple_names which never had to deal with this situation, it's possible there's missing features/incompatibilities to deal with.

So, for now, a `B` entry could, yeah, be missing its parent info and the consumer could find `B` then check parse some DIEs to check the parentage. Though finding the parents of a given DIE might be expensive/require more parsing - perhaps we could put an unnamed entry for `A` to refer to as the parent? Then it'd be relatively quick to check only that DIE to see what its name is?

https://github.com/llvm/llvm-project/pull/77457


More information about the llvm-commits mailing list