From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E9EA5385840B; Tue, 5 Oct 2021 09:24:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9EA5385840B From: "iains at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/102528] Unused out-of-line functions emitted for trivial coroutines Date: Tue, 05 Oct 2021 09:24:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: iains at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Oct 2021 09:24:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102528 --- Comment #6 from Iain Sandoe --- #include struct simple { struct promise_type { void return_void() {} std::suspend_never initial_suspend() { return {}; } std::suspend_never final_suspend() noexcept { return {}; } void unhandled_exception() { /*throw;*/ } simple get_return_object() { return {}; } }; std::true_type await_ready() {return {}; } void await_suspend(std::coroutine_handle<>) {} void await_resume() {} }; inline simple test1() { co_return; } inline simple test2() { co_await test1(); co_return; } void test() { test1(); } is enough to reproduce at -O2 -std=3Dc++20 -O2 -S -fno-reorder-blocks-and-partition -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables=20 ^^ makes the output a little less complicated. .text .p2align 4 __Z5test1PZ5test1vE15_Z5test1v.Frame.actor: jmp __ZdlPv L3: ud2 .p2align 4 __Z5test1PZ5test1vE15_Z5test1v.Frame.destroy: movzwl 32(%rdi), %eax ret .p2align 4,,10 .p2align 3 L19: jmp __ZdlPv L16: ud2 .p2align 4 .globl __Z4testv __Z4testv: ret L21: nop .ident "GCC: (GNU) 12.0.0 20211003 (experimental)" NOTES: 1/ All traces of test2 are correctly elided (so that it seems we need to ha= ve had a use at some earlier point). 2/ at the start of DSE2 we still hold references to the actor and destroyer functions (the ramp has been inlined, and the ramp function elided). 3/ DSE2 elides the coroutine frame and the references to the two functions,= but it seems that is too late in the pipeline for them to be removed?=