From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75205 invoked by alias); 17 Feb 2017 09:43:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 75111 invoked by uid 89); 17 Feb 2017 09:43:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=queued X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Feb 2017 09:43:12 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 129EBAE40 for ; Fri, 17 Feb 2017 09:43:10 +0000 (UTC) Date: Fri, 17 Feb 2017 09:45:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix PR79547 In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2017-02/txt/msg01094.txt.bz2 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 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: