From: Peter Zijlstra <peterz@infradead.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
Uros Bizjak <ubizjak@gmail.com>,
GCC Development <gcc@gcc.gnu.org>, X86 ML <x86@kernel.org>,
Jakub Jelinek <jakub@redhat.com>,
Andy Lutomirski <luto@amacapital.net>,
linux-toolchains@vger.kernel.org,
Christian Borntraeger <borntraeger@de.ibm.com>,
Will Deacon <will@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: typeof and operands in named address spaces
Date: Tue, 10 Nov 2020 21:11:08 +0100 [thread overview]
Message-ID: <20201110201108.GQ2611@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAKwvOdkEqnn_+pQspKdDs=7nVO_4_dUNWuZ2uUcTEs1eh_duoA@mail.gmail.com>
On Tue, Nov 10, 2020 at 10:42:58AM -0800, Nick Desaulniers wrote:
> When I think of qualifiers, I think of const and volatile. I'm not
> sure why the first post I'm cc'ed on talks about "segment" qualifiers.
> Maybe it's in reference to a variable attribute that the kernel
> defines? Looking at Clang's Qualifier class, I see const, volatile,
> restrict (ah, right), some Objective-C stuff, and address space
> (TR18037 is referenced, I haven't looked up what that is) though maybe
> "segment" pseudo qualifiers the kernel defines expand to address space
> variable attributes?
Right, x86 Named Address Space:
https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Named-Address-Spaces.html#Named-Address-Spaces
Also, Google found me this:
https://reviews.llvm.org/D64676
The basic problem seems to be they act exactly like qualifiers in that
typeof() preserves them, so if you have:
( and now I realize the parent isn't Cc'd to LKML, find here:
https://gcc.gnu.org/pipermail/gcc/2020-November/234119.html )
> --cut here--
> #define foo(_var) \
> ({ \
> typeof(_var) tmp__; \
> asm ("mov %1, %0" : "=r"(tmp__) : "m"(_var)); \
> tmp__; \
> })
>
> __seg_fs int x;
>
> int test (void)
> {
> int y;
>
> y = foo (x);
> return y;
> }
> --cut here--
> when compiled with -O2 for x86 target, the compiler reports:
>
> pcpu.c: In function ‘test’:
> pcpu.c:14:3: error: ‘__seg_fs’ specified for auto variable ‘tmp__’
> Maybe stripping all qualifiers is fine since you can add them back in
> if necessary?
So far that seems sufficient. Although the Devil's advocate in me is
trying to construct a case where we need to preserve const but strip
volatile and that's then means we need to detect if the original has
const or not, because unconditionally adding it will be wrong.
next prev parent reply other threads:[~2020-11-10 20:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAFULd4aOca3k-AZ+ocMBqDRpH_kNisBQwfK0F4Jf7znsPxsrBw@mail.gmail.com>
2020-11-09 12:47 ` typeof and operands in named address spaces Peter Zijlstra
2020-11-09 19:38 ` Segher Boessenkool
2020-11-09 19:50 ` Nick Desaulniers
2020-11-10 7:57 ` Peter Zijlstra
2020-11-10 18:42 ` Nick Desaulniers
2020-11-10 20:11 ` Peter Zijlstra [this message]
2020-11-12 0:40 ` Segher Boessenkool
2025-05-29 6:29 ` Uros Bizjak
2020-11-12 0:47 ` Segher Boessenkool
2020-11-10 7:52 ` Peter Zijlstra
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=20201110201108.GQ2611@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=borntraeger@de.ibm.com \
--cc=gcc@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=linux-toolchains@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mpe@ellerman.id.au \
--cc=ndesaulniers@google.com \
--cc=segher@kernel.crashing.org \
--cc=torvalds@linux-foundation.org \
--cc=ubizjak@gmail.com \
--cc=will@kernel.org \
--cc=x86@kernel.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