* [PATCH] Fix PR79547 @ 2017-02-16 12:47 Richard Biener 2017-02-17 9:45 ` Richard Biener 0 siblings, 1 reply; 5+ messages in thread From: Richard Biener @ 2017-02-16 12:47 UTC (permalink / raw) To: gcc-patches I am testing the following patch for PR79547. Those builtins do not return anything that can be used to re-construct the pointer(s) passed to them. Queued for GCC 8. Richard. 2017-02-16 Richard Biener <rguenther@suse.de> PR tree-optimization/79547 * tree-ssa-structalias.c (find_func_aliases_for_builtin_call): Handle strlen, strcmp, strncmp, strcasecmp, strncasecmp, memcmp, bcmp, strspn, strcspn, __builtin_object_size and __builtin_constant_p without any constraints. * gcc.dg/tree-ssa/strlen-2.c: New testcase. Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 245501) +++ gcc/tree-ssa-structalias.c (working copy) @@ -4474,6 +4474,22 @@ find_func_aliases_for_builtin_call (stru process_all_all_constraints (lhsc, rhsc); } return true; + /* Pure functions that return something not based on any object. */ + case BUILT_IN_STRLEN: + case BUILT_IN_STRCMP: + case BUILT_IN_STRNCMP: + case BUILT_IN_STRCASECMP: + case BUILT_IN_STRNCASECMP: + case BUILT_IN_MEMCMP: + case BUILT_IN_BCMP: + case BUILT_IN_STRSPN: + case BUILT_IN_STRCSPN: + case BUILT_IN_OBJECT_SIZE: + case BUILT_IN_CONSTANT_P: + /* We don't need to do anything here. No constraints are necessary + for the return value and call handling for pure functions is + special-cased in the alias oracle. */ + return true; /* Trampolines are special - they set up passing the static frame. */ case BUILT_IN_INIT_TRAMPOLINE: Index: gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c (nonexistent) +++ gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c (working copy) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +void f (unsigned); + +void f3 (void) +{ + char s[] = "1234"; + + f (__builtin_strlen (s)); + f (__builtin_strlen (s)); + f (__builtin_strlen (s)); +} + +/* { dg-final { scan-tree-dump-times "strlen" 1 "strlen" } } */ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix PR79547 2017-02-16 12:47 [PATCH] Fix PR79547 Richard Biener @ 2017-02-17 9:45 ` Richard Biener 2017-02-17 10:52 ` Marc Glisse 2017-04-21 13:08 ` Richard Biener 0 siblings, 2 replies; 5+ messages in thread From: Richard Biener @ 2017-02-17 9:45 UTC (permalink / raw) To: gcc-patches On Thu, 16 Feb 2017, Richard Biener wrote: > > I am testing the following patch for PR79547. Those builtins do not > return anything that can be used to re-construct the pointer(s) passed > to them. > > Queued for GCC 8. Actually we need calluse constraints. Thus adjusted as follows. Richard. 2017-02-17 Richard Biener <rguenther@suse.de> PR tree-optimization/79547 * tree-ssa-structalias.c (find_func_aliases_for_builtin_call): Handle strlen, strcmp, strncmp, strcasecmp, strncasecmp, memcmp, bcmp, strspn, strcspn, __builtin_object_size and __builtin_constant_p without any constraints. * gcc.dg/tree-ssa/strlen-2.c: New testcase. Index: gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c (nonexistent) +++ gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c (working copy) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +void f (unsigned); + +void f3 (void) +{ + char s[] = "1234"; + + f (__builtin_strlen (s)); + f (__builtin_strlen (s)); + f (__builtin_strlen (s)); +} + +/* { dg-final { scan-tree-dump-times "strlen" 1 "strlen" } } */ Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 245501) +++ gcc/tree-ssa-structalias.c (working copy) @@ -4474,6 +4474,40 @@ find_func_aliases_for_builtin_call (stru process_all_all_constraints (lhsc, rhsc); } return true; + /* Pure functions that return something not based on any object and + that use the memory pointed to by their arguments (but not + transitively). */ + case BUILT_IN_STRCMP: + case BUILT_IN_STRNCMP: + case BUILT_IN_STRCASECMP: + case BUILT_IN_STRNCASECMP: + case BUILT_IN_MEMCMP: + case BUILT_IN_BCMP: + case BUILT_IN_STRSPN: + case BUILT_IN_STRCSPN: + { + varinfo_t uses = get_call_use_vi (t); + make_any_offset_constraints (uses); + make_constraint_to (uses->id, gimple_call_arg (t, 0)); + make_constraint_to (uses->id, gimple_call_arg (t, 1)); + /* No constraints are necessary for the return value. */ + return true; + } + case BUILT_IN_STRLEN: + { + varinfo_t uses = get_call_use_vi (t); + make_any_offset_constraints (uses); + make_constraint_to (uses->id, gimple_call_arg (t, 0)); + /* No constraints are necessary for the return value. */ + return true; + } + case BUILT_IN_OBJECT_SIZE: + case BUILT_IN_CONSTANT_P: + { + /* No constraints are necessary for the return value or the + arguments. */ + return true; + } /* Trampolines are special - they set up passing the static frame. */ case BUILT_IN_INIT_TRAMPOLINE: ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix PR79547 2017-02-17 9:45 ` Richard Biener @ 2017-02-17 10:52 ` Marc Glisse 2017-02-17 11:32 ` Richard Biener 2017-04-21 13:08 ` Richard Biener 1 sibling, 1 reply; 5+ messages in thread From: Marc Glisse @ 2017-02-17 10:52 UTC (permalink / raw) To: Richard Biener; +Cc: gcc-patches On Fri, 17 Feb 2017, Richard Biener wrote: > On Thu, 16 Feb 2017, Richard Biener wrote: > >> >> I am testing the following patch for PR79547. Those builtins do not >> return anything that can be used to re-construct the pointer(s) passed >> to them. >> >> Queued for GCC 8. > > Actually we need calluse constraints. Thus adjusted as follows. > > Richard. > > 2017-02-17 Richard Biener <rguenther@suse.de> > > PR tree-optimization/79547 > * tree-ssa-structalias.c (find_func_aliases_for_builtin_call): > Handle strlen, strcmp, strncmp, strcasecmp, strncasecmp, memcmp, > bcmp, strspn, strcspn, __builtin_object_size and __builtin_constant_p > without any constraints. We have EAF_NOESCAPE that we are using for non-builtins, though it probably gets little use there. Would it make sense to use it here as well, or would that be pointless? -- Marc Glisse ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix PR79547 2017-02-17 10:52 ` Marc Glisse @ 2017-02-17 11:32 ` Richard Biener 0 siblings, 0 replies; 5+ messages in thread From: Richard Biener @ 2017-02-17 11:32 UTC (permalink / raw) To: gcc-patches On Fri, 17 Feb 2017, Marc Glisse wrote: > On Fri, 17 Feb 2017, Richard Biener wrote: > > > On Thu, 16 Feb 2017, Richard Biener wrote: > > > > > > > > I am testing the following patch for PR79547. Those builtins do not > > > return anything that can be used to re-construct the pointer(s) passed > > > to them. > > > > > > Queued for GCC 8. > > > > Actually we need calluse constraints. Thus adjusted as follows. > > > > Richard. > > > > 2017-02-17 Richard Biener <rguenther@suse.de> > > > > PR tree-optimization/79547 > > * tree-ssa-structalias.c (find_func_aliases_for_builtin_call): > > Handle strlen, strcmp, strncmp, strcasecmp, strncasecmp, memcmp, > > bcmp, strspn, strcspn, __builtin_object_size and __builtin_constant_p > > without any constraints. > > We have EAF_NOESCAPE that we are using for non-builtins, though it probably > gets little use there. Would it make sense to use it here as well, or would > that be pointless? EAF_NOESCAPE doesn't capture what we want here -- for pure and const functions arguments already don't escape in EAF_NOESCAPEs sense it's just that EAF_NOESCAPE doesn't cover "escaping" through the return value. We do not have sth like ERF_RETURNS_NO_ARG. Generally all explicitely handled builtins do not need any further fn-spec attributes added in builtins.def. Richard. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix PR79547 2017-02-17 9:45 ` Richard Biener 2017-02-17 10:52 ` Marc Glisse @ 2017-04-21 13:08 ` Richard Biener 1 sibling, 0 replies; 5+ messages in thread From: Richard Biener @ 2017-04-21 13:08 UTC (permalink / raw) To: gcc-patches On Fri, 17 Feb 2017, Richard Biener wrote: > On Thu, 16 Feb 2017, Richard Biener wrote: > > > > > I am testing the following patch for PR79547. Those builtins do not > > return anything that can be used to re-construct the pointer(s) passed > > to them. > > > > Queued for GCC 8. > > Actually we need calluse constraints. Thus adjusted as follows. Re-bootstrapped & tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. > Richard. > > 2017-02-17 Richard Biener <rguenther@suse.de> > > PR tree-optimization/79547 > * tree-ssa-structalias.c (find_func_aliases_for_builtin_call): > Handle strlen, strcmp, strncmp, strcasecmp, strncasecmp, memcmp, > bcmp, strspn, strcspn, __builtin_object_size and __builtin_constant_p > without any constraints. > > * gcc.dg/tree-ssa/strlen-2.c: New testcase. > > Index: gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c > =================================================================== > --- gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c (nonexistent) > +++ gcc/testsuite/gcc.dg/tree-ssa/strlen-2.c (working copy) > @@ -0,0 +1,15 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-strlen" } */ > + > +void f (unsigned); > + > +void f3 (void) > +{ > + char s[] = "1234"; > + > + f (__builtin_strlen (s)); > + f (__builtin_strlen (s)); > + f (__builtin_strlen (s)); > +} > + > +/* { dg-final { scan-tree-dump-times "strlen" 1 "strlen" } } */ > Index: gcc/tree-ssa-structalias.c > =================================================================== > --- gcc/tree-ssa-structalias.c (revision 245501) > +++ gcc/tree-ssa-structalias.c (working copy) > @@ -4474,6 +4474,40 @@ find_func_aliases_for_builtin_call (stru > process_all_all_constraints (lhsc, rhsc); > } > return true; > + /* Pure functions that return something not based on any object and > + that use the memory pointed to by their arguments (but not > + transitively). */ > + case BUILT_IN_STRCMP: > + case BUILT_IN_STRNCMP: > + case BUILT_IN_STRCASECMP: > + case BUILT_IN_STRNCASECMP: > + case BUILT_IN_MEMCMP: > + case BUILT_IN_BCMP: > + case BUILT_IN_STRSPN: > + case BUILT_IN_STRCSPN: > + { > + varinfo_t uses = get_call_use_vi (t); > + make_any_offset_constraints (uses); > + make_constraint_to (uses->id, gimple_call_arg (t, 0)); > + make_constraint_to (uses->id, gimple_call_arg (t, 1)); > + /* No constraints are necessary for the return value. */ > + return true; > + } > + case BUILT_IN_STRLEN: > + { > + varinfo_t uses = get_call_use_vi (t); > + make_any_offset_constraints (uses); > + make_constraint_to (uses->id, gimple_call_arg (t, 0)); > + /* No constraints are necessary for the return value. */ > + return true; > + } > + case BUILT_IN_OBJECT_SIZE: > + case BUILT_IN_CONSTANT_P: > + { > + /* No constraints are necessary for the return value or the > + arguments. */ > + return true; > + } > /* Trampolines are special - they set up passing the static > frame. */ > case BUILT_IN_INIT_TRAMPOLINE: > > -- Richard Biener <rguenther@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg) ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-21 12:46 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-02-16 12:47 [PATCH] Fix PR79547 Richard Biener 2017-02-17 9:45 ` Richard Biener 2017-02-17 10:52 ` Marc Glisse 2017-02-17 11:32 ` Richard Biener 2017-04-21 13:08 ` Richard Biener
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).