From: Paolo Bonzini <pbonzini@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>, Roman Kagan <rkagan@virtuozzo.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"x86@kernel.org" <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
"Liran Alon" <liran.alon@oracle.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"clang-built-linux@googlegroups.com"
<clang-built-linux@googlegroups.com>
Subject: Re: [PATCH 1/2] x86: kvm: avoid -Wsometimes-uninitized warning
Date: Fri, 12 Jul 2019 15:14:08 +0200 [thread overview]
Message-ID: <b7da5e91-f23c-9f5d-2c61-07e7fc7af9b1@redhat.com> (raw)
In-Reply-To: <CAK8P3a3+QSRQkitXiDFLYvyYvOS+Q4sXb=xA_XPeX2O2zQ5kgw@mail.gmail.com>
On 12/07/19 15:02, Arnd Bergmann wrote:
> I think what happens here is that clang does not treat the return
> code of track the return code of is_64_bit_mode() as a constant
> expression, and therefore assumes that the if() condition
> may or may not be true, for the purpose of determining whether
> the variable is used without an inialization. This would hold even
> if it later eliminates the code leading up to the if() in an optimization
> stage. IS_ENABLED(CONFIG_X86_64) however is a constant
> expression, so with the patch, it understands this.
>
> In contrast, gcc seems to perform all the inlining first, and
> then see if some variable is used uninitialized in the final code.
> This gives additional information to the compiler, but makes the
> outcome less predictable since it depends on optimization flags
> and architecture specific behavior.
>
> Both approaches have their own sets of false positive and false
> negative warnings.
True, on the other hand constant returns are not really rocket science. :)
Maybe change is_long_mode to a macro if !CONFIG_X86_64? That would be
better if clang likes it.
Paolo
next prev parent reply other threads:[~2019-07-12 13:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-12 9:12 [PATCH 1/2] x86: kvm: avoid -Wsometimes-uninitized warning Arnd Bergmann
2019-07-12 9:12 ` [PATCH 2/2] x86: kvm: avoid constant-conversion warning Arnd Bergmann
2019-07-12 9:30 ` Sedat Dilek
2019-07-12 17:47 ` Paolo Bonzini
2019-07-12 12:02 ` [PATCH 1/2] x86: kvm: avoid -Wsometimes-uninitized warning Roman Kagan
2019-07-12 13:02 ` Arnd Bergmann
2019-07-12 13:14 ` Paolo Bonzini [this message]
2019-07-12 13:32 ` Arnd Bergmann
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=b7da5e91-f23c-9f5d-2c61-07e7fc7af9b1@redhat.com \
--to=pbonzini@redhat.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=clang-built-linux@googlegroups.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liran.alon@oracle.com \
--cc=mingo@redhat.com \
--cc=rkagan@virtuozzo.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).