From a6c4a5032431908208fe439fe4a68fded636d197 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 25 Feb 2014 01:20:15 +0000 Subject: [PATCH] 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 --- lib/CodeGen/CGRecordLayoutBuilder.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index b93038c4d0..94d78fef3b 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -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 -- 2.40.0