public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ndesaulniers at google dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-110728-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110728 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 run. 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) agreed (on IRC). For now in clang, we produce a diagnostic since the behavior seems surprising. If this gets changed in GCC, I'd be happy to modify clang to match that updated behavior.
next reply other threads:[~2023-07-18 21:23 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-18 21:23 ndesaulniers at google dot com [this message] 2023-07-18 21:29 ` [Bug c/110728] " pinskia at gcc dot gnu.org 2023-07-18 21:32 ` pinskia at gcc dot gnu.org 2023-07-18 21:33 ` pinskia at gcc dot gnu.org 2023-07-18 21:48 ` pinskia at gcc dot gnu.org 2023-07-18 23:22 ` rjmccall at gmail dot com 2023-07-19 7:01 ` rguenth at gcc dot gnu.org 2023-07-19 16:46 ` [Bug middle-end/110728] " ndesaulniers at google dot com 2023-07-19 17:16 ` rjmccall at gmail dot com 2023-08-03 14:38 ` matz at gcc dot gnu.org 2023-08-03 16:00 ` ndesaulniers at google dot com 2023-08-03 16:11 ` matz at gcc dot gnu.org 2023-08-03 17:07 ` rjmccall at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-110728-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).