From patchwork Mon Aug 26 14:33:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1976859 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=j+dazKiL; 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 4WstV02GkMz1yZd for ; Tue, 27 Aug 2024 00:34:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 847F5385C6C0 for ; Mon, 26 Aug 2024 14:34:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id C44913858C60 for ; Mon, 26 Aug 2024 14:33:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C44913858C60 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 C44913858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::532 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724682836; cv=none; b=PnSeMQDsRMTtmHrTLQVQ/m2xT5SOXPU9ZD611Bgcm3jnq++4AcWaaRwJRsPbvI2oAurNdangNakcTi2JiPcwSEbqQHD3emch7wJ0M58iaPXzPG8AQ+sj6eCLhlTV8WiSsoMAPMIGigQHP1JeP/JlvzD2AyJJc0U5YLMcqU62X4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724682836; c=relaxed/simple; bh=CR1JqtZCQ2ItBI/fQ/ooEP6IiiqkmVQs/ocXWMKvn9U=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=NBbZPRFa1kDrA4PFVu+P0l3db3VF5RIZcRPbqDU0MxEAsNTxgA1EArScYQxpZAV0J/P9M1Gg5W/kU71BuPPMAlAEEbbidMiGbqG12sxbfE5H8CLRetqi1iHz1pJY6CUPpyitIc2GwEJxJQEPNo7wvMJPUIGn0TzJkEFq32nBJao= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5bed83488b6so5006898a12.2 for ; Mon, 26 Aug 2024 07:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724682832; x=1725287632; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=upzV6qjHJvxxjvxZwht754MsfNAXT+lUcrsHlBbJA1w=; b=j+dazKiLhWwa6ue/XvQrhs8n6gUhPZtCVkdYLjhnEj+7JjbiYTXHtfnDVsf3zq2Aza MIYkyQ+STMCqaapoYnm33phS9CeNe+yC9F07ysbzntCvcbXfmfuHZ9uD5QDF/oMq7P2a jfZEP/Yfs0E9KXepZduXh5EiQdSiKDnudwpClAQRRbqsDS3F2Uxzrql4K7v1KTROcMWH LMo2mq+bdrMTSrG+LHEQBhBU9TRS24ratuenJita4IKDNkP32oS5TaUP35KAH4cvrkFw YRTkTjIUcp1d8p2KHVkPasv05Pl1KqaELhqAcbVgUhY7AB8VBx6wUlG3moC+Igo9COZo 5OSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724682832; x=1725287632; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=upzV6qjHJvxxjvxZwht754MsfNAXT+lUcrsHlBbJA1w=; b=PtvcdvAEeXW2uYmBcNItlInF1YuL8NPk9k4ntgQC7LAo4XL+84qpkXFpB1Bm+T+Rt3 03pFZrsLB0dqvf9Jc/LmLJQVeIXXjejovcAEHB2QrEaHzHpwipXu5Tq/PY5R96d1Razp 5O/Rbtk7Xkt504bxOPNL9tG+AK1kMb6KuPXh1veUue64jZqhxRd3CF2b/SHpXCQVJlNp EnMyynAxn6gimFIQ4b7SvXSqd+NHZvvAu3ZiLFI+sZHA2+LVZ1xmfJ+ni0cdO5wsmnfk x8BcOLKI2WAm0FRps9JQRD+045hTQ9JwKWKyebwNLj/ccbxQfQV6p2lKEcMCapxbxx27 9iYQ== X-Gm-Message-State: AOJu0YyV2VhWnCkCSSmfU/aAXF/yTQUmv73II7GF8kDHmaZWzREBr+5m 7oGXZH8ENZ0aUi2kI7DyEB2og6BuUipoHbRuHgkFem8hs05ywCSGzOuiYQ== X-Google-Smtp-Source: AGHT+IE9u/okFg8yw8/szc4dMuuRCoYDneBefFfuHaz8CwuqS1ebG7xbGKASjlYkecaWYj85Axh77g== X-Received: by 2002:a05:6402:2809:b0:5be:da7c:6176 with SMTP id 4fb4d7f45d1cf-5c08916373amr7158476a12.10.1724682831674; Mon, 26 Aug 2024 07:33:51 -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-5c0515a9691sm5612153a12.91.2024.08.26.07.33.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 26 Aug 2024 07:33:51 -0700 (PDT) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com Subject: [PATCH] c++, coroutines: The frame pointer is used in the helpers [PR116482]. Date: Mon, 26 Aug 2024 15:33:50 +0100 Message-Id: <20240826143350.12646-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) 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 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. Tested on x86_64-darwin, reg-strapping on x86_64-darwin/linux and powerpc64 linux, OK for trunk assuming that the reg-straps are successful? thanks Iain --- 8< --- We have a bogus warning about the coroutine state frame pointers being apparently unused in the resume and destroy functions. Fixed thus. PR c++/116482 gcc/cp/ChangeLog: * coroutines.cc (build_actor_fn): Mark the frame pointer as used. (build_destroy_fn): Likewise. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr116482.C: New test. Signed-off-by: Iain Sandoe --- gcc/cp/coroutines.cc | 3 ++- gcc/testsuite/g++.dg/coroutines/pr116482.C | 30 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/coroutines/pr116482.C diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index c3e08221cc9..3dee844ad4e 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -2255,6 +2255,7 @@ build_actor_fn (location_t loc, tree coro_frame_type, tree actor, tree fnbody, tree actor_begin_label = create_named_label_with_ctx (loc, "actor.begin", actor); tree actor_frame = build1_loc (loc, INDIRECT_REF, coro_frame_type, actor_fp); + mark_used (actor_fp); /* Declare the continuation handle. */ add_decl_expr (continuation); @@ -2526,7 +2527,7 @@ build_destroy_fn (location_t loc, tree coro_frame_type, tree destroy, tree destr_frame = cp_build_indirect_ref (loc, destr_fp, RO_UNARY_STAR, tf_warning_or_error); - + mark_used (destr_fp); tree rat_field = lookup_member (coro_frame_type, coro_resume_index_id, 1, 0, tf_warning_or_error); tree rat 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; +}