Author: baldrick Date: Thu Jan 3 12:05:48 2008 New Revision: 45541 URL: http://llvm.org/viewvc/llvm-project?rev=45541&view=rev Log: In the case of a record field at a variable offset, the additional byte part of the bit offset needs to be incorporated into the offset pointer computation, otherwise the following logic may get confused, thinking the field must be a bitfield because bitstart is non-zero. The testcase is FrontendAda/var_offset.adb.
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=45541&r1=45540&r2=45541&view=diff ============================================================================== --- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Thu Jan 3 12:05:48 2008 @@ -5473,6 +5473,16 @@ } else { Value *Offset = Emit(field_offset, 0); + + // Here BitStart gives the offset of the field in bits from field_offset. + // Incorporate as much of it as possible into the pointer computation. + unsigned ByteOffset = BitStart/8; + if (ByteOffset > 0) { + Offset = Builder.CreateAdd(Offset, + ConstantInt::get(Offset->getType(), ByteOffset), "tmp"); + BitStart -= ByteOffset*8; + } + Value *Ptr = CastToType(Instruction::PtrToInt, StructAddrLV.Ptr, Offset->getType()); Ptr = Builder.CreateAdd(Ptr, Offset, "tmp"); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits