[llvm-commits] [llvm-gcc-4.2] r45535 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Thu Jan 3 03:58:49 PST 2008


Author: baldrick
Date: Thu Jan  3 05:58:46 2008
New Revision: 45535

URL: http://llvm.org/viewvc/llvm-project?rev=45535&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.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=45535&r1=45534&r2=45535&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Jan  3 05:58:46 2008
@@ -5021,6 +5021,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");





More information about the llvm-commits mailing list