Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[DebugInfo] Missing debug info for abstract classes with constexpr constructors with -flimited-debug-info #28247

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR28248
Status NEW
Importance P normal
Reported by Reid Kleckner (rnk@google.com)
Reported on 2016-06-21 15:14:42 -0700
Last modified on 2016-07-07 16:53:48 -0700
Version unspecified
Hardware PC Windows NT
CC dblaikie@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
While working on https://llvm.org/bugs/show_bug.cgi?id=28150, I noticed that
this C++ doesn't generate any debug info describing class 'A' in C++11:

struct A {
  virtual void f() = 0;
};
struct B : A {
  virtual void f() {}
};
B b;

On Windows, Clang defaults to C++11, so we don't get this debug info. I think
the C++11 aspect has to do with A's default constructor being constexpr. Adding
a user-defined ctor to A ensures that the debug info is emitted.
Quuxplusone commented 8 years ago

I guess this only happens if you initialize B in a global, because then we initialize it statically. If you make a B on the stack or with 'new', then we emit B's ctor, which calls A's ctor, which references A's vtable, and we get class debug info.

Maybe this isn't that high priority then.

Quuxplusone commented 8 years ago
Weird that we bother with a ctor in the other cases - though the static
initialization is only /required/ in the global case... *shrug*

But, yes, this is a bug (across platforms, shows up on non-windows as well,
when building with C++11). GCC gets this right, though I'm not sure exactly
what rules it uses to do so. Perhaps they just rely on the ctor being inlined
away, so they start off by generating all the assorted things, and thus
emitting the debug info for the type.

Running some experiments. But I guess the most general way to fix this would be
to wire the "requires vtable" stuff through the static initialization
optimization codepath so it still triggers in a way that's sufficient to
generate the debug info even though we never actually emit the ctor, vtable,
etc.