LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 6 - Oversized integer bitfields
Summary: Oversized integer bitfields
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-gcc (show other bugs)
Version: 1.0
Hardware: All All
: P normal
Assignee: Chris Lattner
URL:
Keywords: compile-fail
Depends on:
Blocks:
 
Reported: 2003-10-07 14:07 PDT by Chris Lattner
Modified: 2010-02-22 12:53 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2003-10-07 14:07:41 PDT
Bug: llvm/test/Regression/CFrontend/2003-08-30-LargeIntegerBitfieldMember.c

Causes crash:
$ llvmgcc -c 2003-08-30-LargeIntegerBitfieldMember.c
UNKNOWN INTEGRAL TYPE SIZE: 984
2003-08-30-LargeIntegerBitfieldMember.c:9: internal compiler error: in
llvm_type_get_integer, at llvm-types.c:489
Comment 1 Misha Brukman 2003-11-13 17:37:55 PST
This bug prevents pine from compiling as "struct pine { ... }" contains
something resembling this test case as a subset.

Since this prevents Chris from using LLVM-pine, I'm escalating the bug to
"major". :)
Comment 2 Chris Lattner 2003-11-13 17:49:54 PST
Dood, in that case, this has got to be fixed by 1.1!!
Comment 3 Chris Lattner 2003-11-19 19:02:25 PST
(finally) Fixed.  Testcase: CFrontend/2003-08-30-LargeIntegerBitfieldMember.c

Patch:

$ diff -u llvm-types.c~ llvm-types.c
--- llvm-types.c~       2003-11-19 18:17:19.000000000 -0600
+++ llvm-types.c        2003-11-19 18:59:34.000000000 -0600
@@ -711,6 +711,23 @@
           *Size = 0;
       } while (*Idx && *Size > StartByte);
 
+      /* Output this as a series of integer fields. */
+      while (ElSize > 64) {
+        unsigned UnitSize = ElSize & 63;
+        /* Eliminate all but one bit from the size */
+        if ((UnitSize & (UnitSize-1)) != 0)
+          UnitSize = UnitSize ^ (UnitSize & (UnitSize-1));
+
+        if (UnitSize == 0) UnitSize = 64;
+
+        ElementTys[*Idx] = llvm_type_get_integer(UnitSize, 1);
+        ElementOffsets[*Idx] = StartByte;
+        ElementAlignments[*Idx] = 1;
+        ++*Idx;
+        StartByte += UnitSize/8;
+        ElSize -= UnitSize;
+      }
+
       Ty = llvm_type_get_integer(ElSize, !HasSignedField);
     }
 
-Chris