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. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits