[llvm-commits] [dragonegg] r137818 - /dragonegg/trunk/src/Convert.cpp

Duncan Sands baldrick at free.fr
Wed Aug 17 00:49:32 PDT 2011


Author: baldrick
Date: Wed Aug 17 02:49:32 2011
New Revision: 137818

URL: http://llvm.org/viewvc/llvm-project?rev=137818&view=rev
Log:
The Ada front-end likes to stick zero sized fields in structures.
We may or may not represent these fields in the LLVM type.  If we
don't then previously we would refuse to do element by element
struct copies because of that.  Instead just ignore such fields.
Also, the Ada front-end likes to preemptively mark fields as being
bitfields, even if they are not really.  So use a more sophisticated
bitfield test.

Modified:
    dragonegg/trunk/src/Convert.cpp

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=137818&r1=137817&r2=137818&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed Aug 17 02:49:32 2011
@@ -1451,8 +1451,12 @@
     unsigned TotalCost = 0;
     for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
       assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
+      // Ignore fields of size zero.  This way, we don't give up just because
+      // there is a size zero field that is not represented in the LLVM type.
+      if (integer_zerop(DECL_SIZE(Field)))
+        continue;
       // Bitfields are too hard - give up.
-      if (DECL_BIT_FIELD(Field))
+      if (isBitfield(Field))
         return TooCostly;
       // If there is no corresponding LLVM field then something funky is going
       // on - just give up.
@@ -1502,6 +1506,9 @@
 
     // Copy each field in turn.
     for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
+      // Ignore fields of size zero.
+      if (integer_zerop(DECL_SIZE(Field)))
+        continue;
       // Get the address of the field.
       int FieldIdx = GetFieldIndex(Field, Ty);
       assert(FieldIdx != INT_MAX && "Should not be copying if no LLVM field!");
@@ -1596,6 +1603,9 @@
 
     // Zero each field in turn.
     for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
+      // Ignore fields of size zero.
+      if (integer_zerop(DECL_SIZE(Field)))
+        continue;
       // Get the address of the field.
       int FieldIdx = GetFieldIndex(Field, Ty);
       assert(FieldIdx != INT_MAX && "Should not be zeroing if no LLVM field!");





More information about the llvm-commits mailing list