This is an archive of the discontinued LLVM Phabricator instance.

[CodeView] Implement support for bitfields in LLVM
ClosedPublic

Authored by majnemer on Jun 27 2016, 7:59 PM.

Details

Summary

CodeView need to know the offset of the storage allocation for a
bitfield. Encode this via the "extraData" field in DIDerivedType and
introduced a new flag, DIFlagBitField, to indicate whether or not a
member is a bitfield.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 62052.Jun 27 2016, 7:59 PM
majnemer retitled this revision from to [CodeView] Implement support for bitfields in LLVM.
majnemer updated this object.
majnemer added reviewers: rnk, aaboud.
majnemer added a subscriber: llvm-commits.
aaboud edited edge metadata.

Looks good.
I suggest to add a test that covers more cases, see below.
Also, need to apply changes to dwarf implementation (I think it does not cover the below case correctly today).

I am adding David Blaikie as a reviewer.

test/DebugInfo/COFF/bitfields.ll
3 ↗(On Diff #62052)

How about having full test of bitfield. This test contains only the last issue.
How about this one:

#pragma pack(1)
struct S1 {
  char x1[2];
  char x2;
  int y : 23;
  int z : 23;
  int w : 2;
  struct { char c; short s; } v;
  short u : 3;
} s1;

#pragma pack(1)
struct S2 {
  char : 0;
  int y : 1;
} s2;

#pragma pack(1)
struct S3 {
  char : 8;
  short : 8;
  short x : 8;
} s3;

Or at least parts of it.

majnemer updated this revision to Diff 62102.Jun 28 2016, 9:03 AM
majnemer edited edge metadata.
  • Address review feedback

Looks good.
I suggest to add a test that covers more cases, see below.
Also, need to apply changes to dwarf implementation (I think it does not cover the below case correctly today).

The DWARF side is not accurate for versions < v4 but this can be fixed in a latter change.

I am adding David Blaikie as a reviewer.

aaboud accepted this revision.Jun 28 2016, 12:13 PM
aaboud edited edge metadata.

LGTM.
Please update PR28162.

This revision is now accepted and ready to land.Jun 28 2016, 12:13 PM
This revision was automatically updated to reflect the committed changes.