[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c
Chris Lattner
lattner at cs.uiuc.edu
Sun Jun 20 14:08:03 PDT 2004
Changes in directory llvm-gcc/gcc:
llvm-expand.c updated: 1.44 -> 1.45
---
Log message:
Fix PR377: http://llvm.cs.uiuc.edu/PR377 : [llvmgcc] miscompilation of staticly initialized unsigned bitfields
There were two bugs in this code. First, llvm_type_get_size returns #bytes, not
#bits. Second, we must use 1LL instead of 1 or else all bits get shifted out.
Testcase here: SingleSource/UnitTests/2004-06-20-StaticBitfieldInit.c
---
Diffs of the changes: (+3 -3)
Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.44 llvm-gcc/gcc/llvm-expand.c:1.45
--- llvm-gcc/gcc/llvm-expand.c:1.44 Fri Jun 18 22:35:20 2004
+++ llvm-gcc/gcc/llvm-expand.c Sun Jun 20 13:59:59 2004
@@ -3814,8 +3814,8 @@
/* If there is already a value set for this field, mask out any bits
* that are part of the current field (in case the current field is
- * multiply initialized to different values). The LLVM stuff should
- * constant propagate these operations.
+ * multiply initialized to different values). LLVM will constant fold
+ * all of the constant expressions generated.
*/
if (Result[FieldIndexVal]) {
long long MaskVal = ~(((1 << FieldSize)-1) << FieldOffset);
@@ -3825,7 +3825,7 @@
/* If this is an unsigned type, mask off bits outside the range of
the data type in question... */
if (!llvm_type_is_signed(FieldType))
- MaskVal &= (1 << llvm_type_get_size(FieldType))-1;
+ MaskVal &= (1LL << (llvm_type_get_size(FieldType)*8))-1;
Mask = llvm_constant_new_integral(FieldType, MaskVal);
Result[FieldIndexVal] =
More information about the llvm-commits
mailing list