Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2220936/?format=api
{ "id": 2220936, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2220936/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/ri6wlyhzl8w.fsf@virgil.suse.cz/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.1/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null }, "msgid": "<ri6wlyhzl8w.fsf@virgil.suse.cz>", "date": "2026-04-08T12:31:43", "name": "ipa: Type-convert constants in jump functions during inlining (PR124777)", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "e9d79797edbc5144a6dbe7c0db94d648c7202ca8", "submitter": { "id": 4351, "url": "http://patchwork.ozlabs.org/api/1.1/people/4351/?format=api", "name": "Martin Jambor", "email": "mjambor@suse.cz" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/ri6wlyhzl8w.fsf@virgil.suse.cz/mbox/", "series": [ { "id": 499134, "url": "http://patchwork.ozlabs.org/api/1.1/series/499134/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=499134", "date": "2026-04-08T12:31:43", "name": "ipa: Type-convert constants in jump functions during inlining (PR124777)", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499134/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2220936/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2220936/checks/", "tags": {}, "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256\n header.s=susede2_rsa header.b=igXAv67A;\n\tdkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=sAtVXfqE;\n\tdkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz\n header.a=rsa-sha256 header.s=susede2_rsa header.b=igXAv67A;\n\tdkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=sAtVXfqE;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256\n header.s=susede2_rsa header.b=igXAv67A;\n\tdkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=sAtVXfqE;\n\tdkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz\n header.a=rsa-sha256 header.s=susede2_rsa header.b=igXAv67A;\n\tdkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=sAtVXfqE", "sourceware.org;\n dmarc=none (p=none dis=none) header.from=suse.cz", "sourceware.org; spf=pass smtp.mailfrom=suse.cz", "server2.sourceware.org;\n arc=none smtp.remote-ip=195.135.223.130", "smtp-out1.suse.de;\n dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=igXAv67A;\n dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=sAtVXfqE" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frMs058N4z1xv0\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 08 Apr 2026 22:32:19 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 49BCD4BA2E0D\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 8 Apr 2026 12:32:17 +0000 (GMT)", "from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130])\n by sourceware.org (Postfix) with ESMTPS id A47194BA540B\n for <gcc-patches@gcc.gnu.org>; Wed, 8 Apr 2026 12:31:48 +0000 (GMT)", "from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org\n [IPv6:2a07:de40:b281:104:10:150:64:97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out1.suse.de (Postfix) with ESMTPS id 8D72A4E9C5;\n Wed, 8 Apr 2026 12:31:47 +0000 (UTC)", "from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8540E4A0B3;\n Wed, 8 Apr 2026 12:31:47 +0000 (UTC)", "from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id SlmFILNK1mniagAAD6G6ig\n (envelope-from <mjambor@suse.cz>); Wed, 08 Apr 2026 12:31:47 +0000" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 49BCD4BA2E0D", "OpenDKIM Filter v2.11.0 sourceware.org A47194BA540B" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org A47194BA540B", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org A47194BA540B", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775651509; cv=none;\n b=aiEw8+edONp1MDcuN5+FNOF83pmKybBTnZ/eBHS3sHJYMbSPi2NOuOM7hsqyImOzhRtfkw9ZUNf+4yspnHngLlNPnClS8zngzEAQyH66Mml+4/44M01/Z0CztSEzVviQvm30VZoJ9OzcNW8yW/8kthbjzexJWHVVTHjGgGUmTDg=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775651509; c=relaxed/simple;\n bh=fyMH9E02M4ZPYZi5PwKut5qOVZ7F3puYRObvQdNHnek=;\n h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From:\n To:Subject:Date:Message-ID:MIME-Version;\n b=qURVsBq6iRpCBydhzDgrIjUVbbvOb61bD0YRisl8jswLHhHfMjMEGWboNCjLDObfKVBd513AG84XwjVQfSG6OJedinhOk9nTs/1odMNxPfO7Tks2DzEMJrfYKGH6viq/FCEAk+0m4NfpbVSAxftHKt1wC4yoM5TyYzbTDzuTMPA=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz;\n s=susede2_rsa;\n t=1775651507;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type;\n bh=O+TV1ug6PpO3aLc17owyxjtTDAuU6kqIBba9j9r6u+4=;\n b=igXAv67A4+NXKgj+zVIJyZwcLNaparLphwOxp1/qr5SgDzZpeOXegP0P+JWea6mCK0zkrO\n 9iY8N0GSccf/7dvoxwhdM2DJ08MGhBthSamJ5gkXNtD2EOyfIXArwFpbtKi39ttiWjbcqU\n CiSiyjbCfeJUDnO+6cJ/6Bmcao/nUqo=", "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz;\n s=susede2_ed25519; t=1775651507;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type;\n bh=O+TV1ug6PpO3aLc17owyxjtTDAuU6kqIBba9j9r6u+4=;\n b=sAtVXfqEfZLusNSPYV4laaFPHBxV1w0BX3zsV4wi2t34Ba6TsMeus3xbXLovSGxjABKgmu\n EzlcoFKXUKFhZVAQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz;\n s=susede2_rsa;\n t=1775651507;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type;\n bh=O+TV1ug6PpO3aLc17owyxjtTDAuU6kqIBba9j9r6u+4=;\n b=igXAv67A4+NXKgj+zVIJyZwcLNaparLphwOxp1/qr5SgDzZpeOXegP0P+JWea6mCK0zkrO\n 9iY8N0GSccf/7dvoxwhdM2DJ08MGhBthSamJ5gkXNtD2EOyfIXArwFpbtKi39ttiWjbcqU\n CiSiyjbCfeJUDnO+6cJ/6Bmcao/nUqo=", "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz;\n s=susede2_ed25519; t=1775651507;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type;\n bh=O+TV1ug6PpO3aLc17owyxjtTDAuU6kqIBba9j9r6u+4=;\n b=sAtVXfqEfZLusNSPYV4laaFPHBxV1w0BX3zsV4wi2t34Ba6TsMeus3xbXLovSGxjABKgmu\n EzlcoFKXUKFhZVAQ==" ], "From": "Martin Jambor <mjambor@suse.cz>", "To": "GCC Patches <gcc-patches@gcc.gnu.org>", "Cc": "Jan Hubicka <hubicka@ucw.cz>", "Subject": "[PATCH] ipa: Type-convert constants in jump functions during\n inlining (PR124777)", "User-Agent": "Notmuch/0.38.3 (https://notmuchmail.org) Emacs/30.2\n (x86_64-suse-linux-gnu)", "Date": "Wed, 08 Apr 2026 14:31:43 +0200", "Message-ID": "<ri6wlyhzl8w.fsf@virgil.suse.cz>", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Rspamd-Action": "no action", "X-Rspamd-Server": "rspamd2.dmz-prg2.suse.org", "X-Spamd-Result": "default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n NEURAL_HAM_LONG(-1.00)[-1.000];\n R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519];\n NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain];\n MX_GOOD(-0.01)[]; TO_DN_ALL(0.00)[];\n DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519];\n FROM_HAS_DN(0.00)[];\n RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from];\n RCPT_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[];\n FUZZY_RATELIMITED(0.00)[rspamd.com];\n TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[];\n DKIM_TRACE(0.00)[suse.cz:+]; RCVD_COUNT_TWO(0.00)[2];\n FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+];\n DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received];\n RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received];\n MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[];\n SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]", "X-Rspamd-Queue-Id": "8D72A4E9C5", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "Hi,\n\nPR 124777 revealed that update_jump_functions_after_inlining does not\nproperly fold_convert constants when it propagates them from constant\njump functions to formerly pass-through ones, leading to expectations\nof wrong constants in parameters leading to inserting bogus\nbuiltin_unreachables during inlining.\n\nThis patch fixes it by calling ipacp_value_safe_for_type which is what\nIPA-CP uses during its propagation and moved handling of the case to a\nseparate function.\n\nBootstrapped and LTO-bootstrapped and tested on x86_64-linux. OK for\nmaster?\n\nThanks,\n\nMartin\n\n\ngcc/ChangeLog:\n\n2026-04-07 Martin Jambor <mjambor@suse.cz>\n\n\tPR ipa/124777\n\t* ipa-cp.h (ipacp_value_safe_for_type): Declare.\n\t* ipa-cp.cc (ipacp_value_safe_for_type): Make public.\n\t* ipa-prop.cc (ipa_set_jf_cst_copy): Fix comment.\n\t(ipa_convert_prop_cst_jf): New function.\n\t(update_jump_functions_after_inlining): Handle the constant to\n\tpass-through case by calling ipa_convert_prop_cst_jf.\n\ngcc/testsuite/ChangeLog:\n\n2026-04-07 Martin Jambor <mjambor@suse.cz>\n\n\tPR ipa/124777\n\t* gcc.dg/ipa/pr124777.c: New test.\n---\n gcc/ipa-cp.cc | 2 +-\n gcc/ipa-cp.h | 1 +\n gcc/ipa-prop.cc | 44 +++++++++++++++++++++++------\n gcc/testsuite/gcc.dg/ipa/pr124777.c | 38 +++++++++++++++++++++++++\n 4 files changed, 75 insertions(+), 10 deletions(-)\n create mode 100644 gcc/testsuite/gcc.dg/ipa/pr124777.c", "diff": "diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc\nindex e96b1dc8391..337fca71013 100644\n--- a/gcc/ipa-cp.cc\n+++ b/gcc/ipa-cp.cc\n@@ -1544,7 +1544,7 @@ initialize_node_lattices (struct cgraph_node *node)\n propagated to a parameter of type PARAM_TYPE, or return a fold-converted\n VALUE to PARAM_TYPE if that is possible. Return NULL_TREE otherwise. */\n \n-static tree\n+tree\n ipacp_value_safe_for_type (tree param_type, tree value)\n {\n if (!value)\ndiff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h\nindex 45da483e9ab..8191aac5c5b 100644\n--- a/gcc/ipa-cp.h\n+++ b/gcc/ipa-cp.h\n@@ -323,6 +323,7 @@ bool ipa_vr_operation_and_type_effects (vrange &dst_vr,\n \t\t\t\t\tconst ipa_vr &src_vr,\n \t\t\t\t\tenum tree_code operation,\n \t\t\t\t\ttree dst_type, tree src_type);\n+tree ipacp_value_safe_for_type (tree param_type, tree value);\n \n \n \ndiff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc\nindex ea7519a17d3..dee7632eef0 100644\n--- a/gcc/ipa-prop.cc\n+++ b/gcc/ipa-prop.cc\n@@ -680,8 +680,8 @@ ipa_set_jf_unknown (struct ipa_jump_func *jfunc)\n jfunc->type = IPA_JF_UNKNOWN;\n }\n \n-/* Set JFUNC to be a copy of another jmp (to be used by jump function\n- combination code). The two functions will share their rdesc. */\n+/* Set DST to be a copy of another SRC. The two functions will share their\n+ rdesc. */\n \n static void\n ipa_set_jf_cst_copy (struct ipa_jump_func *dst,\n@@ -693,6 +693,36 @@ ipa_set_jf_cst_copy (struct ipa_jump_func *dst,\n dst->value.constant = src->value.constant;\n }\n \n+/* Set DST to be a copy of another jump function SRC but possibly adjust it to\n+ a new passed type PARM_TYPE. If the adjustment fails, the jump function can\n+ end up being set to the unknown type. If the conversion is not necessary or\n+ it succeeds and if the destination rdesc has not been already used, the two\n+ functions will share their rdesc. */\n+\n+static void\n+ipa_convert_prop_cst_jf (struct ipa_jump_func *dst,\n+\t\t\t struct ipa_jump_func *src,\n+\t\t\t tree parm_type)\n+\n+{\n+ gcc_checking_assert (src->type == IPA_JF_CONST);\n+ tree new_val = ipacp_value_safe_for_type (parm_type,\n+\t\t\t\t\t ipa_get_jf_constant (src));\n+ if (new_val)\n+ {\n+ bool rd = ipa_get_jf_pass_through_refdesc_decremented (dst);\n+\n+ dst->type = IPA_JF_CONST;\n+ dst->value.constant.value = new_val;\n+ if (!rd)\n+\tdst->value.constant.rdesc = src->value.constant.rdesc;\n+ else\n+\tipa_zap_jf_refdesc (dst);\n+ }\n+ else\n+ ipa_set_jf_unknown (dst);\n+}\n+\n /* Set JFUNC to be a constant jmp function. */\n \n static void\n@@ -3863,13 +3893,9 @@ update_jump_functions_after_inlining (struct cgraph_edge *cs,\n \t\t ipa_set_jf_unknown (dst);\n \t\t break;\n \t\tcase IPA_JF_CONST:\n-\t\t {\n-\t\t bool rd = ipa_get_jf_pass_through_refdesc_decremented (dst);\n-\t\t ipa_set_jf_cst_copy (dst, src);\n-\t\t if (rd)\n-\t\t ipa_zap_jf_refdesc (dst);\n-\t\t }\n-\n+\t\t ipa_convert_prop_cst_jf (dst, src,\n+\t\t\t\t\t ipa_get_type (old_inline_root_info,\n+\t\t\t\t\t\t\t dst_fid));\n \t\t break;\n \n \t\tcase IPA_JF_PASS_THROUGH:\ndiff --git a/gcc/testsuite/gcc.dg/ipa/pr124777.c b/gcc/testsuite/gcc.dg/ipa/pr124777.c\nnew file mode 100644\nindex 00000000000..210eb7c36b9\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/ipa/pr124777.c\n@@ -0,0 +1,38 @@\n+/* { dg-do run } */\n+/* { dg-options \"-O2 -fno-early-inlining\" } */\n+\n+int a;\n+char b;\n+void c() {\n+ __builtin_exit(0);\n+}\n+\n+typedef short (*t_d)(unsigned);\n+\n+static short __attribute__((noclone))\n+d(unsigned f)\n+{\n+ if (f == (unsigned)(unsigned short)-1)\n+ c ();\n+ for (; a; a++)\n+ ;\n+}\n+\n+typedef short (*t_g)(unsigned, unsigned, unsigned short, t_d);\n+\n+static short __attribute__((noclone))\n+g(unsigned f, unsigned h, unsigned short i, t_d p_d) {\n+ if (f || h)\n+ p_d(i);\n+}\n+\n+static unsigned __attribute__((noclone))\n+j(unsigned f, signed char h, t_d p_d, t_g p_g) {\n+ p_g(b, 1, h, p_d);\n+}\n+\n+int main() {\n+ signed char e = -1;\n+ j(0, e, d, g);\n+ return 0;\n+}\n", "prefixes": [] }