This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Add size to class declarations in debug info.
ClosedPublic

Authored by akhuang on Sep 2 2020, 3:42 PM.

Details

Summary

This adds the size to forward declared class DITypes, if the size is known.

Fixes an issue where we determine whether to emit fragments based on the
type size, so fragments would sometimes be incorrectly emitted if there
was no size.

Bug: https://bugs.llvm.org/show_bug.cgi?id=47338

Diff Detail

Event Timeline

akhuang created this revision.Sep 2 2020, 3:42 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 2 2020, 3:42 PM
akhuang requested review of this revision.Sep 2 2020, 3:42 PM
dblaikie added inline comments.Sep 2 2020, 4:09 PM
clang/lib/CodeGen/CGDebugInfo.cpp
1035

When is a definition not a complete definition? (sounds like a line from Alice in Wonderland... but I'm genuinely curious/not sure I understand)

llvm/lib/Transforms/Scalar/SROA.cpp
4537–4538 ↗(On Diff #289596)

This is probably a sligthly larger/separate project/patch - @aprantl would it be reasonable to add this as an LLVM IR debug info metadata invariant/tested in the debug info verifier?

(in terms of patch order, I guess:

  1. ignoring the size, if present, on declarations in the backend
  2. adding the size in the frontend
  3. adding an invariant/verifier check that the size is always specified on types of variables with locations - and changing this code here to assert rather than test

But happy to review at least 1 and 2 in this review, though they could/should still be committed separately - the third's probably involved enough to merit a separate review, I'd hazard a guess)

llvm/test/DebugInfo/X86/struct-fwd-decl.ll
19 ↗(On Diff #289596)

Probably CHECK-NOT DW_AT_byte_size again, and CHECK: DW_TAG so that even if the fields are reordered a byte_size can't slip in anywhere.

akhuang added inline comments.Sep 2 2020, 4:52 PM
clang/lib/CodeGen/CGDebugInfo.cpp
1035

ha, good question, I copied this without really looking at it. I am also not sure when a definition would not be a complete definition.

llvm/lib/Transforms/Scalar/SROA.cpp
4537–4538 ↗(On Diff #289596)

I just tried adding a verifier check to see what happens, but it looks like incomplete arrays have locations but no size?

I can split out 1 into another patch.

akhuang updated this revision to Diff 289602.Sep 2 2020, 4:58 PM
akhuang marked an inline comment as done.

remove assert; edit test case

akhuang edited the summary of this revision. (Show Details)Sep 3 2020, 11:03 AM
dblaikie accepted this revision.Sep 3 2020, 12:01 PM

Looks good, thanks!

This revision is now accepted and ready to land.Sep 3 2020, 12:01 PM
akhuang added inline comments.Sep 3 2020, 3:41 PM
clang/lib/CodeGen/CGDebugInfo.cpp
1035

Oh, I guess incomplete definition means it's in the process of being defined.

This revision was landed with ongoing or failed builds.Sep 3 2020, 3:43 PM
This revision was automatically updated to reflect the committed changes.