Created attachment 34145 [details] reduced testcase Compiler output: $ gcc -O -fsanitize=undefined testcase.c Unable to coalesce ssa_names 1 and 6 which are marked as MUST COALESCE. xp_1(ab) and xp_6(ab) testcase.c: In function 'execute': testcase.c:4:1: internal compiler error: SSA corruption execute (int *ip, int x) ^ 0xd2c828 fail_abnormal_edge_coalesce /mnt/svn/gcc-trunk/gcc/tree-ssa-coalesce.c:921 0xd2c828 coalesce_partitions /mnt/svn/gcc-trunk/gcc/tree-ssa-coalesce.c:1219 0xd2c828 coalesce_ssa_name() /mnt/svn/gcc-trunk/gcc/tree-ssa-coalesce.c:1364 0xcc27cf remove_ssa_form /mnt/svn/gcc-trunk/gcc/tree-outof-ssa.c:999 0xcc27cf rewrite_out_of_ssa(ssaexpand*) /mnt/svn/gcc-trunk/gcc/tree-outof-ssa.c:1233 0x7d3c37 execute /mnt/svn/gcc-trunk/gcc/cfgexpand.c:5703 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. Tested revisions: r218181 - ICE 4_9 r218177 - OK
Confirmed, -O -fsanitize=object-size is enough.
# xp_1(ab) = PHI <xp_3(2), xp_7(ab)(4)> base: if (x_5(D) != 0) goto <bb 5>; else goto <bb 4>; <bb 4>: xp.0_6 = xp_1(ab); xp_7(ab) = xp.0_6 + 4; _15 = __builtin_object_size (ip_8(D), 0); _16 = ip_8(D); UBSAN_OBJECT_SIZE (_16, 4, _15, 0); _9 = *ip_8(D); _17 = __builtin_object_size (xp_1(ab), 0); ... _13 = &base + _12; gotovar.1_14 = _13; goto gotovar.1_14; xp_1 and xp_7 are life at the same time - the above is from 017t.ubsan. You may not refer to xp_1(ab) but should use xp.0_6 here.
Thanks. Let me dig into this.
Maybe you should just add to the instrument_object_size while (TREE_CODE (base) == SSA_NAME) loop if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (base)) break; ?
Unfortunately, that doesn't seem to help.
Ah, indeed. So perhaps better replace the: 1565 base = gimple_assign_rhs1 (def_stmt); line in the loop with { tree rhs1 = gimple_assign_rhs1 (def_stmt); if (TREE_CODE (rhs1) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) break; else base = rhs1; } or so?
Yup, that works. Testing in progress. Thanks.
Author: mpolacek Date: Mon Dec 1 15:37:55 2014 New Revision: 218222 URL: https://gcc.gnu.org/viewcvs?rev=218222&root=gcc&view=rev Log: PR sanitizer/64121 * ubsan.c (instrument_object_size): Stop searching if the base occurs in abnormal phi. * c-c++-common/ubsan/pr64121.c: New test. Added: trunk/gcc/testsuite/c-c++-common/ubsan/pr64121.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/ubsan.c
Fixed.