From: Noah Goldstein <goldstein.w.n@gmail.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] nptl: x86_64: Use stackinfo.h definition for CURRENT_STACK_FRAME
Date: Mon, 29 Aug 2022 12:24:38 -0700 [thread overview]
Message-ID: <CAFUsyfJmnMUDAtAvZtqWpj-iYKes9K39Y2t6u2WmGaQ9QzSa7A@mail.gmail.com> (raw)
In-Reply-To: <20220829190012.946402-1-adhemerval.zanella@linaro.org>
On Mon, Aug 29, 2022 at 12:00 PM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> It avoids the possible warning of uninitialized 'frame' variable when
> building with clang:
>
> ../sysdeps/nptl/jmp-unwind.c:27:42: error: variable 'frame' is
> uninitialized when used here [-Werror,-Wuninitialized]
> __pthread_cleanup_upto (env->__jmpbuf, CURRENT_STACK_FRAME);
>
> It increases the generated code by one instruction:
>
> --- master
> +++ patch
> @@ -25068,11 +25068,11 @@ Disassembly of section .text:
> 3db1b: 00 00
> 3db1d: 48 89 44 24 08 mov %rax,0x8(%rsp)
> 3db22: 31 c0 xor %eax,%eax
> - 3db24: 48 8b 44 24 08 mov 0x8(%rsp),%rax
> - 3db29: 64 48 2b 04 25 28 00 sub %fs:0x28,%rax
> - 3db30: 00 00
> - 3db32: 75 0c jne 3db40
> <_longjmp_unwind+0x30>
> - 3db34: 48 89 e6 mov %rsp,%rsi
> + 3db24: 48 89 e6 mov %rsp,%rsi
> + 3db27: 48 8b 44 24 08 mov 0x8(%rsp),%rax
> + 3db2c: 64 48 2b 04 25 28 00 sub %fs:0x28,%rax
> + 3db33: 00 00
> + 3db35: 75 09 jne 3db40
> <_longjmp_unwind+0x30>
> 3db37: 48 83 c4 18 add $0x18,%rsp
> 3db3b: e9 60 31 05 00 jmp 90ca0
> <__GI___pthread_cleanup_upto>
> 3db40: e8 4b ec 0e 00 call 12c790 <__stack_chk_fail>
>
> Checked on x86_64-linux-gnu.
> ---
> sysdeps/x86/nptl/pthreaddef.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/x86/nptl/pthreaddef.h b/sysdeps/x86/nptl/pthreaddef.h
> index 63fdbcb27c..3ff95efee6 100644
> --- a/sysdeps/x86/nptl/pthreaddef.h
> +++ b/sysdeps/x86/nptl/pthreaddef.h
> @@ -42,7 +42,7 @@
> #ifdef __x86_64__
> /* The frame pointer is not usable. */
> # define CURRENT_STACK_FRAME \
> - ({ register char *frame __asm__("rsp"); frame; })
> + ({ void *p__; asm volatile ("mov %%" RSP_REG ", %0" : "=r" (p__)); p__; })
Is the mov instruction needed at all?
Would:
```
({ register void * p__ __asm__("rsp"); asm volatile("" : "=r"(p__)); p__; });
```
work?
> #else
> # define CURRENT_STACK_FRAME __builtin_frame_address (0)
> #endif
> --
> 2.34.1
>
next prev parent reply other threads:[~2022-08-29 19:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 19:00 Adhemerval Zanella
2022-08-29 19:24 ` Noah Goldstein [this message]
2022-08-29 20:20 ` Adhemerval Zanella Netto
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=CAFUsyfJmnMUDAtAvZtqWpj-iYKes9K39Y2t6u2WmGaQ9QzSa7A@mail.gmail.com \
--to=goldstein.w.n@gmail.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.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: link
Be 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).