From patchwork Mon Aug 26 18:34:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1976973 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Zj/+Oz+V; 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 4WszqM68Mfz1yXd for ; Tue, 27 Aug 2024 04:34:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A65D385DDC9 for ; Mon, 26 Aug 2024 18:34:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 3F6693858D20 for ; Mon, 26 Aug 2024 18:34:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F6693858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3F6693858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724697254; cv=none; b=NoG4UMLdkYnW0mBhmMQhj1lxnxDZbjPHQGG1k5ehuPFeGkdmDrLP/BuMjl6a8wyioO/8VEwFFQF66HevwhpTCBLSGa8Y3IIhYDano80O/RXwbyqeIpWldDu99fWpWzSIlmFqIJOrbb22S4XgtVKN9jR/ecF43XPihHakYE1BwDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724697254; c=relaxed/simple; bh=GVDQuCEXBMtoKl6DxBNBOxo/XheSmTIgzWg8fsn31s4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=HV3ReRLCy315upBCBZKI1lWBK9zIROv0wn5crWSkowvvXv1PJPoXJ81mF+tJJjvmoHET5mkGq4ve7vNU7wswJ3Ozv0pzEDD0DsG2etGWnLQtuwg4rCGql7ZKAK2wm92uqYIRFMmgk6hIFaQHKSbhfOX383Q1cABORqHNl9B9Auo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5334e41c30bso5061414e87.0 for ; Mon, 26 Aug 2024 11:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724697250; x=1725302050; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=iMmPAXsxcCXd5MQGlNXTKanUL6yJ0AnpbjyqR08ZlE0=; b=Zj/+Oz+VGQzU4RnAiYajOBmImPoGOFLBHWzwFlrIMuo6aNarzQCgNORmGDnTzFCI4N Dy4QTq+kE8jjh3FFST5i7ni+i0h4pgIXeJrS6fKZbwFDUb4eE96TD1FaQFM75NtFqKqc qzfZnn38ZILNnkw8XwHs31O1DCJDACoc2VKVO7m1nfbApYog8gKHzO28SPFhQ5u+pdP5 9hQ6NY1pB9VYUtjCAkanfIbJH3p0Ahcd60Qh9+Zw5AHbLWD0QWYnJf+SSvW0ukCLqlB6 pey+DEyH8CYQ2mRMIQNVXwMSczk+Dju99ulEs/SbnrgQC53Mf3sxa9pbOcBPYbUQqk1i nXqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724697250; x=1725302050; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=iMmPAXsxcCXd5MQGlNXTKanUL6yJ0AnpbjyqR08ZlE0=; b=i1YzAlMt/l0CdhDfHfYRW0DirCM7O/zkoZgYq/oX4+k4shxH6WNQL+Jd8CEQEBGvg0 4+1ebj+9jO8be1JTrdPB6AAO98lE5HQwOJho70cu9IYNlNHgZvtzwW0ckUCFmyUEpuqP oEkRA3R5pIhnak6X9xfgvQy71z5MGRFLCvUIwitdIRP3YEW01A617a5uC2i28U8N9bWT BZ6rX94imCZmHRoWx5JxHoCpBOGbqZor1TD9BRqjrJyLXnzj4LCQOtgajHtkpP+dCAn7 b8KwcMpr8YaJbBN7I74Q/nI/qclWPoqbtZZaGvNlPxInOfdBv38jvkEKaiMs640Bml+A v47Q== X-Gm-Message-State: AOJu0YzFhYZneouhtnI5bIGNZU8Ra5iiLSK2TDW10BOWj8/nt8ugs7f6 2wNTRwRZw40W0cGujqsGSsuKf49RhUM4496sdbh5w4zDvRW5z2N+QyoOeg== X-Google-Smtp-Source: AGHT+IHjukk+R/J9tQLtIsXNlougQ/SIJ42qVi7WwaRkhQYLIuAjbBEjW+hjVSzkRul1D/5TSmiFtA== X-Received: by 2002:a05:6512:31c8:b0:530:bbe7:4db3 with SMTP id 2adb3069b0e04-534387be4bamr6850459e87.39.1724697249541; Mon, 26 Aug 2024 11:34:09 -0700 (PDT) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c0bb481fd9sm46909a12.88.2024.08.26.11.34.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 26 Aug 2024 11:34:09 -0700 (PDT) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com Subject: [PATCH v2] c++, coroutines: The frame pointer is used in the helpers [PR116482]. Date: Mon, 26 Aug 2024 19:34:08 +0100 Message-Id: <20240826183408.88577-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , Reply-To: iain@sandoe.co.uk Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi Jason, >>As the PR notes, we now have two bogus warnings that the single frame >>pointer parameter is unused in each of the helper functions. >>This started when we began to use start_preparsed_function/finish_function >>to wrap the helper function code generation. I am puzzled a little about >>why the use is not evident without marking - or perhaps it is always needed >>to mark use in synthetic code? >>For the destroy function, in particular, the use of the parameter is simple >>- an indirect ref and then it is passed to the call to the actor. >>The fix here is somewhat trivial - to mark the param as used as soon as it >>is. >You also wouldn't get the warning if the param were marked DECL_ARTIFICIAL, which seems desirable anyway? Yes, done as attached, OK for trunk assuming that reg-testing passes? thanks Iain --- 8< --- We have a bogus warning about the coroutine state frame pointers being apparently unused in the resume and destroy functions. Fixed by making the parameters DECL_ARTIFICIAL. PR c++/116482 gcc/cp/ChangeLog: * coroutines.cc (coro_build_actor_or_destroy_function): Make the parameter decls DECL_ARTIFICIAL. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr116482.C: New test. Signed-off-by: Iain Sandoe --- gcc/cp/coroutines.cc | 1 + gcc/testsuite/g++.dg/coroutines/pr116482.C | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/coroutines/pr116482.C diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index c3e08221cc9..8f899513691 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -4058,6 +4058,7 @@ coro_build_actor_or_destroy_function (tree orig, tree fn_type, tree id = get_identifier ("frame_ptr"); tree fp = build_lang_decl (PARM_DECL, id, coro_frame_ptr); + DECL_ARTIFICIAL (fp) = true; DECL_CONTEXT (fp) = fn; DECL_ARG_TYPE (fp) = type_passed_as (coro_frame_ptr); DECL_ARGUMENTS (fn) = fp; diff --git a/gcc/testsuite/g++.dg/coroutines/pr116482.C b/gcc/testsuite/g++.dg/coroutines/pr116482.C new file mode 100644 index 00000000000..702d1e235bb --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr116482.C @@ -0,0 +1,30 @@ +// Override default options. +// { dg-options "-std=c++20 -fno-exceptions -Wall -Wextra" } + +#include + +struct SuspendNever { + bool await_ready(); + void await_suspend(std::coroutine_handle<>); + void await_resume(); +}; + +struct Coroutine; + +struct PromiseType { + Coroutine get_return_object(); + SuspendNever initial_suspend(); + SuspendNever final_suspend(); +#if __cpp_exceptions + void unhandled_exception() { /*std::terminate();*/ }; +#endif + void return_void(); +}; + +struct Coroutine { + using promise_type = PromiseType; +}; + +Coroutine __async_test_input_basic() { + co_return; +}