Skip to content
Snippets Groups Projects
Commit a6c4a503 authored by David Majnemer's avatar David Majnemer
Browse files

IRGen: Simplify alignment calculation in setBitFieldInfo

Take advantage of CharUnits::alignmentAtOffset instead of calculating it
by hand.

Differential Revision: http://llvm-reviews.chandlerc.com/D2862


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202098 91177308-0d34-0410-b5e6-96231b3b80d8
parent 5b7370af
No related branches found
No related tags found
No related merge requests found
......@@ -220,10 +220,8 @@ void CGRecordLowering::setBitFieldInfo(
// Here we calculate the actual storage alignment of the bits. E.g if we've
// got an alignment >= 2 and the bitfield starts at offset 6 we've got an
// alignment of 2.
Info.StorageAlignment = (unsigned)(
StartOffset % Layout.getAlignment() ?
1ll << llvm::countTrailingZeros((uint64_t)StartOffset.getQuantity()) :
Layout.getAlignment().getQuantity());
Info.StorageAlignment =
Layout.getAlignment().alignmentAtOffset(StartOffset).getQuantity();
if (Info.Size > Info.StorageSize)
Info.Size = Info.StorageSize;
// Reverse the bit offsets for big endian machines. Because we represent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment