> I get a bootstrap failure on x86 (verify_flow_info failed) with it. It's actually pre-existing: it's PRE value-numbering a call that can make an abnormal goto, hence the CFG mess in the end. The call is ECF_PURE but also ECF_LOOPING_CONST_OR_PURE, so gimple_has_side_effects returns true and, in turn, call_can_make_abnormal_goto . The bug is in can_value_number_call.
I can come up with two solutions: - testing ECF_LOOPING_CONST_OR_PURE as well, like gimple_has_side_effects, or - calling call_can_make_abnormal_goto explicitly. The attached patch implements the former. With it, I could bootstrap and test the stor-layout.c patch on our internal testsuite. What do you think? * stor-layout.c (bit_from_pos): Distribute conversion to bitsizetype in a PLUS_EXPR byte offset. * tree-ssa-pre.c (can_value_number_call): Return false if the call has the ECF_LOOPING_CONST_OR_PURE flag. -- Eric Botcazou
Index: stor-layout.c =================================================================== --- stor-layout.c (revision 187435) +++ stor-layout.c (working copy) @@ -786,25 +786,29 @@ start_record_layout (tree t) } /* Return the combined bit position for the byte offset OFFSET and the - bit position BITPOS. */ + bit position BITPOS. + + These functions operate on byte and bit positions present in FIELD_DECLs + and assume that these expressions result in no (intermediate) overflow. + This assumption is necessary to fold the expressions as much as possible, + so as to avoid creating artificially variable-sized types in languages + supporting variable-sized types like Ada. */ tree bit_from_pos (tree offset, tree bitpos) { + if (TREE_CODE (offset) == PLUS_EXPR) + offset = size_binop (PLUS_EXPR, + fold_convert (bitsizetype, TREE_OPERAND (offset, 0)), + fold_convert (bitsizetype, TREE_OPERAND (offset, 1))); + else + offset = fold_convert (bitsizetype, offset); return size_binop (PLUS_EXPR, bitpos, - size_binop (MULT_EXPR, - fold_convert (bitsizetype, offset), - bitsize_unit_node)); + size_binop (MULT_EXPR, offset, bitsize_unit_node)); } /* Return the combined truncated byte position for the byte offset OFFSET and - the bit position BITPOS. - - These functions operate on byte and bit positions as present in FIELD_DECLs - and assume that these expressions result in no (intermediate) overflow. - This assumption is necessary to fold the expressions as much as possible, - so as to avoid creating artificially variable-sized types in languages - supporting variable-sized types like Ada. */ + the bit position BITPOS. */ tree byte_from_pos (tree offset, tree bitpos) Index: tree-ssa-pre.c =================================================================== --- tree-ssa-pre.c (revision 187435) +++ tree-ssa-pre.c (working copy) @@ -2592,10 +2592,15 @@ compute_antic (void) static bool can_value_number_call (gimple stmt) { + int flags; + if (gimple_call_internal_p (stmt)) return false; - if (gimple_call_flags (stmt) & (ECF_PURE | ECF_CONST)) + + flags = gimple_call_flags (stmt); + if ((flags & (ECF_PURE | ECF_CONST)) && !(flags & ECF_LOOPING_CONST_OR_PURE)) return true; + return false; }