[llvm-commits] [126856] Handle edge case, when starting offset for bit field
dpatel at apple.com
dpatel at apple.com
Thu May 3 17:31:01 PDT 2007
Revision: 126856
Author: dpatel
Date: 2007-05-03 17:31:00 -0700 (Thu, 03 May 2007)
Log Message:
-----------
Handle edge case, when starting offset for bit field
is outside allocated bytes and starting offset is not
at byte boundry.
Modified Paths:
--------------
apple-local/branches/llvm/gcc/llvm-types.cpp
Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-types.cpp 2007-05-04 00:26:47 UTC (rev 126855)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp 2007-05-04 00:31:00 UTC (rev 126856)
@@ -1384,10 +1384,11 @@
if (StartOffsetFromByteBoundry != 0) {
// New field does not start at byte boundry.
PadBits = StartOffsetInBits - (FirstUnallocatedByte*8);
- PadBytes = PadBits/8 + 1;
- }
+ PadBytes = PadBits/8;
+ PadBits = PadBits - PadBytes*8;
+ } else
+ PadBytes = StartOffsetInBits/8-FirstUnallocatedByte;
- PadBytes += StartOffsetInBits/8-FirstUnallocatedByte;
const Type *Pad = Type::Int8Ty;
if (PadBytes != 1)
Pad = ArrayType::get(Pad, PadBytes);
@@ -1396,7 +1397,7 @@
// This field will use some of the bits from this PadBytes, if
// starting offset is not at byte boundry.
if (StartOffsetFromByteBoundry != 0)
- FieldSizeInBits = FieldSizeInBits - (8 - PadBits);
+ FieldSizeInBits = PadBits;
}
// Now, Field starts at FirstUnallocatedByte and everything is aligned.
More information about the llvm-commits
mailing list