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



Jakub Jelinek <jakub at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

             Status|NEW                         |ASSIGNED

         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org

                   |gnu.org                     |



--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-11 
09:18:41 UTC ---

Created attachment 29142

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29142

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).

Reply via email to