From patchwork Sat Sep 24 23:30:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 116262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D9D98B6F75 for ; Sun, 25 Sep 2011 09:30:01 +1000 (EST) Received: (qmail 30835 invoked by alias); 24 Sep 2011 23:30:00 -0000 Received: (qmail 30827 invoked by uid 22791); 24 Sep 2011 23:29:59 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_TM X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 24 Sep 2011 23:29:45 +0000 Received: from nat-dem.mentorg.com ([195.212.93.2] helo=eu2-mail.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1R7bfC-0003Kd-2e from Tom_deVries@mentor.com ; Sat, 24 Sep 2011 16:29:42 -0700 Received: from [127.0.0.1] ([172.16.63.104]) by eu2-mail.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 25 Sep 2011 01:29:40 +0200 Message-ID: <4E7E6830.9020507@mentor.com> Date: Sun, 25 Sep 2011 01:30:56 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 Thunderbird/3.1.13 MIME-Version: 1.0 To: Eric Botcazou CC: gcc-patches@gcc.gnu.org, Tom de Vries , Richard Guenther , Zdenek Dvorak Subject: Re: [PATCH PR43513, 1/3] Replace vla with array - Implementation. References: <4E2FED87.8020300@codesourcery.com> <4E319A5E.3060208@codesourcery.com> <4E33B110.8070708@codesourcery.com> <201109241729.26112.ebotcazou@adacore.com> In-Reply-To: <201109241729.26112.ebotcazou@adacore.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 09/24/2011 05:29 PM, Eric Botcazou wrote: >> This is an updated version of the patch. I have 2 new patches and an >> updated testcase which I will sent out individually. >> >> Patch set was bootstrapped and reg-tested on x86_64. >> >> Ok for trunk? >> >> Thanks, >> - Tom >> >> 2011-07-30 Tom de Vries >> >> PR middle-end/43513 >> * Makefile.in (tree-ssa-ccp.o): Add $(PARAMS_H) to rule. >> * tree-ssa-ccp.c (params.h): Include. >> (fold_builtin_alloca_for_var): New function. >> (ccp_fold_stmt): Use fold_builtin_alloca_for_var. > > We have detected another fallout on some Ada code: the transformation replaces > a call to __builtin_alloca with &var, i.e. it introduces an aliased variable, > which invalidates the points-to information of some subsequent call, fooling > DSE into thinking that it can eliminate a live store. > > The brute force approach > > Index: tree-ssa-ccp.c > =================================================================== > --- tree-ssa-ccp.c (revision 179038) > +++ tree-ssa-ccp.c (working copy) > @@ -2014,7 +2014,10 @@ do_ssa_ccp (void) > ccp_initialize (); > ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node); > if (ccp_finalize ()) > - return (TODO_cleanup_cfg | TODO_update_ssa | TODO_remove_unused_locals); > + return (TODO_cleanup_cfg > + | TODO_update_ssa > + | TODO_rebuild_alias > + | TODO_remove_unused_locals); > else > return 0; > } > > works, but we might want to be move clever. Thoughts? > How about attached (untested) patch implementing a conservative, but runtime-efficient approach? Thanks, - Tom Index: gcc/tree-ssa-ccp.c =================================================================== --- gcc/tree-ssa-ccp.c (revision 179043) +++ gcc/tree-ssa-ccp.c (working copy) @@ -1729,6 +1729,7 @@ fold_builtin_alloca_for_var (gimple stmt array_type = build_array_type_nelts (elem_type, n_elem); var = create_tmp_var (array_type, NULL); DECL_ALIGN (var) = align; + pt_solution_add_var (&get_ptr_info (lhs)->pt, var); /* Fold alloca to the address of the array. */ return fold_convert (TREE_TYPE (lhs), build_fold_addr_expr (var)); Index: gcc/tree-ssa-alias.h =================================================================== --- gcc/tree-ssa-alias.h (revision 179043) +++ gcc/tree-ssa-alias.h (working copy) @@ -125,6 +125,7 @@ extern void dump_alias_stats (FILE *); /* In tree-ssa-structalias.c */ extern unsigned int compute_may_aliases (void); +extern void pt_solution_add_var (struct pt_solution *, tree); extern bool pt_solution_empty_p (struct pt_solution *); extern bool pt_solution_includes_global (struct pt_solution *); extern bool pt_solution_includes (struct pt_solution *, const_tree); Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 179043) +++ gcc/tree-ssa-structalias.c (working copy) @@ -5952,6 +5952,14 @@ pt_solution_ior_into (struct pt_solution bitmap_ior_into (dest->vars, src->vars); } +void +pt_solution_add_var (struct pt_solution *dest, tree var) +{ + struct pt_solution var_pt; + pt_solution_set_var (&var_pt, var); + pt_solution_ior_into (dest, &var_pt); +} + /* Return true if the points-to solution *PT is empty. */ bool