[llvm-commits] [dragonegg] r137624 - /dragonegg/trunk/src/Constants.cpp

Duncan Sands baldrick at free.fr
Mon Aug 15 11:14:04 PDT 2011


Author: baldrick
Date: Mon Aug 15 13:14:04 2011
New Revision: 137624

URL: http://llvm.org/viewvc/llvm-project?rev=137624&view=rev
Log:
Don't bother remembering fields that we aren't going to do anything with
anyway.

Modified:
    dragonegg/trunk/src/Constants.cpp

Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=137624&r1=137623&r2=137624&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Mon Aug 15 13:14:04 2011
@@ -1076,22 +1076,23 @@
   // initial value is supplied for a field then the value will overwrite and
   // replace the zero starting value later.
   if (flag_default_initialize_globals) {
-    // Process the fields in reverse order.  This is for the benefit of union
-    // types for which the first field must be default initialized (iterating
-    // in forward order would default initialize the last field).
+    // Record all interesting fields so they can easily be visited backwards.
     SmallVector<tree, 16> Fields;
     for (tree field = TYPE_FIELDS(TREE_TYPE(exp)); field;
          field = TREE_CHAIN(field)) {
       assert(TREE_CODE(field) == FIELD_DECL && "Lang data not freed?");
-      Fields.push_back(field);
+      // Ignore fields with variable or unknown position since they cannot be
+      // default initialized.
+      if (OffsetIsLLVMCompatible(field))
+        Fields.push_back(field);
     }
+
+    // Process the fields in reverse order.  This is for the benefit of union
+    // types for which the first field must be default initialized (iterating
+    // in forward order would default initialize the last field).
     for (SmallVector<tree, 16>::reverse_iterator I = Fields.rbegin(),
          E = Fields.rend(); I != E; ++I) {
       tree field = *I;
-      // If the field has variable or unknown position then it cannot be default
-      // initialized - skip it.
-      if (!OffsetIsLLVMCompatible(field))
-        continue;
       uint64_t FirstBit = getFieldOffsetInBits(field);
       assert(FirstBit <= TypeSize && "Field off end of type!");
       // Determine the width of the field.





More information about the llvm-commits mailing list