r202098 - IRGen: Simplify alignment calculation in setBitFieldInfo
David Majnemer
david.majnemer at gmail.com
Mon Feb 24 17:20:15 PST 2014
Author: majnemer
Date: Mon Feb 24 19:20:15 2014
New Revision: 202098
URL: http://llvm.org/viewvc/llvm-project?rev=202098&view=rev
Log:
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
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=202098&r1=202097&r2=202098&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Mon Feb 24 19:20:15 2014
@@ -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
More information about the cfe-commits
mailing list