This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: What is wrong with my SSA (ICE in SSA name coalescing)?
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 17 May 2013 14:28:08 +0200
- Subject: Re: What is wrong with my SSA (ICE in SSA name coalescing)?
- References: <CAMbmDYYko9PTAmMovjgt2Pk5JrVZFteGu4QdiGn3_Uq44_G8Ng at mail dot gmail dot com>
On Fri, May 17, 2013 at 2:03 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> I'm testing GIMPLE instrumentation pass and having a trouble with SSA
> name coalescing. I get such error only in tests with abnormal edges.
> Here is a simple test I use:
>
> void foo ();
> void goo (char *);
>
> int test ()
> {
> char *name = 0;
>
> foo();
>
> _setjmp (0);
>
> if (!name) {
> name = "-";
> }
>
> goo(name);
> goo(0);
>
> return 0;
> }
>
> Here is GIMPLE after my instrumentation. Instrumentation
> statements/expressions are marked with +++
>
> test ()
> {
> +++<unnamed type> __tmp.0;+++
> char * name;
> int D.1761;
> int _5;
>
> <bb 10>:
> +++__tmp.0_9 = __length_1;+++
> +++__tmp.0_8(ab) = __zero_length;+++
>
> <bb 2>:
> name_3(ab) = 0B;
> foo ();
>
> <bb 3>:
> # name_1(ab) = PHI <name_3(ab)(2), name_1(ab)(3), name_2(ab)(6),
> name_2(ab)(7)>
> +++# __tmp.0_7(ab) = PHI <__tmp.0_8(ab)(2), __tmp.0_7(ab)(3),
> __tmp.0_6(ab)(6), __tmp.0_6(ab)(7)>+++
> _setjmp (0);
>
> <bb 4>:
> if (name_1(ab) == 0B)
> goto <bb 5>;
> else
> goto <bb 6>;
>
> <bb 5>:
> name_4 = "-";
>
> <bb 6>:
> # name_2(ab) = PHI <name_1(ab)(4), name_4(5)>
> +++# __tmp.0_6(ab) = PHI <__tmp.0_7(ab)(4), __tmp.0_9(5)>+++
> goo (name_2(ab), +++__tmp.0_6(ab)+++);
>
> <bb 7>:
> goo (0B, +++__tmp.0_8(ab)+++);
>
> <bb 8>:
> _5 = 0;
>
> <L2>:
> return _5;
>
> }
>
> SSA name coalescing for this code later causes following error:
>
> Unable to coalesce ssa_names 7 and 8 which are marked as MUST COALESCE.
> __tmp.0_7(ab) and __tmp.0_8(ab)
> coalesce_test.c: In function 'test':
> coalesce_test.c:5:1: internal compiler error: SSA corruption
> test ()
> ^
> 0xb5dc65 fail_abnormal_edge_coalesce
> ../../gcc-pl/gcc/tree-ssa-coalesce.c:934
> 0xb5f0ed coalesce_partitions
> ../../gcc-pl/gcc/tree-ssa-coalesce.c:1236
> 0xb5f837 coalesce_ssa_name()
> ../../gcc-pl/gcc/tree-ssa-coalesce.c:1373
> 0xafaca4 remove_ssa_form
> ../../gcc-pl/gcc/tree-outof-ssa.c:900
> 0xafb602 rewrite_out_of_ssa(ssaexpand*)
> ../../gcc-pl/gcc/tree-outof-ssa.c:1133
> 0x66cac9 gimple_expand_cfg
> ../../gcc-pl/gcc/cfgexpand.c:4480
>
> What is actually wrong with my instrumentation? As I could understand
> from debugging, coalescing succeeded for name_1 and name_3, but failed
> for __tmp.0_7 and __tmp.0_8 because __tmp.0_8 has long lifetime (used
> in BB 7). If I remove second goo call from the test, then error goes
> away. Is it actually incorrect to have SSA names with such
> intersecting lifetimes? BTW if I use another var than __tmp.0 for 8th
> SSA name creation, then test passes.
>
> Compiler modification is based on gcc (GCC) 4.9.0 20130422 (experimental).
You cannot have SSA names live across abnormal edges because there is
no way to insert compensation code on them.
Richard.
> Thanks,
> Ilya