From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17862 invoked by alias); 24 Jul 2014 13:04:06 -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 17777 invoked by uid 89); 24 Jul 2014 13:04:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f176.google.com Received: from mail-wi0-f176.google.com (HELO mail-wi0-f176.google.com) (209.85.212.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 24 Jul 2014 13:04:03 +0000 Received: by mail-wi0-f176.google.com with SMTP id bs8so9634455wib.3 for ; Thu, 24 Jul 2014 06:04:00 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.180.187.6 with SMTP id fo6mr12941344wic.58.1406207039342; Thu, 24 Jul 2014 06:03:59 -0700 (PDT) Received: by 10.195.13.76 with HTTP; Thu, 24 Jul 2014 06:03:59 -0700 (PDT) In-Reply-To: References: Date: Thu, 24 Jul 2014 13:06:00 -0000 Message-ID: Subject: Re: update address taken: don't drop clobbers From: Richard Biener To: Marc Glisse Cc: GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg01657.txt.bz2 On Sat, Jul 12, 2014 at 8:15 AM, Marc Glisse wrote: > On Thu, 10 Jul 2014, Richard Biener wrote: > >>> --- gcc/tree-into-ssa.c (revision 212109) >>> +++ gcc/tree-into-ssa.c (working copy) >>> @@ -1831,26 +1831,38 @@ maybe_register_def (def_operand_p def_p, >>> { >>> tree def = DEF_FROM_PTR (def_p); >>> tree sym = DECL_P (def) ? def : SSA_NAME_VAR (def); >>> >>> /* If DEF is a naked symbol that needs renaming, create a new >>> name for it. */ >>> if (marked_for_renaming (sym)) >>> { >>> if (DECL_P (def)) >>> { >>> - tree tracked_var; >>> - >>> - def = make_ssa_name (def, stmt); >>> + if (gimple_clobber_p (stmt) && is_gimple_reg (sym)) >> >> >> sym should always be a gimple reg here (it's marked for renaming). >> >>> + { >>> + /* Replace clobber stmts with a default def. Create a new >>> + variable so we don't later think we must coalesce, which >>> would >>> + fail with some ada abnormal PHIs. Still, we try to keep >>> a >>> + similar name so error messages make sense. */ >>> + unlink_stmt_vdef (stmt); >> >> >> I think that's redundant with gsi_replace (note that using gsi_replace >> looks dangerous here as it calls update_stmt during SSA rewrite... >> that might open a can of worms). > > > IIRC it was failing without unlink_stmt_vdef (maybe that was in a different > version of the patch not using gsi_replace, but I don't think so). I was > hoping that a clobber had little enough effects that update_stmt was > unlikely to break anything. Anyway it doesn't matter if I use your > suggestion below. The important part is that it not ICE (of course) and that it doesn't trigger useless SSA renaming of .MEM - gsi_replace does update_stmt which does the unlink_stmt_vdef for you if the .MEM is no longer necessary. Richard. > >>> + gsi_replace (&gsi, gimple_build_nop (), true); >>> + tree id = DECL_NAME (sym); >>> + const char* name = id ? IDENTIFIER_POINTER (id) : 0; >>> + tree newvar = create_tmp_var (TREE_TYPE (sym), name); >>> + def = get_or_create_ssa_default_def (cfun, newvar); >> >> >> So - can't you simply do >> >> gimple_assign_set_rhs_from_tree (&gsi, >> get_or_create_dda_default_def (cfun, sym)); >> >> ? Thus replace x = CLOBBER; with x_3 = x_2(D); >> >>> + } >>> + else >> >> >> and of course still rewrite the DEF then. IMHO the copy-propagation >> you do is premature optimization. > > > I'll try that. I was trying to remain as close as possible to what you wrote > in rewrite_stmt: > > if (gimple_clobber_p (stmt) > && is_gimple_reg (var)) > { > /* If we rewrite a DECL into SSA form then drop its > clobber stmts and replace uses with a new default def. */ > gcc_checking_assert (TREE_CODE (var) == VAR_DECL > && !gimple_vdef (stmt)); > gsi_replace (si, gimple_build_nop (), true); > register_new_def (get_or_create_ssa_default_def (cfun, var), > var); > break; > } > > > I'll be away next week, but I'll re-read all the replies carefully when I > come back. > > -- > Marc Glisse