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

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 24 13:30:07 PST 2021


rnk added a comment.

To help bikeshed the name, I can imagine a few other use cases:

- an attribute to suppress type info emission, never emit full type info for this type (similar to nodebug / artificial attributes for functions) -- this could help optimize debug info size
- an attribute to always emit type information, whether it is required to be complete or not (similar to -fno-eliminate-unused-types behavior)
- non-use-case: It's not clear if it's useful to have an attribute to explicitly indicate that a type should use the vptr, constructor, or extern template heuristics.

I thought maybe we could have a single attribute that takes a mode, something like `emit_debug_type_info("never/always/when_required_complete/with_ctor/with_vtable")`. Or maybe shorter is better: `emit_typeinfo("when_required_complete")`. But that sounds like we're talking about RTTI, not debug info.



================
Comment at: clang/include/clang/Basic/Attr.td:1666
+  let Subjects = SubjectList<[CXXRecord]>;
+  let Documentation = [Undocumented];
+  let SimpleHandler = 1;
----------------
I understand that this patch is mainly to open discussion, but we should document the attribute before landing the patch.


================
Comment at: clang/test/CodeGenCXX/force-debug-attribute.cpp:10-11
+
+// Struct that isn't constructed, so its full type info should be omitted with
+// -debug-info-kind=constructor.
+struct DEBUGASNEEDED some_struct {
----------------
This attribute should also work with vtable and extern template instantiation type homing, right? So for example, I would see this template type in the debug info in the standard compilation modes as well:
  template <typename T> struct Foo { Foo() {} T x; };
  extern template struct DEBUGASNEEDED Foo<int>; // I expect to see a complete Foo<int> DICompositeType


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