[llvm-commits] [127931] Fix union comparison code when handling hard ada cases :)

clattner at apple.com clattner at apple.com
Fri Jun 1 13:42:56 PDT 2007


Revision: 127931
Author:   clattner
Date:     2007-06-01 13:42:56 -0700 (Fri, 01 Jun 2007)

Log Message:
-----------
Fix union comparison code when handling hard ada cases :)

Patch by Duncan Sands.  Thanks for beating this into me Duncan.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-types.cpp	2007-06-01 20:39:30 UTC (rev 127930)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp	2007-06-01 20:42:56 UTC (rev 127931)
@@ -516,12 +516,20 @@
   type = TYPE_MAIN_VARIANT(type);
 
   // If the type does not overlap, don't bother checking below.
-  if (TYPE_SIZE(type) == 0 ||
-      PadStartBits >= int(TREE_INT_CST_LOW(TYPE_SIZE(type))) ||
+
+  if (!TYPE_SIZE(type))
+    return false;
+
+  if (!isInt64(TYPE_SIZE(type), false))
+    // Variable sized or huge - be conservative.
+    return true;
+
+  if (!getInt64(TYPE_SIZE(type), false) ||
+      PadStartBits >= (int64_t)getInt64(TYPE_SIZE(type), false) ||
       PadStartBits+PadSizeBits <= 0)
     return false;
 
-  
+
   switch (TREE_CODE(type)) {
   default:
     fprintf(stderr, "Unknown type to compare:\n");
@@ -564,7 +572,7 @@
       return GCCTypeOverlapsWithPadding(TREE_TYPE(Field),
                                         PadStartBits, PadSizeBits);
     }
-    
+
     // See if any elements overlap.
     for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
       if (TREE_CODE(Field) != FIELD_DECL) continue;
@@ -577,16 +585,16 @@
 
     return false;
   }
-    
-  case RECORD_TYPE: 
+
+  case RECORD_TYPE:
     for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
       if (TREE_CODE(Field) != FIELD_DECL) continue;
-      
+
       if (TREE_CODE(DECL_FIELD_OFFSET(Field)) != INTEGER_CST)
         return true;
-      
+
       unsigned FieldBitOffset = getFieldOffsetInBits(Field);
-      if (GCCTypeOverlapsWithPadding(TREE_TYPE(Field), 
+      if (GCCTypeOverlapsWithPadding(TREE_TYPE(Field),
                                      PadStartBits-FieldBitOffset, PadSizeBits))
         return true;
     }





More information about the llvm-commits mailing list