This is an archive of the discontinued LLVM Phabricator instance.

[ARM/AArch64] Enforce alignment for bitfielded structs
ClosedPublic

Authored by bsmith on Apr 27 2015, 9:35 AM.

Details

Reviewers
rengolin
Summary

When creating a global variable with a type of a struct with bitfields, we must forcibly set the alignment of the global from the RecordDecl. We must do this so that the proper bitfield alignment makes its way down to LLVM, since clang will mangle the bitfields into one large type.

This patch feels like a bit of a hack to me, but honestly I'm not sure how else to go about making this change. This patch is a first attempt to address the problem described in the thread http://lists.cs.uiuc.edu/pipermail/cfe-dev/2015-April/042521.html.

(There is no testcase attached to this just yet I shall add one tomorrow, I just wanted to get this out for review early to see whether I'm approaching this the right way).

Diff Detail

Repository
rL LLVM

Event Timeline

bsmith updated this revision to Diff 24483.Apr 27 2015, 9:35 AM
bsmith retitled this revision from to [ARM/AArch64] Enforce alignment for bitfielded structs.
bsmith updated this object.
bsmith edited the test plan for this revision. (Show Details)
bsmith set the repository for this revision to rL LLVM.
bsmith added a subscriber: Unknown Object (MLST).

Doesn't Clang have some king of target description infrastructure? I'd guess that adding a new field / method to get the bitfield struct alignment would be the the best option.

bsmith updated this revision to Diff 24537.Apr 28 2015, 3:55 AM

Added testcase and removed triple check in favour of a TargetInfo query.

rengolin accepted this revision.Apr 28 2015, 4:01 AM
rengolin added a reviewer: rengolin.

Removing the redundant line, LGTM. Thanks!

lib/CodeGen/CodeGenModule.cpp
1806

redundant line?

This revision is now accepted and ready to land.Apr 28 2015, 4:01 AM
bsmith closed this revision.Apr 28 2015, 4:28 AM

Thanks, committed as r235976 (with redundant line removed).