[PATCH] IRGen: Simplify alignment calculation in setBitFieldInfo
David Majnemer
david.majnemer at gmail.com
Fri Feb 21 23:57:51 PST 2014
Hi whunt,
Take advantage of CharUnits::alignmentAtOffset instead of calculating it
by hand.
http://llvm-reviews.chandlerc.com/D2862
Files:
lib/CodeGen/CGRecordLayoutBuilder.cpp
Index: lib/CodeGen/CGRecordLayoutBuilder.cpp
===================================================================
--- lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -220,10 +220,8 @@
// 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2862.1.patch
Type: text/x-patch
Size: 854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140221/79a6c1fb/attachment.bin>
More information about the cfe-commits
mailing list