Take the following source: int g1(int); int h(int *a, int *b)__attribute__((pure)); void link_error(); int g(void) { int t = 0, t1 = 2; int t2 = h(&t, &t1); if (t != 0) link_error (); if (t1 != 2) link_error (); g1(t2); if (t != 0) link_error (); if (t1 != 2) link_error (); return t2 == 2; } We should not have link_error referenced at all. Even on the improved aliasing branch we get: Variable: t, UID 1278, int, is addressable, call clobbered, default def: t_1 Variable: t1, UID 1279, int, is addressable, call clobbered, default def: t1_3 That is incorrect, as t and t1 are not call clobbered as pure functions cannot cause something to escape.
Related to PR 23134.
Actually, it's not related at all. This is just a bug.
Assigning to Daniel Berlin per his request.
Subject: Bug 24287 CVSROOT: /cvs/gcc Module name: gcc Branch: improved-aliasing-branch Changes by: dberlin@gcc.gnu.org 2005-10-19 14:00:53 Modified files: gcc : ChangeLog.iab passes.c tree-dfa.c tree-flow.h tree-ssa-alias.c tree-ssa-operands.c tree-ssa-structalias.c gcc/cp : ptree.c Added files: gcc/testsuite/gcc.dg/tree-ssa: pr24287.c Log message: 2005-10-18 Daniel Berlin <dberlin@dberlin.org> Fix PR tree-optimization/24287 * tree-dfa.c (dump_variable): Print reasons for call clobbering. * tree-flow.h (struct ptr_info_def): Add escape mask to pointer. (ESCAPE_TRANSITIVE): Removed. (ESCAPE_TO_PURE_CONST): New. (ESCAPE_IS_PARM): New. (ESCAPE_UNKNOWN): New. * tree-ssa-alias.c (set_initial_properties): Incoming pointers are value escaping. Pointers that point to anything are not. Use pointer escape mask. (is_escape_site): Use ESCAPE_TO_PURE_CONST. * tree-ssa-operands.c (add_call_clobber_ops): Clean up a bit. Things that *only* escape to pure/const functions are only read by pure/const functions, and are not clobbered by the non-pure/const functions. (add_call_read_ops): Cleanup. * tree-ssa-structalias.c (update_alias_info): Use pi->escape_mask, not v_ann. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.iab.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=1.1.2.13&r2=1.1.2.14 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/passes.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.109.2.7&r2=2.109.2.8 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-dfa.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.63.4.6&r2=2.63.4.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-flow.h.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.132.2.8&r2=2.132.2.9 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-alias.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.109.4.11&r2=2.109.4.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-operands.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.100.4.7&r2=2.100.4.8 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-structalias.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.27.2.10&r2=2.27.2.11 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ptree.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=1.51&r2=1.51.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr24287.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=NONE&r2=1.1.2.1
Is this PR fixed? Or does it need some follow-up work?
Subject: Re: pure functions cause things to be call clobbered still On Sun, 2005-12-18 at 15:48 +0000, kazu at gcc dot gnu dot org wrote: > > ------- Comment #5 from kazu at gcc dot gnu dot org 2005-12-18 15:48 ------- > Is this PR fixed? Or does it need some follow-up work? > It's fixed on improved-aliasing. I'm merging the required changes.
Confirmed fixed by: 2006-01-16 Daniel Berlin <dberlin@dberlin.org>