Bug 24287 - pure functions cause things to be call clobbered still
Summary: pure functions cause things to be call clobbered still
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.0
: P2 enhancement
Target Milestone: 4.2.0
Assignee: Daniel Berlin
URL:
Keywords: alias, missed-optimization
Depends on:
Blocks:
 
Reported: 2005-10-09 17:24 UTC by Andrew Pinski
Modified: 2006-01-19 04:58 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-13 19:07:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2005-10-09 17:24:46 UTC
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.
Comment 1 Andrew Pinski 2005-10-09 17:35:56 UTC
Related to PR 23134.
Comment 2 Daniel Berlin 2005-10-10 12:45:53 UTC
Actually, it's not related at all.
This is just a bug.
Comment 3 Andrew Pinski 2005-10-10 15:17:08 UTC
Assigning to Daniel Berlin per his request.
Comment 4 CVS Commits 2005-10-19 14:00:59 UTC
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

Comment 5 Kazu Hirata 2005-12-18 15:48:23 UTC
Is this PR fixed?  Or does it need some follow-up work?
Comment 6 Daniel Berlin 2005-12-18 16:29:46 UTC
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.


Comment 7 Andrew Pinski 2006-01-19 04:58:47 UTC
Confirmed fixed by:
2006-01-16  Daniel Berlin  <dberlin@dberlin.org>