This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Improvements to representation of enumeration types (PR36168)
ClosedPublic

Authored by chill on Jan 31 2018, 6:39 AM.

Details

Summary

This is the clang counterpart to https://reviews.llvm.org/D42734

This patch:

  • fixed an incorrect sign-extension of unsigned values, when emitting debug info metadata for enumerators
  • the enumerators metadata is created with a flag, which determines interpretation of the value bits (signed or unsigned)
  • the enumerations metadata contains the underlying integer type and a flag, indicating whether this is a C++ "fixed enum"

Diff Detail

Event Timeline

chill created this revision.Jan 31 2018, 6:39 AM
aprantl accepted this revision.Jan 31 2018, 9:29 AM
This revision is now accepted and ready to land.Jan 31 2018, 9:29 AM
dblaikie added inline comments.Jan 31 2018, 11:05 AM
lib/CodeGen/CGDebugInfo.cpp
2491–2495

Move this "IsSigned" outside the loop, since it's loop invariant?

chill updated this revision to Diff 132414.Feb 1 2018, 9:39 AM

Minor update, the parameter to createEnumerator is IsUnsigned now (instead of IsSigned), changed caller.

chill marked an inline comment as done.Feb 1 2018, 9:40 AM
dblaikie added inline comments.Feb 1 2018, 10:05 AM
test/CodeGen/debug-info-enum.cpp
2

Could you summarize the purpose of each of these tests (possibly in a comment above the enum in each case) - there look to be more test cases than I'd imagine being necessary, but I haven't carefully analyzed them.

For example: I wouldn't expect to test every integer type, if the code handling them is general enough to be demonstrated by one or two cases?

6–10

Rather than relying on specific ordering of output, generally you should test that the actual references across different metadata records are correct (eg: check that the DICompositeType's member list elements are the DIEnumerators (use named matches, rather than hardcoding the metadata node numbers))

Though, admittedly, this is a lot easier to read as-is.

66

Probably drop the "flags: " part of this NOT check - so that if other flags are added, this won't be overly constrained (eg: if this type ended up with "flags: X | DIFlagFixedEnum" this NOT check as-is wouldn't catch the regression)

chill updated this revision to Diff 132587.Feb 2 2018, 7:32 AM

Changes, relative to the previous revision:

  • a few tweaks to the tests
chill marked 3 inline comments as done.Feb 2 2018, 7:41 AM
chill added inline comments.
test/CodeGen/debug-info-enum.cpp
2

Yes, in hindsight, there are more tests that strictly necessary, I just enumerated all the different integer type sizes cross signed/usigned, for some there were no errors, for some there were always errors, for some there were sometimes errors only sometimes (i.e. depending on compiler target and/or options).

6–10

I've done that, to some extent, making sure each enumeration refers to the expected underlying type. Not idea how to do that completely independent of order.

chill marked 2 inline comments as done.Feb 2 2018, 8:12 AM
dblaikie accepted this revision.Feb 2 2018, 5:14 PM

Few things that could tidy up the tests a bit, but otherwise looks good :)

test/CodeGen/debug-info-enum.cpp
6–10

Thanks! Maybe add a comment (like I suggested in the LLVM review too, just now) in each case to describe each test case. You have one up the top for the enum class over signed char, but someting similar for each enum might be good.

Yeah, it's impossible to do it entirely independent of order.

You could do a bit more than what you've got here - the DIEnumerators could be checked:

match the list from the DICompositeType enumeration_type (the same way you match the baseType) then match the elements of the list, then match those elements to the DIEnumerators same as you do for the DIBasicType) - does that make sense?

chill updated this revision to Diff 132822.Feb 5 2018, 6:54 AM

Changes since last revision:

  • Add/update test to check that each enumerator belongs to the right enumeration
chill marked an inline comment as done.Feb 5 2018, 6:54 AM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.