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 *);