From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0B0653858C62; Tue, 18 Jul 2023 21:23:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B0653858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689715432; bh=gyQu072C+ZWE87LeeJfCBM0ThsY8BuVi4vVDI+pcrZM=; h=From:To:Subject:Date:From; b=xPBncSZGkh8NSVLVVdvs0GgURYVpAiNPmQKhAeBvMiCeyjSW77dhq2cmqK3qlRcN3 0T6247AUfgOUbr0UGJZZUMybLHGp6Mwa14zXPoocpG6cOsQgndueRBUNbMm8A/SLne SVlbcT/ARvYksGB627OUzUspe/cP4RtIqCdyH7WU= From: "ndesaulniers at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110728] New: should __attribute__((cleanup())) callback get invoked for indirect edges of asm goto Date: Tue, 18 Jul 2023 21:23:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ndesaulniers at google dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110728 Bug ID: 110728 Summary: should __attribute__((cleanup())) callback get invoked for indirect edges of asm goto Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ndesaulniers at google dot com Target Milestone: --- Consider the following test case: ```c void test4cleanup(int*); // No errors expected. void test4(void) { l0:; int x __attribute__((cleanup(test4cleanup))); asm goto("# %l0"::::l0); } ``` gcc trunk today generates effectively the following control flow: ``` test4: .LFB0: subq $24, %rsp .L2: #APP # .L2 #NO_APP leaq 12(%rsp), %rdi call test4cleanup addq $24, %rsp ret ``` so if the inline asm blob jumps to `l0`, then the cleanup function is not r= un. That seemed surprising, at least when we discussed it on this thread. https://reviews.llvm.org/D155342#4511887 A fellow Linux kernel dev (who introduced the usage of __attribute__((cleanup())) (and asm goto, coincidentally) to the kernel) ag= reed (on IRC). For now in clang, we produce a diagnostic since the behavior seems surprisi= ng.=20 If this gets changed in GCC, I'd be happy to modify clang to match that upd= ated behavior.=