From patchwork Tue Nov 5 11:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 2006813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=aceTLybw; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=HS+ngjNw; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=aceTLybw; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=HS+ngjNw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjQWb3pCqz1xxN for ; Tue, 5 Nov 2024 22:06:34 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 62D6A3857739 for ; Tue, 5 Nov 2024 11:06:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 6E107385840F for ; Tue, 5 Nov 2024 11:06:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E107385840F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6E107385840F 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=1730804775; cv=none; b=XVJU60KqrMaYxH9JNOwBsOIU2qj9EYRHpYTlMDW4EKaOsF5iDRjB6U7kttlWudTZGPTGU+qC+CanQ2GYJ9EwGmU9AoVGRlEIolqRyCne+ZrNBoDsZo54ZzcCkpJ4b8inz9KdUSj2NyayzZKcoEteUe/Bq5rlFz7zv5XOTd4O4vY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730804775; c=relaxed/simple; bh=uXdKkBtBjXFve0WCb88osgfiS08FarVhX+eHDTnF1nM=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=neLSeXdHvirv0092vn9DzBX0qEPlC5ObBZBUCTrJU0ibNb34QVFl/T8ninvwb0jvlVIeSjh0OlaDDWIN3l7EDxrGql95buSR/gpeiWFCguXG9BZfuMpvjghT+xmroEhv8URR+HZy5S5nB4UD4UGmqDBuaxjxPLTnP0uc2kO1CjQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 6926C1FBCD; Tue, 5 Nov 2024 11:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730804769; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=lw91snvrkal/VxD8EJgeVBwmZsPE3NtqaJZLDL+1B7Q=; b=aceTLybwB9MDzs3iOTuVBlI/h1HE5NnYq79Q1GGCg8jJAbtQfZiCKNCtN9PAoIpmAcYFMx UkS67xRx+73JV3gszinDGW7iDxGMjKZTZ1Lwf+wvSCpJh48N0ZQ6sMRkogFoKayFCji5FU a+UAS0dkV2pg3G2CBzeB6NvdCng5q0M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730804769; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=lw91snvrkal/VxD8EJgeVBwmZsPE3NtqaJZLDL+1B7Q=; b=HS+ngjNwDKiCFQlYmt+nDSTFYNK8mFD6YojsjOC7KxHjhtIkdpYhWfMBEk8wlnVadWLBCh 2b00zySDBYPk12CQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730804769; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=lw91snvrkal/VxD8EJgeVBwmZsPE3NtqaJZLDL+1B7Q=; b=aceTLybwB9MDzs3iOTuVBlI/h1HE5NnYq79Q1GGCg8jJAbtQfZiCKNCtN9PAoIpmAcYFMx UkS67xRx+73JV3gszinDGW7iDxGMjKZTZ1Lwf+wvSCpJh48N0ZQ6sMRkogFoKayFCji5FU a+UAS0dkV2pg3G2CBzeB6NvdCng5q0M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730804769; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=lw91snvrkal/VxD8EJgeVBwmZsPE3NtqaJZLDL+1B7Q=; b=HS+ngjNwDKiCFQlYmt+nDSTFYNK8mFD6YojsjOC7KxHjhtIkdpYhWfMBEk8wlnVadWLBCh 2b00zySDBYPk12CQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5F4961394A; Tue, 5 Nov 2024 11:06:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WQk+FyH8KWedXQAAD6G6ig (envelope-from ); Tue, 05 Nov 2024 11:06:09 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Aldy Hernandez , Josef Melcr Subject: [PATCH 1/8] ipa: Fix jump function copying User-Agent: Notmuch/0.38.3 (https://notmuchmail.org) Emacs/29.4 (x86_64-suse-linux-gnu) Date: Tue, 05 Nov 2024 12:06:04 +0100 Message-ID: MIME-Version: 1.0 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, when reviewing various IPA bits and pieces I have discovered two embarrassing problems with jump function duplication. First, aggregate jump function vector copying contained a pasto where the source is the (empty) destination vector and so no aggregate jump functions ever got copied to jump functions of clones. Second, the code did not copy value range information stored in the jump functions, again not making them available for the inliner when examining calls going out of IPA clones. This patch fixes both issues and on top of that moves copying of individual jump functions out of the duplication hook to a special function because we expect it to be useful in creating jump functions for planned call-graph edges that model transfer of control to OpenMP outlined regions through calls to gomp functions. Bootstrapped and tested on x86_64-linux, the whole patch series has additionally passed LTO and profiled-LTO bootstrap on the same platform and a bootstrap and testsuite on ppc64-linux. Aarch64-linux bootstrap and testing is in progress. Because we have agreed with Honza this is necessary last week, I consider the patch pre-approved and will commit it later today. Thanks, Martin gcc/ChangeLog: 2024-11-01 Martin Jambor * ipa-prop.cc (ipa_duplicate_jump_function): New function. (ipa_edge_args_sum_t::duplicate): Move individual jump function copying to ipa_duplicate_jump_function. --- gcc/ipa-prop.cc | 187 ++++++++++++++++++++++++++---------------------- 1 file changed, 100 insertions(+), 87 deletions(-) diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index add3a12b584..db8eda8c361 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -4497,6 +4497,105 @@ ipa_edge_args_sum_t::remove (cgraph_edge *cs, ipa_edge_args *args) } } +/* Copy information from SRC_JF to DST_JF which correstpond to call graph edges + SRC and DST. */ + +static void +ipa_duplicate_jump_function (cgraph_edge *src, cgraph_edge *dst, + ipa_jump_func *src_jf, ipa_jump_func *dst_jf) +{ + dst_jf->agg.items = vec_safe_copy (src_jf->agg.items); + + if (src_jf->type == IPA_JF_CONST) + { + struct ipa_cst_ref_desc *src_rdesc = jfunc_rdesc_usable (src_jf); + + if (!src_rdesc) + dst_jf->value.constant.rdesc = NULL; + else if (src->caller == dst->caller) + { + /* Creation of a speculative edge. If the source edge is the one + grabbing a reference, we must create a new (duplicate) + reference description. Otherwise they refer to the same + description corresponding to a reference taken in a function + src->caller is inlined to. In that case we just must + increment the refcount. */ + if (src_rdesc->cs == src) + { + symtab_node *n = symtab_node_for_jfunc (src_jf); + gcc_checking_assert (n); + ipa_ref *ref + = src->caller->find_reference (n, src->call_stmt, + src->lto_stmt_uid, + IPA_REF_ADDR); + gcc_checking_assert (ref); + dst->caller->clone_reference (ref, ref->stmt); + + ipa_cst_ref_desc *dst_rdesc = ipa_refdesc_pool.allocate (); + dst_rdesc->cs = dst; + dst_rdesc->refcount = src_rdesc->refcount; + dst_rdesc->next_duplicate = NULL; + dst_jf->value.constant.rdesc = dst_rdesc; + } + else + { + src_rdesc->refcount++; + dst_jf->value.constant.rdesc = src_rdesc; + } + } + else if (src_rdesc->cs == src) + { + struct ipa_cst_ref_desc *dst_rdesc = ipa_refdesc_pool.allocate (); + dst_rdesc->cs = dst; + dst_rdesc->refcount = src_rdesc->refcount; + dst_rdesc->next_duplicate = src_rdesc->next_duplicate; + src_rdesc->next_duplicate = dst_rdesc; + dst_jf->value.constant.rdesc = dst_rdesc; + } + else + { + struct ipa_cst_ref_desc *dst_rdesc; + /* This can happen during inlining, when a JFUNC can refer to a + reference taken in a function up in the tree of inline clones. + We need to find the duplicate that refers to our tree of + inline clones. */ + + gcc_assert (dst->caller->inlined_to); + for (dst_rdesc = src_rdesc->next_duplicate; + dst_rdesc; + dst_rdesc = dst_rdesc->next_duplicate) + { + struct cgraph_node *top; + top = dst_rdesc->cs->caller->inlined_to + ? dst_rdesc->cs->caller->inlined_to + : dst_rdesc->cs->caller; + if (dst->caller->inlined_to == top) + break; + } + gcc_assert (dst_rdesc); + dst_jf->value.constant.rdesc = dst_rdesc; + } + } + else if (dst_jf->type == IPA_JF_PASS_THROUGH + && src->caller == dst->caller) + { + struct cgraph_node *inline_root = dst->caller->inlined_to + ? dst->caller->inlined_to : dst->caller; + ipa_node_params *root_info = ipa_node_params_sum->get (inline_root); + int idx = ipa_get_jf_pass_through_formal_id (dst_jf); + + int c = ipa_get_controlled_uses (root_info, idx); + if (c != IPA_UNDESCRIBED_USE) + { + c++; + ipa_set_controlled_uses (root_info, idx, c); + } + } + + if (src_jf->m_vr && src_jf->m_vr->known_p ()) + ipa_set_jfunc_vr (dst_jf, *src_jf->m_vr); +} + /* Method invoked when an edge is duplicated. Copy ipa_edge_args and adjust reference count data strucutres accordingly. */ @@ -4516,93 +4615,7 @@ ipa_edge_args_sum_t::duplicate (cgraph_edge *src, cgraph_edge *dst, struct ipa_jump_func *src_jf = ipa_get_ith_jump_func (old_args, i); struct ipa_jump_func *dst_jf = ipa_get_ith_jump_func (new_args, i); - dst_jf->agg.items = vec_safe_copy (dst_jf->agg.items); - - if (src_jf->type == IPA_JF_CONST) - { - struct ipa_cst_ref_desc *src_rdesc = jfunc_rdesc_usable (src_jf); - - if (!src_rdesc) - dst_jf->value.constant.rdesc = NULL; - else if (src->caller == dst->caller) - { - /* Creation of a speculative edge. If the source edge is the one - grabbing a reference, we must create a new (duplicate) - reference description. Otherwise they refer to the same - description corresponding to a reference taken in a function - src->caller is inlined to. In that case we just must - increment the refcount. */ - if (src_rdesc->cs == src) - { - symtab_node *n = symtab_node_for_jfunc (src_jf); - gcc_checking_assert (n); - ipa_ref *ref - = src->caller->find_reference (n, src->call_stmt, - src->lto_stmt_uid, - IPA_REF_ADDR); - gcc_checking_assert (ref); - dst->caller->clone_reference (ref, ref->stmt); - - ipa_cst_ref_desc *dst_rdesc = ipa_refdesc_pool.allocate (); - dst_rdesc->cs = dst; - dst_rdesc->refcount = src_rdesc->refcount; - dst_rdesc->next_duplicate = NULL; - dst_jf->value.constant.rdesc = dst_rdesc; - } - else - { - src_rdesc->refcount++; - dst_jf->value.constant.rdesc = src_rdesc; - } - } - else if (src_rdesc->cs == src) - { - struct ipa_cst_ref_desc *dst_rdesc = ipa_refdesc_pool.allocate (); - dst_rdesc->cs = dst; - dst_rdesc->refcount = src_rdesc->refcount; - dst_rdesc->next_duplicate = src_rdesc->next_duplicate; - src_rdesc->next_duplicate = dst_rdesc; - dst_jf->value.constant.rdesc = dst_rdesc; - } - else - { - struct ipa_cst_ref_desc *dst_rdesc; - /* This can happen during inlining, when a JFUNC can refer to a - reference taken in a function up in the tree of inline clones. - We need to find the duplicate that refers to our tree of - inline clones. */ - - gcc_assert (dst->caller->inlined_to); - for (dst_rdesc = src_rdesc->next_duplicate; - dst_rdesc; - dst_rdesc = dst_rdesc->next_duplicate) - { - struct cgraph_node *top; - top = dst_rdesc->cs->caller->inlined_to - ? dst_rdesc->cs->caller->inlined_to - : dst_rdesc->cs->caller; - if (dst->caller->inlined_to == top) - break; - } - gcc_assert (dst_rdesc); - dst_jf->value.constant.rdesc = dst_rdesc; - } - } - else if (dst_jf->type == IPA_JF_PASS_THROUGH - && src->caller == dst->caller) - { - struct cgraph_node *inline_root = dst->caller->inlined_to - ? dst->caller->inlined_to : dst->caller; - ipa_node_params *root_info = ipa_node_params_sum->get (inline_root); - int idx = ipa_get_jf_pass_through_formal_id (dst_jf); - - int c = ipa_get_controlled_uses (root_info, idx); - if (c != IPA_UNDESCRIBED_USE) - { - c++; - ipa_set_controlled_uses (root_info, idx, c); - } - } + ipa_duplicate_jump_function (src, dst, src_jf, dst_jf); } } From patchwork Tue Nov 5 11:07:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 2006815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=GIyPPmrv; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=xAlJwcg0; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=GIyPPmrv; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=xAlJwcg0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjQYn4pN6z1xxN for ; Tue, 5 Nov 2024 22:08:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C13B3857B91 for ; Tue, 5 Nov 2024 11:08:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 4ADCC385840F for ; Tue, 5 Nov 2024 11:07:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4ADCC385840F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4ADCC385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730804882; cv=none; b=U6i7KXo/KXouuXvgLQrs7+MnAvVJrpmfPjJqZ8pGmj5+TdhuQBXxCIEDqDt2U21qpfet9dJkf1Jm69/wLqI+cfeQ65ne5GStGncSuFZHwGWvHEdu3ms4/mIASZ83QB+CwzTottWG4LwcqC1KNhK47/Pgb4EzdVJHgUUj4N1Dzq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730804882; c=relaxed/simple; bh=kMUCTfHjoC53RDa2Hj4Q1QVAD5TiAez7wD5EUw0FMbo=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=Oku7jccoFkLUJHnT9utj3qz25CtIrmFuyu5Nr0Ji/0rKMzWVN1eGJritd9sceu0+55ZFoTWP4PHRJdEYiUj0kN86y62pllWgKZDFKvYkq1P8Jq6bgMr8Qari/i0604mDhE0BaD2ZjdG6AbCON4T9GWnCehdkw3mV2W/aRM2Hyvw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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-out1.suse.de (Postfix) with ESMTPS id 4929921D89; Tue, 5 Nov 2024 11:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730804877; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=YqfhUchGhUGoC0IYvK+T/sDCXfGYE6yON95KypMao5g=; b=GIyPPmrv2VwK676QagU5JP75dc1hZpnnMFkDLX5i8Hbh2yp5bpNPFlhSutxhdX+mTtQkEh nAOQApgDZo8IWAM8Pah0/BWKa6PPVBnw2luCpxifW+SzliUxN+vgys4hAs/IaFx0WIGtUX +fBqlbdeqEUyY89XdJXH7DMgA78EBYs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730804877; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=YqfhUchGhUGoC0IYvK+T/sDCXfGYE6yON95KypMao5g=; b=xAlJwcg0Ng2CYG1NswV20ZugQv49SXi20Dwia7j9R7N85bv+eoYYidI2/IzNpxtlUxd103 EkJo+NVIatpFc/Cw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730804877; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=YqfhUchGhUGoC0IYvK+T/sDCXfGYE6yON95KypMao5g=; b=GIyPPmrv2VwK676QagU5JP75dc1hZpnnMFkDLX5i8Hbh2yp5bpNPFlhSutxhdX+mTtQkEh nAOQApgDZo8IWAM8Pah0/BWKa6PPVBnw2luCpxifW+SzliUxN+vgys4hAs/IaFx0WIGtUX +fBqlbdeqEUyY89XdJXH7DMgA78EBYs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730804877; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=YqfhUchGhUGoC0IYvK+T/sDCXfGYE6yON95KypMao5g=; b=xAlJwcg0Ng2CYG1NswV20ZugQv49SXi20Dwia7j9R7N85bv+eoYYidI2/IzNpxtlUxd103 EkJo+NVIatpFc/Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 391011394A; Tue, 5 Nov 2024 11:07:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id qSWYDY38KWcrXgAAD6G6ig (envelope-from ); Tue, 05 Nov 2024 11:07:57 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Aldy Hernandez Subject: [PATCH 2/8] ipa: Rationalize IPA-VR computations across pass-through jump functions User-Agent: Notmuch/0.38.3 (https://notmuchmail.org) Emacs/29.4 (x86_64-suse-linux-gnu) Date: Tue, 05 Nov 2024 12:07:56 +0100 Message-ID: MIME-Version: 1.0 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; TO_DN_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, currently ipa_value_range_from_jfunc and propagate_vr_across_jump_function contain similar but not same code for dealing with pass-through jump functions. This patch puts these common bits into one function which can also handle comparison operations. Bootstrapped and tested on x86_64-linux, the whole patch series has additionally passed LTO and profiled-LTO bootstrap on the same platform and a bootstrap and testsuite on ppc64-linux. Aarch64-linux bootstrap and testing is in progress. OK for master is that passes too? Thanks, Martin gcc/ChangeLog: 2024-11-01 Martin Jambor PR ipa/114985 * ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): New function. (ipa_value_range_from_jfunc): Move the common functionality to the above new function, adjust the rest so that it works with it well. (propagate_vr_across_jump_function): Likewise. --- gcc/ipa-cp.cc | 181 +++++++++++++++++++------------------------------- 1 file changed, 67 insertions(+), 114 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 212d9ccbbfe..fa4f0feeb8d 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -1682,6 +1682,55 @@ ipa_vr_operation_and_type_effects (vrange &dst_vr, dst_type, src_type); } +/* Given a PASS_THROUGH jump function JFUNC that takes as its source SRC_VR of + SRC_TYPE and the result needs to be DST_TYPE, if any value range information + can be deduced at all, intersect VR with it. */ + +static void +ipa_vr_intersect_with_arith_jfunc (vrange &vr, + ipa_jump_func *jfunc, + const value_range &src_vr, + tree src_type, + tree dst_type) +{ + if (src_vr.undefined_p () || src_vr.varying_p ()) + return; + + enum tree_code operation = ipa_get_jf_pass_through_operation (jfunc); + if (TREE_CODE_CLASS (operation) == tcc_unary) + { + value_range tmp_res (dst_type); + if (ipa_vr_operation_and_type_effects (tmp_res, src_vr, operation, + dst_type, src_type)) + vr.intersect (tmp_res); + return; + } + + tree operand = ipa_get_jf_pass_through_operand (jfunc); + range_op_handler handler (operation); + if (!handler) + return; + value_range op_vr (TREE_TYPE (operand)); + ipa_range_set_and_normalize (op_vr, operand); + + tree operation_type; + if (TREE_CODE_CLASS (operation) == tcc_comparison) + operation_type = boolean_type_node; + else + operation_type = src_type; + + value_range op_res (dst_type); + if (!ipa_vr_supported_type_p (operation_type) + || !handler.operand_check_p (operation_type, src_type, op_vr.type ()) + || !handler.fold_range (op_res, operation_type, src_vr, op_vr)) + return; + + value_range tmp_res (dst_type); + if (ipa_vr_operation_and_type_effects (tmp_res, op_res, NOP_EXPR, dst_type, + operation_type)) + vr.intersect (tmp_res); +} + /* Determine range of JFUNC given that INFO describes the caller node or the one it is inlined to, CS is the call graph edge corresponding to JFUNC and PARM_TYPE of the parameter. */ @@ -1691,18 +1740,18 @@ ipa_value_range_from_jfunc (vrange &vr, ipa_node_params *info, cgraph_edge *cs, ipa_jump_func *jfunc, tree parm_type) { - vr.set_undefined (); + vr.set_varying (parm_type); - if (jfunc->m_vr) + if (jfunc->m_vr && jfunc->m_vr->known_p ()) ipa_vr_operation_and_type_effects (vr, *jfunc->m_vr, NOP_EXPR, parm_type, jfunc->m_vr->type ()); if (vr.singleton_p ()) return; + if (jfunc->type == IPA_JF_PASS_THROUGH) { - int idx; ipcp_transformation *sum = ipcp_get_transformation_summary (cs->caller->inlined_to ? cs->caller->inlined_to @@ -1710,54 +1759,15 @@ ipa_value_range_from_jfunc (vrange &vr, if (!sum || !sum->m_vr) return; - idx = ipa_get_jf_pass_through_formal_id (jfunc); + int idx = ipa_get_jf_pass_through_formal_id (jfunc); if (!(*sum->m_vr)[idx].known_p ()) return; - tree vr_type = ipa_get_type (info, idx); + tree src_type = ipa_get_type (info, idx); value_range srcvr; (*sum->m_vr)[idx].get_vrange (srcvr); - enum tree_code operation = ipa_get_jf_pass_through_operation (jfunc); - - if (TREE_CODE_CLASS (operation) == tcc_unary) - { - value_range res (parm_type); - - if (ipa_vr_operation_and_type_effects (res, - srcvr, - operation, parm_type, - vr_type)) - vr.intersect (res); - } - else - { - value_range op_res (vr_type); - value_range res (vr_type); - tree op = ipa_get_jf_pass_through_operand (jfunc); - value_range op_vr (TREE_TYPE (op)); - range_op_handler handler (operation); - - ipa_range_set_and_normalize (op_vr, op); - - if (!handler - || !op_res.supports_type_p (vr_type) - /* Sometimes we try to fold comparison operators using a - pointer type to hold the result instead of a boolean - type. Avoid trapping in the sanity check in - fold_range until this is fixed. */ - || srcvr.undefined_p () - || op_vr.undefined_p () - || !handler.operand_check_p (vr_type, srcvr.type (), op_vr.type ()) - || !handler.fold_range (op_res, vr_type, srcvr, op_vr)) - op_res.set_varying (vr_type); - - if (ipa_vr_operation_and_type_effects (res, - op_res, - NOP_EXPR, parm_type, - vr_type)) - vr.intersect (res); - } + ipa_vr_intersect_with_arith_jfunc (vr, jfunc, srcvr, src_type, parm_type); } } @@ -2523,9 +2533,15 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc, || !ipa_vr_supported_type_p (param_type)) return dest_lat->set_to_bottom (); + value_range vr (param_type); + vr.set_varying (param_type); + if (jfunc->m_vr) + ipa_vr_operation_and_type_effects (vr, *jfunc->m_vr, NOP_EXPR, + param_type, + jfunc->m_vr->type ()); + if (jfunc->type == IPA_JF_PASS_THROUGH) { - enum tree_code operation = ipa_get_jf_pass_through_operation (jfunc); ipa_node_params *caller_info = ipa_node_params_sum->get (cs->caller); int src_idx = ipa_get_jf_pass_through_formal_id (jfunc); class ipcp_param_lattices *src_lats @@ -2535,77 +2551,14 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc, if (src_lats->m_value_range.bottom_p ()) return dest_lat->set_to_bottom (); - value_range vr (param_type); - if (TREE_CODE_CLASS (operation) == tcc_unary) - ipa_vr_operation_and_type_effects (vr, + if (ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR + || !ipa_edge_within_scc (cs)) + ipa_vr_intersect_with_arith_jfunc (vr, jfunc, src_lats->m_value_range.m_vr, - operation, param_type, - operand_type); - /* A crude way to prevent unbounded number of value range updates - in SCC components. We should allow limited number of updates within - SCC, too. */ - else if (!ipa_edge_within_scc (cs)) - { - tree op = ipa_get_jf_pass_through_operand (jfunc); - value_range op_vr (TREE_TYPE (op)); - value_range op_res (param_type); - range_op_handler handler (operation); - - ipa_range_set_and_normalize (op_vr, op); - - if (!handler - || !ipa_vr_supported_type_p (operand_type) - /* Sometimes we try to fold comparison operators using a - pointer type to hold the result instead of a boolean - type. Avoid trapping in the sanity check in - fold_range until this is fixed. */ - || src_lats->m_value_range.m_vr.undefined_p () - || op_vr.undefined_p () - || !handler.operand_check_p (operand_type, - src_lats->m_value_range.m_vr.type (), - op_vr.type ()) - || !handler.fold_range (op_res, operand_type, - src_lats->m_value_range.m_vr, op_vr)) - op_res.set_varying (param_type); - - ipa_vr_operation_and_type_effects (vr, - op_res, - NOP_EXPR, param_type, - operand_type); - } - if (!vr.undefined_p () && !vr.varying_p ()) - { - if (jfunc->m_vr) - { - value_range jvr (param_type); - if (ipa_vr_operation_and_type_effects (jvr, *jfunc->m_vr, - NOP_EXPR, - param_type, - jfunc->m_vr->type ())) - vr.intersect (jvr); - } - return dest_lat->meet_with (vr); - } - } - else if (jfunc->type == IPA_JF_CONST) - { - tree val = ipa_get_jf_constant (jfunc); - if (TREE_CODE (val) == INTEGER_CST) - { - val = fold_convert (param_type, val); - if (TREE_OVERFLOW_P (val)) - val = drop_tree_overflow (val); - - value_range tmpvr (val, val); - return dest_lat->meet_with (tmpvr); - } + operand_type, param_type); } - value_range vr (param_type); - if (jfunc->m_vr - && ipa_vr_operation_and_type_effects (vr, *jfunc->m_vr, NOP_EXPR, - param_type, - jfunc->m_vr->type ())) + if (!vr.undefined_p () && !vr.varying_p ()) return dest_lat->meet_with (vr); else return dest_lat->set_to_bottom (); From patchwork Tue Nov 5 11:08:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 2006819 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=jPAPLzX3; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=n6BExQzr; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=x1LYX/BX; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=e1MvvVnW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjQb207Wpz1xyQ for ; Tue, 5 Nov 2024 22:09:33 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 20468385734E for ; Tue, 5 Nov 2024 11:09:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 5848D385840F for ; Tue, 5 Nov 2024 11:08:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5848D385840F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5848D385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730804926; cv=none; b=GzplREQ/dJfSCARshm5yBMhOisa3mlEtsCt9odIZl5nl0ewPnMY7zMtnUm60lP3QCgBDa0whHw7iEizTuBkg8XxF30WeLDR7jtnxp2E9M877uxGTveym9NJFEmCfIsLRewzMNLtb/iKDkXQ45dT1/dSbCSwDDO10TMUQD5eyJTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730804926; c=relaxed/simple; bh=PyDzmfbhqYFRqqXasFe5Bp5/Ws7bQ2VK60ZQoUlREfM=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=jWqr+IQ1Mfv4cs+cY343GSnv0IIeb1rp+2Oq4GDTwhteJtw/1/RkLmDTzyRZ86lgcDhUTFD3v0iWGm+Bz7E5DvxYToKF/pyjtS2P9eQtzcPkGSGH/FUleNmZvEIaGdKgVtBHcvul291vwIlqW68Ol24XL5BeN+dfYU/qJxfYMXc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 366121FBEF; Tue, 5 Nov 2024 11:08:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730804921; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=9Q+xWN4+LBYQC1tmhRj20rIdTAUW9gRYSVqCF+Z+lqk=; b=jPAPLzX32FLj9x/l9ClBUlCJSsAwEXWpudeNVVA2NeDsuZFjDzYQoKiuhh5uLQbqKAGX6S onStmXVyJLBmUnuJyeocSWrs4+QA9RHiBcPcfG25TiQr0aq/kZOyfbpwKLTTm/sezjGkDC yjd0WuHOHL1iFTt/3YNUUXQoxeGe2WI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730804921; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=9Q+xWN4+LBYQC1tmhRj20rIdTAUW9gRYSVqCF+Z+lqk=; b=n6BExQzro0wc1xX7VVE4Wp2jW6+1ofKOf4Z0Ay1JfzfKprrz2Xgqf3yaUllIw4HDkEwF6h GYU6fw3gs+lrYeBQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730804920; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=9Q+xWN4+LBYQC1tmhRj20rIdTAUW9gRYSVqCF+Z+lqk=; b=x1LYX/BXhldzoVV5Jg+wd2e/QcyRiNBMioiGpAlJPJY/X5ZruFHiCSEjbDIMECJ5IeZ/Y4 cmL4gpm6ojT+ag9xE1KRhTzmypy9BfeYBo3wBpdEOY4iJnHAtl0As236e+llapJ0rhRNOw QezhWdNlbN+ZFHGcc+6mT0j+QS6B970= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730804920; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=9Q+xWN4+LBYQC1tmhRj20rIdTAUW9gRYSVqCF+Z+lqk=; b=e1MvvVnWYQodb1QzbWCeviBig4S0LwGV97LhWlNd3oPRWYGPp3co0F85pnSxKwhDgGhCSm lSg1JCitFE/AqcCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2C3911394A; Tue, 5 Nov 2024 11:08:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sOrDCrj8KWdmXgAAD6G6ig (envelope-from ); Tue, 05 Nov 2024 11:08:40 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Aldy Hernandez Subject: [PATCH 3/8] ipa: Skip type conversions in jump function constructions User-Agent: Notmuch/0.38.3 (https://notmuchmail.org) Emacs/29.4 (x86_64-suse-linux-gnu) Date: Tue, 05 Nov 2024 12:08:39 +0100 Message-ID: MIME-Version: 1.0 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email, imap1.dmz-prg2.suse.org:helo, virgil.suse.cz:mid, ipa-prop.cc:url] X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, originally, we did not stream any formal parameter types into WPA and were generally very conservative when it came to type mismatches in IPA-CP. Over the time, mismatches that happen in code and blew up in WPA made us be much more resilient and also stream the types of the parameters which we now use commonly. With that information, we can skip conversions when looking at the IL from which we build jump functions because we can check that they are indeed OK and emulate them with fold_convert or, if not, at least deal with the undefined behavior input gracefully. With this change, we can nicely propagate non-NULLness in IPA-VR as demonstrated with the new test case. I have gone through all other uses of (all components of) jump functions which could be affected by this and verified they do indeed check types and can handle mismatches. Bootstrapped and tested on x86_64-linux, the whole patch series has additionally passed LTO and profiled-LTO bootstrap on the same platform and a bootstrap and testsuite on ppc64-linux. Aarch64-linux bootstrap and testing is in progress. OK for master is that passes too? Thanks, Martin gcc/ChangeLog: 2024-11-01 Martin Jambor * ipa-prop.cc (skip_a_conversion_op): New function. (ipa_compute_jump_functions_for_edge): Use it. gcc/testsuite/ChangeLog: 2024-11-01 Martin Jambor * gcc.dg/ipa/vrp9.c: New test. --- gcc/ipa-prop.cc | 20 ++++++++++++++ gcc/testsuite/gcc.dg/ipa/vrp9.c | 48 +++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/ipa/vrp9.c diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index db8eda8c361..9bd2e4bc60c 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -2305,6 +2305,25 @@ ipa_set_jfunc_vr (ipa_jump_func *jf, const ipa_vr &vr) ipa_set_jfunc_vr (jf, tmp); } + +/* If T is an SSA_NAME that is a result of a simple type conversion statement, + return the operand of that conversion, otherwise treturn T. */ + +static tree +skip_a_conversion_op (tree t) +{ + if (TREE_CODE (t) != SSA_NAME + || SSA_NAME_IS_DEFAULT_DEF (t)) + return t; + + gimple *def = SSA_NAME_DEF_STMT (t); + if (!is_gimple_assign (def) + || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def))) + return t; + + return gimple_assign_rhs1 (def); +} + /* Compute jump function for all arguments of callsite CS and insert the information in the jump_functions array in the ipa_edge_args corresponding to this callsite. */ @@ -2409,6 +2428,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, gcc_assert (!jfunc->m_vr); } + arg = skip_a_conversion_op (arg); if (is_gimple_ip_invariant (arg) || (VAR_P (arg) && is_global_var (arg) diff --git a/gcc/testsuite/gcc.dg/ipa/vrp9.c b/gcc/testsuite/gcc.dg/ipa/vrp9.c new file mode 100644 index 00000000000..461a2e757d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/vrp9.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int some_f1 (int); +int some_f2 (int); +int some_f3 (int); + +void remove_this_call (); + +int g; + +static int __attribute__((noinline)) +bar (int p) +{ + if (p) + remove_this_call (); + return g++; +} + +static int __attribute__((noinline)) +foo (int (*f)(int)) +{ + return bar (f == (void *)0); +} + +int +baz1 (void) +{ + int (*f)(int); + if (g) + f = some_f1; + else + f = some_f2; + return foo (f); +} + +int +baz2 (void) +{ + int (*f)(int); + if (g) + f = some_f2; + else + f = some_f3; + return foo (f); +} + +/* { dg-final { scan-tree-dump-not "remove_this_call" "optimized" } } */ From patchwork Tue Nov 5 11:09:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 2006821 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=SYAo0iZP; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vptBYCdv; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=SYAo0iZP; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vptBYCdv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjQbl214Bz1xyD for ; Tue, 5 Nov 2024 22:10:11 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 85CAE3857BA2 for ; Tue, 5 Nov 2024 11:10:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 588CB3857838 for ; Tue, 5 Nov 2024 11:09:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 588CB3857838 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 588CB3857838 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730804982; cv=none; b=uVPPp5l+yHQqNf+ww8fjRTaUVYMX4ALhLWKVXOtQECqB4fEIEVZr5rl8iQiq27oTRrmF65Oz73C5O/zqPTr6a+PJbHGYc9w1uCnWuVTna91MdsOYIYwdnvs+sHXL6nXQ+D7YROEEhZ29f8eJ1vlBQ76UsuHMvFT+J0R14bQJ2jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730804982; c=relaxed/simple; bh=5bQlItuYlC/JrU78zWVNw2MmDRBrIietpVnHyj4iJfg=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=mNmCwOKnCGFBUMbAE6EjOXieCB4evH81d8nT3MQkF8wAD8q90C250KdK7oP3+vHy9wrBDM7mQVvSkcsVjfW0LHHUyHmJfWdhb+dahhMtWMYk2d52MJM+NyI+mk9Ntd7d5IFKkzfySWKpqALkGPrXbrrTVw5TOSZDwqzuXoJU5cs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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-out1.suse.de (Postfix) with ESMTPS id 4F77521D99; Tue, 5 Nov 2024 11:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730804974; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=7cHL7sAXWCdJjMwCL1udndHECHgrxTh11PGWHPhfnQ0=; b=SYAo0iZPS4hlRjgBnHT8ycBksbsEDvHtC9Ssrjipg1cXbh3fHPwatOBhC1YC/YiBRWGy5R 11YjfcXe7DmE4KOEHtJqXp0K7qhEU0Vx6C4/OdyCp+tTbH9//RcCVTca/XFt8x+FNqJL9o JQw+dVpjLFsXiaM1AjgYsmd0/A8bOrg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730804974; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=7cHL7sAXWCdJjMwCL1udndHECHgrxTh11PGWHPhfnQ0=; b=vptBYCdvnj/Z13/ayk3uIIoisUPiFhRIGtrv094QnxnemNizo/zdLAvTX0WI/v7DcrLFSm Usx8Lil6vTyZ11Ag== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=SYAo0iZP; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vptBYCdv DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730804974; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=7cHL7sAXWCdJjMwCL1udndHECHgrxTh11PGWHPhfnQ0=; b=SYAo0iZPS4hlRjgBnHT8ycBksbsEDvHtC9Ssrjipg1cXbh3fHPwatOBhC1YC/YiBRWGy5R 11YjfcXe7DmE4KOEHtJqXp0K7qhEU0Vx6C4/OdyCp+tTbH9//RcCVTca/XFt8x+FNqJL9o JQw+dVpjLFsXiaM1AjgYsmd0/A8bOrg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730804974; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=7cHL7sAXWCdJjMwCL1udndHECHgrxTh11PGWHPhfnQ0=; b=vptBYCdvnj/Z13/ayk3uIIoisUPiFhRIGtrv094QnxnemNizo/zdLAvTX0WI/v7DcrLFSm Usx8Lil6vTyZ11Ag== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3AF9E1394A; Tue, 5 Nov 2024 11:09:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IBgWDu78KWefXgAAD6G6ig (envelope-from ); Tue, 05 Nov 2024 11:09:34 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Aldy Hernandez Subject: [PATCH 4/8] ipa: Better value ranges for zero pointer constants User-Agent: Notmuch/0.38.3 (https://notmuchmail.org) Emacs/29.4 (x86_64-suse-linux-gnu) Date: Tue, 05 Nov 2024 12:09:33 +0100 Message-ID: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4F77521D99 X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[virgil.suse.cz:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,ipa-prop.cc:url,suse.cz:dkim,suse.cz:email]; TO_DN_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, When looking into cases where we know an actual argument of a call is a constant but we don't generate a singleton value-range for the jump function, I found out that the special handling of pointer constants does not work well for constant zero pointer values. However, the code for other types works well for zeros, so I just added a simple test. With this patch, we generate [prange] struct S * [0, 0] MASK 0x0 VALUE 0x0 instead of for example: [prange] struct S * [0, +INF] MASK 0xfffffffffffffff0 VALUE 0x0 for a zero constant passed in a call. Bootstrapped and tested on x86_64-linux, the whole patch series has additionally passed LTO and profiled-LTO bootstrap on the same platform and a bootstrap and testsuite on ppc64-linux. Aarch64-linux bootstrap and testing is in progress. OK for master is that passes too? Thanks, Martin gcc/ChangeLog: 2024-11-01 Martin Jambor * ipa-prop.cc (ipa_compute_jump_functions_for_edge): When creating value-range jump functions from pointer type constant zero, do so as if it was not a pointer. --- gcc/ipa-prop.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 9bd2e4bc60c..012f8a32386 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -2368,7 +2368,8 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, } value_range vr (TREE_TYPE (arg)); - if (POINTER_TYPE_P (TREE_TYPE (arg))) + if (POINTER_TYPE_P (TREE_TYPE (arg)) + && !zerop (arg)) { bool addr_nonzero = false; bool strict_overflow = false; From patchwork Tue Nov 5 11:10:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 2006822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=SQKZCBeR; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=BTKKuSPZ; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=SQKZCBeR; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=BTKKuSPZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjQch0z8Tz1xyD for ; Tue, 5 Nov 2024 22:11:00 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5333E3857BA2 for ; Tue, 5 Nov 2024 11:10:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 6A5BE385735A for ; Tue, 5 Nov 2024 11:10:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A5BE385735A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6A5BE385735A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730805033; cv=none; b=fmywVJmtxC4WqyExNdGqSsmU/jRxVFSmDna3PF06BApRSzEkzP+VDC3bqAqcD5SnQWpNGXux4sKvfBWM1l0ozVb0zl/1UkPiIqahGAI4SariKHVTJMs4wYdB979g1vQRn91LAUW797YmEb3DYpIWX1hIMfwCesVOi49ANVUNwW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730805033; c=relaxed/simple; bh=MTvG2L4J6NCwcHmb529jQ7Wykc8Ug+D8U1gjijiGHkM=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=DDrsEhf0ZnYxWuXH2+jdwTDW52moevEWEIzyxczWiYYD9Nib+pN3MBxydmcxHJwGzPsm2sTdTML5B1fJQJwDjxzs0YGRlUBJ6sckyVG9czXlDdadfyOIYCUc9UUAViStt3se1YZamUDhVUXxwIBRYtsq5U0xtfRmluFHcpbphJI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 6D44F1FBCD; Tue, 5 Nov 2024 11:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730805028; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=gxpA3PQmzRo9YQyjYKNfd1EGM37N1160wH7Z2dK/UV8=; b=SQKZCBeRdjjmESaKEZvP9+aKrp+rcsFQ2ah1uxxKvRNWVsLJu+Eq73Y8EVqA/P4UfvpfRT qAJFqYnFmF2fzQRmAjl+pO7fmmZXf3fzjJLHFis6nOAZd+lTAkB9PxgyxlFyVvzXcx983K KjF1+bWw8tNlqMLY7JtQiMHTg2uec9g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730805028; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=gxpA3PQmzRo9YQyjYKNfd1EGM37N1160wH7Z2dK/UV8=; b=BTKKuSPZL+yGXKpv8myOAbRTPCt5+1VJNKiKt1uXdXFVTbVjrSFXW6f8L9e7PhyAvDPl/D 9y03yEGID5bPJPDg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730805028; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=gxpA3PQmzRo9YQyjYKNfd1EGM37N1160wH7Z2dK/UV8=; b=SQKZCBeRdjjmESaKEZvP9+aKrp+rcsFQ2ah1uxxKvRNWVsLJu+Eq73Y8EVqA/P4UfvpfRT qAJFqYnFmF2fzQRmAjl+pO7fmmZXf3fzjJLHFis6nOAZd+lTAkB9PxgyxlFyVvzXcx983K KjF1+bWw8tNlqMLY7JtQiMHTg2uec9g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730805028; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=gxpA3PQmzRo9YQyjYKNfd1EGM37N1160wH7Z2dK/UV8=; b=BTKKuSPZL+yGXKpv8myOAbRTPCt5+1VJNKiKt1uXdXFVTbVjrSFXW6f8L9e7PhyAvDPl/D 9y03yEGID5bPJPDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 64B4E1394A; Tue, 5 Nov 2024 11:10:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id a0CTGCT9KWftXgAAD6G6ig (envelope-from ); Tue, 05 Nov 2024 11:10:28 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Aldy Hernandez Subject: [PATCH 5/8] ipa: Update value range jump functions during inlining User-Agent: Notmuch/0.38.3 (https://notmuchmail.org) Emacs/29.4 (x86_64-suse-linux-gnu) Date: Tue, 05 Nov 2024 12:10:27 +0100 Message-ID: MIME-Version: 1.0 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, suse.cz:email, virgil.suse.cz:mid, ipa-prop.cc:url] X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, when inlining (during the analysis phase) a call graph edge, we update all pass-through jump functions corresponding to edges going out of the newly inlined function to be relative to the function into which we are inlining or to expose the information originally captured for the edge that is being inlined. Similarly, we can combine the value range information in pass-through jump functions corresponding to both edges, which is what this patch adds - at least for the case when the inlined pass-through is a simple, non-arithmetic one, which is the case that we also handle for constant and aggregate jump function parts. Bootstrapped and tested on x86_64-linux, the whole patch series has additionally passed LTO and profiled-LTO bootstrap on the same platform and a bootstrap and testsuite on ppc64-linux. Aarch64-linux bootstrap and testing is in progress. OK for master is that passes too? Thanks, Martin gcc/ChangeLog: 2024-11-01 Martin Jambor * ipa-cp.h: Forward declare class ipa_vr. (ipa_vr_operation_and_type_effects) Declare. * ipa-cp.cc (ipa_vr_operation_and_type_effects): Make public. * ipa-prop.cc (update_jump_functions_after_inlining): Also update value range jump functions. --- gcc/ipa-cp.cc | 4 ++-- gcc/ipa-cp.h | 13 +++++++++++++ gcc/ipa-prop.cc | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index fa4f0feeb8d..92dd2af19e0 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -1644,7 +1644,7 @@ ipa_context_from_jfunc (ipa_node_params *info, cgraph_edge *cs, int csidx, DST_TYPE on value range in SRC_VR and store it to DST_VR. Return true if the result is a range that is not VARYING nor UNDEFINED. */ -static bool +bool ipa_vr_operation_and_type_effects (vrange &dst_vr, const vrange &src_vr, enum tree_code operation, @@ -1670,7 +1670,7 @@ ipa_vr_operation_and_type_effects (vrange &dst_vr, /* Same as above, but the SRC_VR argument is an IPA_VR which must first be extracted onto a vrange. */ -static bool +bool ipa_vr_operation_and_type_effects (vrange &dst_vr, const ipa_vr &src_vr, enum tree_code operation, diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h index ba2ebfede63..4f569c1ee83 100644 --- a/gcc/ipa-cp.h +++ b/gcc/ipa-cp.h @@ -299,4 +299,17 @@ ipa_vr_supported_type_p (tree type) return irange::supports_p (type) || prange::supports_p (type); } +class ipa_vr; + +bool ipa_vr_operation_and_type_effects (vrange &dst_vr, + const vrange &src_vr, + enum tree_code operation, + tree dst_type, tree src_type); +bool ipa_vr_operation_and_type_effects (vrange &dst_vr, + const ipa_vr &src_vr, + enum tree_code operation, + tree dst_type, tree src_type); + + + #endif /* IPA_CP_H */ diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 012f8a32386..3b24bcbed15 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -3486,6 +3486,24 @@ update_jump_functions_after_inlining (struct cgraph_edge *cs, gcc_unreachable (); } + if (src->m_vr && src->m_vr->known_p ()) + { + value_range svr (src->m_vr->type ()); + if (!dst->m_vr || !dst->m_vr->known_p ()) + ipa_set_jfunc_vr (dst, *src->m_vr); + else if (ipa_vr_operation_and_type_effects (svr, *src->m_vr, + NOP_EXPR, + dst->m_vr->type (), + src->m_vr->type ())) + { + value_range dvr; + dst->m_vr->get_vrange (dvr); + dvr.intersect (svr); + if (!dvr.undefined_p ()) + ipa_set_jfunc_vr (dst, dvr); + } + } + if (src->agg.items && (dst_agg_p || !src->agg.by_ref)) { From patchwork Tue Nov 5 11:11:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 2006823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=1MXj8r2J; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=64mREt4J; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=1MXj8r2J; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=64mREt4J; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjQdn1639z1xyD for ; Tue, 5 Nov 2024 22:11:57 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CB9D3857729 for ; Tue, 5 Nov 2024 11:11:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 68EC3385771B for ; Tue, 5 Nov 2024 11:11:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 68EC3385771B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 68EC3385771B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730805093; cv=none; b=ff/d0OIpsb5oXzYA9EbXZaFpgCgsKYyM8QoSkTciojhy8gPXcWvchiV/wTV5QH835hjF9jV7rdtaH0eQR0rhmk43JwMpGlpONs/d7DN3znSRJVJ3t9E2N+9bFm7nwXELKaCYoV+H3IS/MT2HqgeuccqyLTCouTNnGolyQ1+1Aio= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730805093; c=relaxed/simple; bh=nGg1Oy3pKmjbHLqx/MkaZVvNbZ+l2BwW9weky5pz1wY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=i8GCd4nluQZ5PqyzNsMpn45gBkOHpinvloyMH9U1s1HKanuHdM55xYMpEsG3ttK/IOJVUvPJEDh8P5fwIIp+p2bZ03G9r48zp0syl8S6FpQa0b4NNU/ifMch2sz2oMjqa9i7jJ3qjgwyhoC1lWgQjnxs7fYMgYSzIaIj3rNCb0U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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-out1.suse.de (Postfix) with ESMTPS id 5168E21B67; Tue, 5 Nov 2024 11:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730805082; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=QsTYZDOrYc3FAHyAJoE87Jnm7Kni1D8M6viTHllQITU=; b=1MXj8r2JUhoXSVc8ZT/3KDfLr17aB/8CrM6CHQurWsPzzj4JeOvrztj5Y81ri7qGFowc5M 5MUNw6/uavgefc2+cO8nJYi/mYshN/QBlPraIgzV+I3VqNl96vU6j5isJxNogyrsx5Wdpz w9yU4qlzfNBvlsYqmBdvPp/9jaA05Wo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730805082; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=QsTYZDOrYc3FAHyAJoE87Jnm7Kni1D8M6viTHllQITU=; b=64mREt4JohBv9pvpSjW6HQ/7ye1ykA6FKMHGilSg0pkbgzKthOU1U3XsYwX2MQjcQJK0Ir K45bSBvCKqaUFqDw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=1MXj8r2J; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=64mREt4J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1730805082; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=QsTYZDOrYc3FAHyAJoE87Jnm7Kni1D8M6viTHllQITU=; b=1MXj8r2JUhoXSVc8ZT/3KDfLr17aB/8CrM6CHQurWsPzzj4JeOvrztj5Y81ri7qGFowc5M 5MUNw6/uavgefc2+cO8nJYi/mYshN/QBlPraIgzV+I3VqNl96vU6j5isJxNogyrsx5Wdpz w9yU4qlzfNBvlsYqmBdvPp/9jaA05Wo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1730805082; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=QsTYZDOrYc3FAHyAJoE87Jnm7Kni1D8M6viTHllQITU=; b=64mREt4JohBv9pvpSjW6HQ/7ye1ykA6FKMHGilSg0pkbgzKthOU1U3XsYwX2MQjcQJK0Ir K45bSBvCKqaUFqDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 47F391394A; Tue, 5 Nov 2024 11:11:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id g5+LEVr9KWc3XwAAD6G6ig (envelope-from ); Tue, 05 Nov 2024 11:11:22 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Aldy Hernandez Subject: [PATCH 6/8] ipa: Introduce a one jump function dumping function User-Agent: Notmuch/0.38.3 (https://notmuchmail.org) Emacs/29.4 (x86_64-suse-linux-gnu) Date: Tue, 05 Nov 2024 12:11:17 +0100 Message-ID: MIME-Version: 1.0 X-Rspamd-Queue-Id: 5168E21B67 X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[virgil.suse.cz:mid,ipa-prop.cc:url,suse.cz:dkim,suse.cz:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; TO_DN_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, the next patch in the series introduces a verifier that prints a single jump function when it fails with the function introduced in this one. Because it is a verifier, the risk that it would need to e reverted are non-zero and because the function can be useful on its own, this is a special patch to introduce it. Bootstrapped and tested on x86_64-linux, the whole patch series has additionally passed LTO and profiled-LTO bootstrap on the same platform and a bootstrap and testsuite on ppc64-linux. Aarch64-linux bootstrap and testing is in progress. OK for master is that passes too? Thanks, Martin gcc/ChangeLog: 2024-11-01 Martin Jambor * ipa-prop.h (ipa_dump_jump_function): Declare. * ipa-prop.cc (ipa_dump_jump_function): New function. (ipa_print_node_jump_functions_for_edge): Move printing of individual jump functions to the new function. --- gcc/ipa-prop.cc | 221 +++++++++++++++++++++++++----------------------- gcc/ipa-prop.h | 2 + 2 files changed, 116 insertions(+), 107 deletions(-) diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 3b24bcbed15..3ff4753653b 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -429,6 +429,117 @@ ipa_print_constant_value (FILE *f, tree val) } } +/* Print contents of JFUNC to F. If CTX is non-NULL, dump it too. */ + +DEBUG_FUNCTION void +ipa_dump_jump_function (FILE *f, ipa_jump_func *jump_func, + class ipa_polymorphic_call_context *ctx) +{ + enum jump_func_type type = jump_func->type; + + if (type == IPA_JF_UNKNOWN) + fprintf (f, "UNKNOWN\n"); + else if (type == IPA_JF_CONST) + { + fprintf (f, "CONST: "); + ipa_print_constant_value (f, jump_func->value.constant.value); + fprintf (f, "\n"); + } + else if (type == IPA_JF_PASS_THROUGH) + { + fprintf (f, "PASS THROUGH: "); + fprintf (f, "%d, op %s", + jump_func->value.pass_through.formal_id, + get_tree_code_name(jump_func->value.pass_through.operation)); + if (jump_func->value.pass_through.operation != NOP_EXPR) + { + fprintf (f, " "); + print_generic_expr (f, jump_func->value.pass_through.operand); + } + if (jump_func->value.pass_through.agg_preserved) + fprintf (f, ", agg_preserved"); + if (jump_func->value.pass_through.refdesc_decremented) + fprintf (f, ", refdesc_decremented"); + fprintf (f, "\n"); + } + else if (type == IPA_JF_ANCESTOR) + { + fprintf (f, "ANCESTOR: "); + fprintf (f, "%d, offset " HOST_WIDE_INT_PRINT_DEC, + jump_func->value.ancestor.formal_id, + jump_func->value.ancestor.offset); + if (jump_func->value.ancestor.agg_preserved) + fprintf (f, ", agg_preserved"); + if (jump_func->value.ancestor.keep_null) + fprintf (f, ", keep_null"); + fprintf (f, "\n"); + } + + if (jump_func->agg.items) + { + struct ipa_agg_jf_item *item; + int j; + + fprintf (f, " Aggregate passed by %s:\n", + jump_func->agg.by_ref ? "reference" : "value"); + FOR_EACH_VEC_ELT (*jump_func->agg.items, j, item) + { + fprintf (f, " offset: " HOST_WIDE_INT_PRINT_DEC ", ", + item->offset); + fprintf (f, "type: "); + print_generic_expr (f, item->type); + fprintf (f, ", "); + if (item->jftype == IPA_JF_PASS_THROUGH) + fprintf (f, "PASS THROUGH: %d,", + item->value.pass_through.formal_id); + else if (item->jftype == IPA_JF_LOAD_AGG) + { + fprintf (f, "LOAD AGG: %d", + item->value.pass_through.formal_id); + fprintf (f, " [offset: " HOST_WIDE_INT_PRINT_DEC ", by %s],", + item->value.load_agg.offset, + item->value.load_agg.by_ref ? "reference" + : "value"); + } + + if (item->jftype == IPA_JF_PASS_THROUGH + || item->jftype == IPA_JF_LOAD_AGG) + { + fprintf (f, " op %s", + get_tree_code_name (item->value.pass_through.operation)); + if (item->value.pass_through.operation != NOP_EXPR) + { + fprintf (f, " "); + print_generic_expr (f, item->value.pass_through.operand); + } + } + else if (item->jftype == IPA_JF_CONST) + { + fprintf (f, "CONST: "); + ipa_print_constant_value (f, item->value.constant); + } + else if (item->jftype == IPA_JF_UNKNOWN) + fprintf (f, "UNKNOWN: " HOST_WIDE_INT_PRINT_DEC " bits", + tree_to_uhwi (TYPE_SIZE (item->type))); + fprintf (f, "\n"); + } + } + + if (ctx && !ctx->useless_p ()) + { + fprintf (f, " Context: "); + ctx->dump (dump_file); + } + + if (jump_func->m_vr) + { + jump_func->m_vr->dump (f); + fprintf (f, "\n"); + } + else + fprintf (f, " Unknown VR\n"); +} + /* Print the jump functions associated with call graph edge CS to file F. */ static void @@ -439,116 +550,12 @@ ipa_print_node_jump_functions_for_edge (FILE *f, struct cgraph_edge *cs) for (int i = 0; i < count; i++) { - struct ipa_jump_func *jump_func; - enum jump_func_type type; - - jump_func = ipa_get_ith_jump_func (args, i); - type = jump_func->type; - - fprintf (f, " param %d: ", i); - if (type == IPA_JF_UNKNOWN) - fprintf (f, "UNKNOWN\n"); - else if (type == IPA_JF_CONST) - { - fprintf (f, "CONST: "); - ipa_print_constant_value (f, jump_func->value.constant.value); - fprintf (f, "\n"); - } - else if (type == IPA_JF_PASS_THROUGH) - { - fprintf (f, "PASS THROUGH: "); - fprintf (f, "%d, op %s", - jump_func->value.pass_through.formal_id, - get_tree_code_name(jump_func->value.pass_through.operation)); - if (jump_func->value.pass_through.operation != NOP_EXPR) - { - fprintf (f, " "); - print_generic_expr (f, jump_func->value.pass_through.operand); - } - if (jump_func->value.pass_through.agg_preserved) - fprintf (f, ", agg_preserved"); - if (jump_func->value.pass_through.refdesc_decremented) - fprintf (f, ", refdesc_decremented"); - fprintf (f, "\n"); - } - else if (type == IPA_JF_ANCESTOR) - { - fprintf (f, "ANCESTOR: "); - fprintf (f, "%d, offset " HOST_WIDE_INT_PRINT_DEC, - jump_func->value.ancestor.formal_id, - jump_func->value.ancestor.offset); - if (jump_func->value.ancestor.agg_preserved) - fprintf (f, ", agg_preserved"); - if (jump_func->value.ancestor.keep_null) - fprintf (f, ", keep_null"); - fprintf (f, "\n"); - } - - if (jump_func->agg.items) - { - struct ipa_agg_jf_item *item; - int j; - - fprintf (f, " Aggregate passed by %s:\n", - jump_func->agg.by_ref ? "reference" : "value"); - FOR_EACH_VEC_ELT (*jump_func->agg.items, j, item) - { - fprintf (f, " offset: " HOST_WIDE_INT_PRINT_DEC ", ", - item->offset); - fprintf (f, "type: "); - print_generic_expr (f, item->type); - fprintf (f, ", "); - if (item->jftype == IPA_JF_PASS_THROUGH) - fprintf (f, "PASS THROUGH: %d,", - item->value.pass_through.formal_id); - else if (item->jftype == IPA_JF_LOAD_AGG) - { - fprintf (f, "LOAD AGG: %d", - item->value.pass_through.formal_id); - fprintf (f, " [offset: " HOST_WIDE_INT_PRINT_DEC ", by %s],", - item->value.load_agg.offset, - item->value.load_agg.by_ref ? "reference" - : "value"); - } - - if (item->jftype == IPA_JF_PASS_THROUGH - || item->jftype == IPA_JF_LOAD_AGG) - { - fprintf (f, " op %s", - get_tree_code_name (item->value.pass_through.operation)); - if (item->value.pass_through.operation != NOP_EXPR) - { - fprintf (f, " "); - print_generic_expr (f, item->value.pass_through.operand); - } - } - else if (item->jftype == IPA_JF_CONST) - { - fprintf (f, "CONST: "); - ipa_print_constant_value (f, item->value.constant); - } - else if (item->jftype == IPA_JF_UNKNOWN) - fprintf (f, "UNKNOWN: " HOST_WIDE_INT_PRINT_DEC " bits", - tree_to_uhwi (TYPE_SIZE (item->type))); - fprintf (f, "\n"); - } - } - + struct ipa_jump_func *jump_func = ipa_get_ith_jump_func (args, i); class ipa_polymorphic_call_context *ctx = ipa_get_ith_polymorhic_call_context (args, i); - if (ctx && !ctx->useless_p ()) - { - fprintf (f, " Context: "); - ctx->dump (dump_file); - } - if (jump_func->m_vr) - { - jump_func->m_vr->dump (f); - fprintf (f, "\n"); - } - else - fprintf (f, " Unknown VR\n"); + fprintf (f, " param %d: ", i); + ipa_dump_jump_function (f, jump_func, ctx); } } diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 7a05c169c42..3215395286b 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -1247,6 +1247,8 @@ void ipa_push_agg_values_from_jfunc (ipa_node_params *info, cgraph_node *node, unsigned dst_index, vec *res); void ipa_dump_param (FILE *, class ipa_node_params *info, int i); +void ipa_dump_jump_function (FILE *f, ipa_jump_func *jfunc, + class ipa_polymorphic_call_context *ctx = NULL); void ipa_release_body_info (struct ipa_func_body_info *); tree ipa_get_callee_param_type (struct cgraph_edge *e, int i); bool ipcp_get_parm_bits (tree, tree *, widest_int *);