This is an archive of the discontinued LLVM Phabricator instance.

Override a bit fields layout from an external source
ClosedPublic

Authored by aleksandr.urakov on Jul 12 2018, 3:12 AM.

Details

Summary

This patch adds a possibility to use an external layout for bit fields.

The problem occurred while debugging a Windows application with PDB symbols. The structure was as follows:

struct S {
  short a : 3;
  short : 8;
  short b : 5;
}

The problem is that PDB doesn't have information about the unnamed bit field, so the field b was located just behind the field a. But PDB has a valid information about fields offsets, so we can use it to solve the problem.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner edited reviewers, added: compnerd, smeenai, rnk; removed: rsmith, arphaman, whunt.Jul 12 2018, 10:09 AM
smeenai resigned from this revision.Jul 12 2018, 4:31 PM

I'm not familiar enough with this to review it.

rsmith accepted this revision.Jul 12 2018, 4:51 PM
rsmith added a subscriber: rsmith.
rsmith added inline comments.
test/CodeGenCXX/override-bit-field-layout.cpp
5–12 ↗(On Diff #155135)

Another relevant test:

struct T {
  virtual void f();
  short x : 3;
};

Because we don't do vfptr layout adjustments when using an external layout source, I think this would have put x at offset 0 instead of at offset 8 prior to your patch.

This revision is now accepted and ready to land.Jul 12 2018, 4:51 PM
aleksandr.urakov marked an inline comment as done.Jul 12 2018, 11:47 PM

Thank you!

Yes, I have added a test case for that.

If it's OK, can you commit this for me, please? I have no commit access.

This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.