From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 550693858D20 for ; Fri, 15 Dec 2023 07:09:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 550693858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 550693858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702624165; cv=none; b=HkNvQG+gxIbcwQGvQfNc9iyy8uvWF0XCILJNqjWyDXsUPytUPN8aUZNew9a2UHziHZlDa64n84y4A7BmdrJe2wZ3Z+S9TiU3vLFD/lQJXgBPDOTWUpjnliM96Ucpg1qN6Zzoh96KIJifOE9IaXFp7gU4iMJdphFerOAWqPtFIZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702624165; c=relaxed/simple; bh=Myk4rvJCfw275DXmYmvSjOY2oc/B2UptV/ymM4KO6jk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=lw1xxeasVnfWlBxA0IonY6Hultq8aBE96sTVP+xuLspnLnNY3t/6Msj1qIXXNH1N8MwEP4ihYXmjUpAilJjMCY5O+vbYAWOPoI5ER18e/lollOsBpCQOLH+HwhZlYnmRxqfH3wpHVTo77E15EmKLrdqthNps3sDFhYBVbJu5Qjo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CEB2D1F81E; Fri, 15 Dec 2023 07:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702624161; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/pNNE/gpYaI4yzB5QMA1PSwYZTfWBMRd4jr8V8EglNM=; b=wuE+AzmgsqdUu6onLq1EFotkXWTKRmeIljxjDmH3U/CSkCQXUZdyxytG8/cfGAksVrvSnH ajw8CKPZNi6D1r6AzVlYmbklaKV47xpm0umsqL0+7CcuzLVZbwDQtxCd4P/CszDrJRaTXw HGWEkJySJntL0xnJmdbBQea8S/X4/74= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702624161; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/pNNE/gpYaI4yzB5QMA1PSwYZTfWBMRd4jr8V8EglNM=; b=ddSOQ1O5n7tAtaLgA8g37X6Uidl/5EngdtwHgLCPMhSL0sAq63YXXskxHCOsvWGZgozDh6 1dtq8bmzzJjDMmDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702624160; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/pNNE/gpYaI4yzB5QMA1PSwYZTfWBMRd4jr8V8EglNM=; b=Jri1f2w7MaSqN3v0cGYLbJTo+4q3SGxOQSw/uRixJGiN0WH9nkels6U40iL+PDvHKR3g8Z CFz4LdwPIzwjxDF6Lp9QK4pyUPHm6SDFuymD6TGb1USeqzqjHnWugl+91F/NREEmtjTJnD HkaQklzLCVFWdl3nEvO8ZR1Ra0zmxUk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702624160; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/pNNE/gpYaI4yzB5QMA1PSwYZTfWBMRd4jr8V8EglNM=; b=S+S2Z9kEmKWzaWntiWlv+rALuhiTrlUPnnQjL9bz4jteak0bBj3kOMGFEaWqbr3tPaozQJ +Lm0vKORKGmkZQDA== Date: Fri, 15 Dec 2023 08:08:15 +0100 (CET) From: Richard Biener To: Alexandre Oliva cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] strub: use opt_for_fn during ipa In-Reply-To: Message-ID: <34r50573-433n-4679-312p-271o551pq47n@fhfr.qr> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Score: -0.10 Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 1.19 X-Spamd-Result: default: False [1.19 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.19)[-0.967]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_SPAM_LONG(1.48)[0.423]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[20.81%] X-Spam-Flag: NO X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 14 Dec 2023, Alexandre Oliva wrote: > > Instead of global optimization levels and flags, check per-function > ones. > > Regstrapped on x86_64-linux-gnu, also testing on sparc-solaris2.11.3. > Ok to install? You have to be generally careful when working within IPA with function bodies without push/pop_cfun around that, several APIs have variants with struct function sepcified, using the wrong one will get you a NULL cfun which _some_ of them handle gracefully and "wrong", all EH stuff is amongst this for example. I see you replace flag_exceptions with opt_for_fn (cfun->decl, flag_exceptions), given that's 'cfun' this replacement is a no-op given 'cfun' would be NULL in IPA context unless you pushed a function. Looking at the 2nd hunk and the caller it seems the transform is a no-op for indrect_calls but not callees, thus that hunk is OK. I'll note that push/pop_cfun can be quite expensive so it's worth avoiding it when possible (we do allow quite some IL manipulation from "outside" of the 'cfun', you just have to be careful with APIs) Thanks, Richard. > (sorry, Richi, I dropped the ball and failed to fix this before the > monster commit) > > > for gcc/ChangeLog > > * ipa-strub.cc (gsi_insert_finally_seq_after_call): Likewise. > (pass_ipa_strub::adjust_at_calls_call): Likewise. > --- > gcc/ipa-strub.cc | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc > index 943bb60996fc1..32e2869cf7840 100644 > --- a/gcc/ipa-strub.cc > +++ b/gcc/ipa-strub.cc > @@ -2132,7 +2132,7 @@ gsi_insert_finally_seq_after_call (gimple_stmt_iterator gsi, gimple_seq seq) > || (call && gimple_call_nothrow_p (call)) > || (eh_lp <= 0 > && (TREE_NOTHROW (cfun->decl) > - || !flag_exceptions))); > + || !opt_for_fn (cfun->decl, flag_exceptions)))); > > if (noreturn_p && nothrow_p) > return; > @@ -2470,9 +2470,11 @@ pass_ipa_strub::adjust_at_calls_call (cgraph_edge *e, int named_args, > /* If we're already within a strub context, pass on the incoming watermark > pointer, and omit the enter and leave calls around the modified call, as an > optimization, or as a means to satisfy a tail-call requirement. */ > - tree swmp = ((optimize_size || optimize > 2 > + tree swmp = ((opt_for_fn (e->caller->decl, optimize_size) > + || opt_for_fn (e->caller->decl, optimize) > 2 > || gimple_call_must_tail_p (ocall) > - || (optimize == 2 && gimple_call_tail_p (ocall))) > + || (opt_for_fn (e->caller->decl, optimize) == 2 > + && gimple_call_tail_p (ocall))) > ? strub_watermark_parm (e->caller->decl) > : NULL_TREE); > bool omit_own_watermark = swmp; > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)