From: "Arnd Bergmann" <arnd@arndb.de>
To: "Linus Torvalds" <torvalds@linux-foundation.org>,
"Dave Airlie" <airlied@gmail.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>
Cc: "Tejun Heo" <tj@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: arm32 build warnings in workqueue.c
Date: Fri, 23 Jun 2023 21:21:44 +0200 [thread overview]
Message-ID: <37e7ef6d-3a92-42ab-a949-59c18bccc510@app.fastmail.com> (raw)
In-Reply-To: <CAHk-=wg9p+oJtzC0582vke8whcWPNSC9eq0Z6kdnSqWMEpah7g@mail.gmail.com>
On Fri, Jun 23, 2023, at 20:52, Linus Torvalds wrote:
> [ Adding clang people. See this for background:
>
>
> https://lore.kernel.org/all/CAHk-=wi=eDN4Ub0qSN27ztBAvHSXCyiY2stu3_XbTpYpQX4x7w@mail.gmail.com/
>
> where that patch not only cleans things up, but seems to make a
> difference to clang ]
>
> On Fri, 23 Jun 2023 at 11:24, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>> So I really think that code needs fixing, and the gcc warning was very valid.
>>
>> Maybe something like the attached. Does this fix the gcc warning?
>> Tejun, comments?
>
> Whee. Inexplicably, that patch also improves code generation with
> clang, with things like this:
>
> - movabsq $137438953440, %rcx # imm = 0x1FFFFFFFE0
> - andq %rax, %rcx
> - movabsq $68719476704, %rdx # imm = 0xFFFFFFFE0
> - cmpq %rdx, %rcx
> + shrq $5, %rax
> + cmpl $2147483647, %eax # imm = 0x7FFFFFFF
>
> in several places.
>
> Or, even more amusingly, this:
>
> - movabsq $68719476704, %rax # imm = 0xFFFFFFFE0
> - orq $1, %rax
> + movabsq $68719476705, %rax # imm = 0xFFFFFFFE1
>
> where the old code was some truly crazy stuff.
>
> I have *no* idea what drugs clang is on, but clearly clang does some
> really really bad things with large enums, and doesn't simplify things
> correctly.
I sent a fix for the warning earlier this year, and it's been
in linux-next for a while but hasn't made it to your tree yet,
see https://lore.kernel.org/all/20230117164041.1207412-1-arnd@kernel.org/
for the initial submission.
I went with the minimal change there, your more elaborate version
looks fine as well. There were a handful of bugs that came up with
the changed behavior, in other cases they caused the code to actually
misbehave rather than just causing a build warning.
After having looked at all the other instances, I still feel that
the new gcc behavior is the sanest way to handle this, but it was
not communicated well in the gcc-13 release notes, and I would have
preferred to see a warning for source code that had a change in code
generation because of this.
The short explanation of the change is that with the previous
gcc and clang behavior, the type of 'enum foo' would be determined
separately from the type of each individual constant, while the
new behavior in gcc-13 makes them all have the same type.
IIRC with a definition of
enum {
A = -1,
B = UINT_MAX,
} var;
you had 'typeof(A)' as an 'int', 'typeof(B)' as an 'unsigned int'
and 'typeof(var)' as a 'long long', now they are all 'long long'.
Arnd
next prev parent reply other threads:[~2023-06-23 19:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 3:57 Dave Airlie
2023-06-23 18:24 ` Linus Torvalds
2023-06-23 18:52 ` Linus Torvalds
2023-06-23 19:16 ` Nick Desaulniers
2023-06-23 19:33 ` Linus Torvalds
2023-06-23 19:21 ` Arnd Bergmann [this message]
2023-06-23 19:42 ` Linus Torvalds
2023-06-23 19:47 ` Tejun Heo
2023-06-23 22:15 ` Linus Torvalds
2023-06-23 22:22 ` Linus Torvalds
2023-06-24 1:23 ` Tejun Heo
2023-07-31 8:20 ` Petr Mladek
2023-07-31 18:40 ` Linus Torvalds
2023-07-31 19:14 ` Tejun Heo
2023-07-31 19:22 ` Linus Torvalds
2023-08-03 22:23 ` Tejun Heo
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=37e7ef6d-3a92-42ab-a949-59c18bccc510@app.fastmail.com \
--to=arnd@arndb.de \
--cc=airlied@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®