http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55935



--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> 2013-01-11 
13:43:50 UTC ---

(In reply to comment #7)

> Created attachment 29142 [details]

> gcc48-pr55935.patch

> 

> Untested fix.  Although the FE perhaps could unshare_expr_without_location so

> that ADDR_EXPRs in the ctor don't have location, IMHO gimple-fold.c still has

> to at least unshare_expr those expressions it copies from the constructors,

> otherwise we'll end up with invalid sharing of ADDR_EXPRs etc. between

> different functions (or within the same function).

> 

> This can be reproduced even with C:

> void foo (void);

> struct S { int i; void (*fn) (); };

> const struct S s = { 5, foo };

> void *fn1 (int x) { if (x < 0) return s.fn; if (x) return 0; return s.fn; }

> void *fn2 (int x) { if (x < 0) return s.fn; if (x) return 0; return s.fn; }

> void *fn3 (void) { return s.fn; }

> void *fn4 (void) { return s.fn; }

> at -O2, in *.copyrename1 pass all 6 ADDR_EXPRs in the IL are still shared.

> ccp1 for whatever reason unshares them all (surprisingly).



We allow those to pass verification in verify_node_sharing because:



/* Return true when the T can be shared.  */



bool

tree_node_can_be_shared (tree t)

{

  if (IS_TYPE_OR_DECL_P (t)

      || TREE_CODE (t) == SSA_NAME

      || is_gimple_min_invariant (t)

      || t == error_mark_node

      || TREE_CODE (t) == IDENTIFIER_NODE)

    return true;



is_gimple_min_invariant is bogus here IMHO.  But I guess "fixing" that

might have quite some fallout ...



Btw, get_symbol_constant_value also unshares the result from

canonicalize_constructor_val (if it's is_gimple_min_invariant).



I suppose we should try fixing tree_node_can_be_shared ...

Reply via email to