get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2226757/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2226757,
    "url": "http://patchwork.ozlabs.org/api/patches/2226757/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhup4p5wp2.gcc.gcc-TEST.pinskia.84.1.3@forge-stage.sourceware.org/",
    "project": {
        "id": 17,
        "url": "http://patchwork.ozlabs.org/api/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,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<bmm.hhup4p5wp2.gcc.gcc-TEST.pinskia.84.1.3@forge-stage.sourceware.org>",
    "list_archive_url": null,
    "date": "2026-04-22T18:49:11",
    "name": "[v1,03/10] fab: rewrite optimize_stack_restore call check [PR122033]",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "108c524e23a71d6323ee82154fd59eb5ef74b0bf",
    "submitter": {
        "id": 93219,
        "url": "http://patchwork.ozlabs.org/api/people/93219/?format=api",
        "name": "Andrew Pinski via Sourceware Forge",
        "email": "forge-bot+pinskia@forge-stage.sourceware.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhup4p5wp2.gcc.gcc-TEST.pinskia.84.1.3@forge-stage.sourceware.org/mbox/",
    "series": [
        {
            "id": 501092,
            "url": "http://patchwork.ozlabs.org/api/series/501092/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=501092",
            "date": "2026-04-22T18:49:11",
            "name": "remove_fab",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/501092/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2226757/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2226757/checks/",
    "tags": {},
    "related": [],
    "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 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; dmarc=none (p=none dis=none)\n header.from=forge-stage.sourceware.org",
            "sourceware.org;\n spf=pass smtp.mailfrom=forge-stage.sourceware.org",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=38.145.34.39"
        ],
        "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 4g18L0559Qz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 05:24:24 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DA951465B675\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 19:24:22 +0000 (GMT)",
            "from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id CD92241BBF56\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 18:50:41 +0000 (GMT)",
            "from forge-stage.sourceware.org (localhost [IPv6:::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256)\n (No client certificate requested)\n by forge-stage.sourceware.org (Postfix) with ESMTPS id 9B7A643592\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 18:50:41 +0000 (UTC)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org DA951465B675",
            "OpenDKIM Filter v2.11.0 sourceware.org CD92241BBF56"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org CD92241BBF56",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org CD92241BBF56",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776883841; cv=none;\n b=D9NjTT/YN6hk/uAAjO76rRr8S5tbvvIfALKoytsyi5MM8+FONM0VzFgpqqEb1K2Ah06IKW0UZSOAu0rnWeLh5Esy44VEp5QJnL59up4+EabEpw6k53oduDjCswFeCx7U1VKitV20G3Oyg/uxJcYo5gC6H+WqEv/q0I8dJfrGxz8=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776883841; c=relaxed/simple;\n bh=MJcdHRJTwplUSAsDc76UaoBG/dBIkD89lf37xw2em8c=;\n h=From:Date:Subject:To:Message-ID;\n b=w/kLsh51tBsbKMKMO+v2jKw9zIP28wBbDLMQhZqu8EM7qw8KRNX0HdnLIDTunLw1sUEjhdjsPhPcpIMRbrt7ipT2LtMZ0ReT546Nuo0CTzOFSrXdtFptP7AtWblOUOJOstTldYCKdZ1HPZqAUzGPGG5UZr3ujBjJAKpowYFSstY=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "From": "Andrew Pinski via Sourceware Forge\n <forge-bot+pinskia@forge-stage.sourceware.org>",
        "Date": "Wed, 22 Apr 2026 18:49:11 +0000",
        "Subject": "[PATCH v1 03/10] fab: rewrite optimize_stack_restore call check\n [PR122033]",
        "To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>",
        "Message-ID": "\n <bmm.hhup4p5wp2.gcc.gcc-TEST.pinskia.84.1.3@forge-stage.sourceware.org>",
        "X-Mailer": "batrachomyomachia",
        "X-Pull-Request-Organization": "gcc",
        "X-Pull-Request-Repository": "gcc-TEST",
        "X-Pull-Request": "https://forge.sourceware.org/gcc/gcc-TEST/pulls/84",
        "References": "\n <bmm.hhup4p5wp2.gcc.gcc-TEST.pinskia.84.1.0@forge-stage.sourceware.org>",
        "In-Reply-To": "\n <bmm.hhup4p5wp2.gcc.gcc-TEST.pinskia.84.1.0@forge-stage.sourceware.org>",
        "X-Patch-URL": "\n https://forge.sourceware.org/pinskia/gcc-TEST/commit/3d9ed1c1ede760560fc4919bb0445222e0d5431b",
        "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>",
        "Reply-To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>,\n pinskia@gcc.gnu.org",
        "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"
    },
    "content": "From: Andrew Pinski <andrew.pinski@oss.qualcomm.com>\n\nThe call check in optimize_stack_restore is not the same as\nwhat is described in the comment before the function. It has never\nbeen the same even. It has always allowed all nromal builtins but not\ntarget builtins while the comment says no calls.\n\nThis rewrites it to allow the following.\n* a restore right before a noreturn is fine to be removed as the noreturn\n  function will do the restore (or exit the program).\n* Internal functions are ok because they will turn into an instruction or 2\n* Still specifically reject alloca and __scrub_leave\n* simple or inexpensive builtins (including target builtins)\n\nThis will both reject some more locations but also accepts more locations due\nto the internal and target and noreturn function calls checks.\n\nBootstrapped and tested on x86_64-linux-gnu.\n\n\tPR tree-optimization/122033\ngcc/ChangeLog:\n\n\t* tree-ssa-ccp.cc (optimize_stack_restore): Rewrite the call check.\n\tUpdate comment in the front to new rules on calls.\n\t* tree.h (fndecl_builtin_alloc_p): New function.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.dg/tree-ssa/pr122033-1.c: New test.\n\t* gcc.dg/tree-ssa/pr122033-2.c: New test.\n\nSigned-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>\n---\n gcc/testsuite/gcc.dg/tree-ssa/pr122033-1.c | 18 +++++++++\n gcc/testsuite/gcc.dg/tree-ssa/pr122033-2.c | 23 ++++++++++++\n gcc/tree-ssa-ccp.cc                        | 43 ++++++++++++++++------\n gcc/tree.h                                 |  9 +++++\n 4 files changed, 81 insertions(+), 12 deletions(-)\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr122033-1.c\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr122033-2.c",
    "diff": "diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr122033-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr122033-1.c\nnew file mode 100644\nindex 000000000000..4ef8c6c3150f\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr122033-1.c\n@@ -0,0 +1,18 @@\n+/* PR middle-end/122033 */\n+/* { dg-do compile } */\n+/* { dg-options \"-O2 -fdump-tree-optimized\" } */\n+\n+void bar1 (char *, int);\n+void bar3(void) __attribute__((noreturn));\n+void foo1 (int size)\n+{\n+  {\n+    char temp[size];\n+    temp[size-1] = '\\0';\n+    bar1 (temp, size);\n+  }\n+  bar3 ();\n+}\n+\n+/* { dg-final { scan-tree-dump-not \"__builtin_stack_save\" \"optimized\"} } */\n+/* { dg-final { scan-tree-dump-not \"__builtin_stack_restore\" \"optimized\"} } */\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr122033-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr122033-2.c\nnew file mode 100644\nindex 000000000000..f429324f64c7\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr122033-2.c\n@@ -0,0 +1,23 @@\n+/* PR middle-end/122033 */\n+/* { dg-do compile } */\n+/* { dg-options \"-O2 -fdump-tree-optimized\" } */\n+\n+void g(int*);\n+void h();\n+double t;\n+void f(int a, int b)\n+{\n+  {\n+    int array0[a];\n+    {\n+      int array1[b];\n+      g(array0);\n+      g(array1);\n+    }\n+    t = __builtin_sin(t);\n+  }\n+  h ();\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"__builtin_stack_save\" 2 \"optimized\"} } */\n+/* { dg-final { scan-tree-dump-times \"__builtin_stack_restore\" 2 \"optimized\"} } */\ndiff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc\nindex c9ffd2af85c2..070289ca9f0a 100644\n--- a/gcc/tree-ssa-ccp.cc\n+++ b/gcc/tree-ssa-ccp.cc\n@@ -3091,7 +3091,9 @@ make_pass_ccp (gcc::context *ctxt)\n    if there is another __builtin_stack_restore in the same basic\n    block and no calls or ASM_EXPRs are in between, or if this block's\n    only outgoing edge is to EXIT_BLOCK and there are no calls or\n-   ASM_EXPRs after this __builtin_stack_restore.  */\n+   ASM_EXPRs after this __builtin_stack_restore.\n+   Note restore right before a noreturn function is not needed.\n+   And skip some cheap calls that will most likely become an instruction.  */\n \n static tree\n optimize_stack_restore (gimple_stmt_iterator i)\n@@ -3111,26 +3113,43 @@ optimize_stack_restore (gimple_stmt_iterator i)\n   for (gsi_next (&i); !gsi_end_p (i); gsi_next (&i))\n     {\n       stmt = gsi_stmt (i);\n-      if (gimple_code (stmt) == GIMPLE_ASM)\n+      if (is_a<gasm*> (stmt))\n \treturn NULL_TREE;\n-      if (gimple_code (stmt) != GIMPLE_CALL)\n+      gcall *call = dyn_cast<gcall*>(stmt);\n+      if (!call)\n \tcontinue;\n \n-      callee = gimple_call_fndecl (stmt);\n+      /* We can remove the restore in front of noreturn\n+\t calls.  Since the restore will happen either\n+\t via an unwind/longjmp or not at all. */\n+      if (gimple_call_noreturn_p (call))\n+\tbreak;\n+\n+      /* Internal calls are ok, to bypass\n+\t check first since fndecl will be null. */\n+      if (gimple_call_internal_p (call))\n+\tcontinue;\n+\n+      callee = gimple_call_fndecl (call);\n+      /* Non-builtin calls are not ok. */\n       if (!callee\n-\t  || !fndecl_built_in_p (callee, BUILT_IN_NORMAL)\n-\t  /* All regular builtins are ok, just obviously not alloca.  */\n-\t  || ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (callee))\n-\t  /* Do not remove stack updates before strub leave.  */\n-\t  || fndecl_built_in_p (callee, BUILT_IN___STRUB_LEAVE))\n+\t  || !fndecl_built_in_p (callee))\n+\treturn NULL_TREE;\n+\n+      /* Do not remove stack updates before strub leave.  */\n+      if (fndecl_built_in_p (callee, BUILT_IN___STRUB_LEAVE)\n+\t  /* Alloca calls are not ok either. */\n+\t  || fndecl_builtin_alloc_p (callee))\n \treturn NULL_TREE;\n \n       if (fndecl_built_in_p (callee, BUILT_IN_STACK_RESTORE))\n \tgoto second_stack_restore;\n-    }\n \n-  if (!gsi_end_p (i))\n-    return NULL_TREE;\n+      /* If not a simple or inexpensive builtin, then it is not ok either. */\n+      if (!is_simple_builtin (callee)\n+\t  && !is_inexpensive_builtin (callee))\n+\treturn NULL_TREE;\n+    }\n \n   /* Allow one successor of the exit block, or zero successors.  */\n   switch (EDGE_COUNT (bb->succs))\ndiff --git a/gcc/tree.h b/gcc/tree.h\nindex b1d143416666..efbe867e891b 100644\n--- a/gcc/tree.h\n+++ b/gcc/tree.h\n@@ -7005,6 +7005,15 @@ fndecl_built_in_p (const_tree node, built_in_function name1, F... names)\n \t\t\t\t\tname1, names...));\n }\n \n+/* Returns true if the function decl NODE is an alloca. */\n+inline bool\n+fndecl_builtin_alloc_p (const_tree node)\n+{\n+  if (!fndecl_built_in_p (node, BUILT_IN_NORMAL))\n+    return false;\n+  return ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (node));\n+}\n+\n /* A struct for encapsulating location information about an operator\n    and the operation built from it.\n \n",
    "prefixes": [
        "v1",
        "03/10"
    ]
}