[llvm-branch-commits] [llvm-gcc-branch] r106688 - in /llvm-gcc-4.2/branches/Apple/Morbo: ./ gcc/llvm-convert.cpp

Stuart Hastings stuart at apple.com
Wed Jun 23 14:52:43 PDT 2010


Author: stuart
Date: Wed Jun 23 16:52:43 2010
New Revision: 106688

URL: http://llvm.org/viewvc/llvm-project?rev=106688&view=rev
Log:
Morbonification of r106611 and r106612.  Radars 7992077 and 8093043.

Modified:
    llvm-gcc-4.2/branches/Apple/Morbo/   (props changed)
    llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp

Propchange: llvm-gcc-4.2/branches/Apple/Morbo/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 23 16:52:43 2010
@@ -1,2 +1,2 @@
 /llvm/trunk:100565
-/llvm-gcc-4.2/trunk:98728,98841,98893,99196,99305,99592-99593,99629,99670,99982,99984-99986,99988,99992-99993,99995,99997-99999,100035,100149,100303,100565,100624-100626,100712,100721,101090-101091,101199,101216,101304,101333,101804,101959,102139,102148,102433,102444,102506-102507,102511,102532,102561,102589,102636,102648,102745,103361,103366-103367,103394,103414,103644,103800,103918,104181,104384,104420,104423,104726,105504,105828-105829,105902,105948-105949,106005,106243-106244,106270,106352,106564,106681
+/llvm-gcc-4.2/trunk:98728,98841,98893,99196,99305,99592-99593,99629,99670,99982,99984-99986,99988,99992-99993,99995,99997-99999,100035,100149,100303,100565,100624-100626,100712,100721,101090-101091,101199,101216,101304,101333,101804,101959,102139,102148,102433,102444,102506-102507,102511,102532,102561,102589,102636,102648,102745,103361,103366-103367,103394,103414,103644,103800,103918,104181,104384,104420,104423,104726,105504,105828-105829,105902,105948-105949,106005,106243-106244,106270,106352,106564,106611-106612,106681

Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp?rev=106688&r1=106687&r2=106688&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp Wed Jun 23 16:52:43 2010
@@ -8328,6 +8328,7 @@
   unsigned HOST_WIDE_INT CtorIndex;
   tree FieldValue;
   tree Field; // The FIELD_DECL for the field.
+
   FOR_EACH_CONSTRUCTOR_ELT(CONSTRUCTOR_ELTS(exp), CtorIndex, Field, FieldValue){
     // If an explicit field is specified, use it.
     if (Field == 0) {
@@ -8341,30 +8342,40 @@
       }
     }
 
-    // Decode the field's value.
-    Constant *Val = Convert(FieldValue);
-
     // GCCFieldOffsetInBits is where GCC is telling us to put the current field.
     uint64_t GCCFieldOffsetInBits = getFieldOffsetInBits(Field);
     NextField = TREE_CHAIN(Field);
 
     uint64_t FieldSizeInBits = 0;
-    if (DECL_SIZE(Field))
+    uint64_t ValueSizeInBits = 0;
+    Constant *Val = 0;
+    ConstantInt *ValC = 0;
+    
+    // Zero-sized bitfields upset the type converter.  If it's not a
+    // bit-field, or it is a bit-field but it has a non-zero precision
+    // type, go ahead and convert it.
+    if (!DECL_BIT_FIELD_TYPE(Field) || TYPE_PRECISION(TREE_TYPE(Field)))
+      Val = Convert(FieldValue);        // Decode the field's value.
+
+    if (DECL_SIZE(Field)) {
       FieldSizeInBits = getInt64(DECL_SIZE(Field), true);
-    uint64_t ValueSizeInBits = Val->getType()->getPrimitiveSizeInBits();
-    ConstantInt *ValC = dyn_cast<ConstantInt>(Val);
-    if (ValC && ValC->isZero() && DECL_SIZE(Field)) {
-      // G++ has various bugs handling {} initializers where it doesn't
-      // synthesize a zero node of the right type.  Instead of figuring out G++,
-      // just hack around it by special casing zero and allowing it to be the
-      // wrong size.
-      if (ValueSizeInBits != FieldSizeInBits) {
-        APInt ValAsInt = ValC->getValue();
-        ValC = ConstantInt::get(Context, ValueSizeInBits < FieldSizeInBits ?
-                                         ValAsInt.zext(FieldSizeInBits) :
-                                         ValAsInt.trunc(FieldSizeInBits));
-        ValueSizeInBits = FieldSizeInBits;
-        Val = ValC;
+      if (FieldSizeInBits == 0)
+        continue;       // Skip zero-sized fields.
+      ValueSizeInBits = Val->getType()->getPrimitiveSizeInBits();
+      ValC = dyn_cast<ConstantInt>(Val);
+      if (ValC && ValC->isZero()) {
+        // G++ has various bugs handling {} initializers where it doesn't
+        // synthesize a zero node of the right type.  Instead of figuring out G++,
+        // just hack around it by special casing zero and allowing it to be the
+        // wrong size.
+        if (ValueSizeInBits != FieldSizeInBits) {
+          APInt ValAsInt = ValC->getValue();
+          ValC = ConstantInt::get(Context, ValueSizeInBits < FieldSizeInBits ?
+                                  ValAsInt.zext(FieldSizeInBits) :
+                                  ValAsInt.trunc(FieldSizeInBits));
+          ValueSizeInBits = FieldSizeInBits;
+          Val = ValC;
+        }
       }
     }
 





More information about the llvm-branch-commits mailing list