Hi Chris, this breaks the Ada build since the TYPE_SIZE may not be a constant:
> + if (TYPE_SIZE(type) == 0 || > + PadStartBits >= int(TREE_INT_CST_LOW(TYPE_SIZE(type))) || I've attached a fix, which includes some other tweaks for arrays (not very important) plus whitespace cleanup. Ciao, Duncan.
Index: gcc.llvm.master/gcc/llvm-types.cpp =================================================================== --- gcc.llvm.master.orig/gcc/llvm-types.cpp 2007-05-31 15:09:52.000000000 +0200 +++ gcc.llvm.master/gcc/llvm-types.cpp 2007-05-31 15:17:38.000000000 +0200 @@ -526,12 +526,19 @@ 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 (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"); @@ -550,9 +557,16 @@ return true; case ARRAY_TYPE: { - unsigned EltSizeBits = TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(type))); - unsigned NumElts = getInt64(arrayLength(type), true); - unsigned OverlapElt = (unsigned)PadStartBits/EltSizeBits; + uint64_t EltSizeBits = getInt64(TYPE_SIZE(TREE_TYPE(type)), true); + uint64_t NumElts = getInt64(arrayLength(type), true); + uint64_t MaxElts = 1 + (uint64_t)(PadStartBits+PadSizeBits)/EltSizeBits; + + if (MaxElts < NumElts) + NumElts = MaxElts; + + // Don't waste time on large arrays. + if (NumElts > 256) + return true; // Check each element for overlap. This is inelegant, but effective. for (unsigned i = 0; i != NumElts; ++i) @@ -574,7 +588,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; @@ -587,14 +601,14 @@ return false; } - + 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), PadStartBits-FieldBitOffset, PadSizeBits))
_______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits