[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 24 15:50:10 PST 2021


dblaikie added a comment.

In D97411#2586055 <https://reviews.llvm.org/D97411#2586055>, @rnk wrote:

> I expected nodebug already applied to types, even though the documentation says it only affects variables and functions. We should update the docs.

Now that I think about it more, the only thing I made it work for is typedefs, not whole structs - it'd be trickier to do it for a whole struct (what happens if you have a member of that type in another struct? Does it leave a black hole?) - but easy for a typedef: any reference to the typedef is instead a direct reference to the underlying type.

> I think if we already have `nodebug` spelling, we don't need to make something general with modes. The "always emit" use case is fairly weak. It's easy to drop in a `static_assert(sizeof(Ty) > 0, "emit type info");` to get type info if you want it.

I don't think that static_assert would cause 'Ty' to be emitted - at least for DWARF/ELF I don't know of a way to force a type to be used that doesn't generate any code, for instance.

> If we're looking at a no-argument attribute, my naming ideas lean towards incorporating "required [to be] complete" in the name. There are many ways that one can "use" or "require" a type that work fine with a forward declaration. Something like `emit_debug_typeinfo_if_required_complete`? Still too big? `emit_debug_if_required_complete`?

Oh, that might be a bit different again - if the type isn't required to be complete in this translation unit, should this attribute override the "required to be complete" homing strategy? (that's the oldest standing strategy - if the type isn't required to be complete, the definition is omitted) I'd have thought this should override that behavior too. Perhaps the type is never dereferenced, but is somehow still useful (eg: you might have one translation unit that only uses handles, and another translation unit that never has a variable of that type (maybe deals with void*) and casts to the defined type and dereferences it - that would break the "required to be complete" homing strategy (though it's unlikely/weird - if you're passing around void* it's unlikely your caller would somehow see and use the declared type anyway))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411



More information about the cfe-commits mailing list