qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] util/cacheinfo: Fix warning generated by clang


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] util/cacheinfo: Fix warning generated by clang
Date: Sat, 1 Jul 2017 23:44:48 +0100

On 1 July 2017 at 23:35, Richard Henderson <address@hidden> wrote:
> On 07/01/2017 03:30 PM, Peter Maydell wrote:
>>
>> On 1 July 2017 at 23:20, Richard Henderson <address@hidden> wrote:
>>> That is an absolutely stupid warning.  There's long precedent for the
>>> compiler choosing the prefix for you based on the type of the argument.
>>
>>
>> Isn't that the problem? The type of the argument says "32 bits"
>> but the instruction here really wants 64 bits (MRS takes Xn, not Wn).
>
>
> The warning is telling me to use %w to force Wn.  So if the assembler really
> doesn't like Wn, the warning is a bit more than confusing.

Wouldn't be the first time a compiler has produced a confusing warning :-)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63359 includes some
previous gcc-vs-clang-dev discussion on the topic of the warning.
It looks like the clang dev rationale is that having %0 always
generate a 64-bit register access even when passed a 32-bit value
is confusing (eg people expect "str %0, [addr]" : ... : "r" (var_32bits)"
to do a 32 bit store, not a 64 bit store), so better to warn and
nudge the code author into being explicit about the size they wanted.

> Perhaps it ought to be telling me to use %x to force Xn in spite of the
> type?

You always get Xn anyway, regardless of the type.

For us, I think the right thing to do is make 'ctr' be a uint64_t,
because we're reading a 64 bit sysreg and silently truncating it
as a side effect of the asm constraints is a bit obscure.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]