From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH for-1.7] target-i386: Fix build by providing stub kvm_arch_get_supported_cpuid() Date: Tue, 12 Nov 2013 14:12:56 +0100 Message-ID: <52822958.8060508@redhat.com> References: <1384204922-8250-1-git-send-email-peter.maydell@linaro.org> <5281580D.7060305@redhat.com> <52816422.8060002@redhat.com> <52821A62.2050001@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Anthony Liguori , QEMU Developers , Gleb Natapov , kvm-devel , Patch Tracking , Andreas Tobler , Anthony Liguori To: Peter Maydell Return-path: Received: from mail-ee0-f42.google.com ([74.125.83.42]:54023 "EHLO mail-ee0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751586Ab3KLNNB (ORCPT ); Tue, 12 Nov 2013 08:13:01 -0500 Received: by mail-ee0-f42.google.com with SMTP id e52so1813023eek.15 for ; Tue, 12 Nov 2013 05:13:00 -0800 (PST) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 12/11/2013 13:16, Peter Maydell ha scritto: > On 12 November 2013 12:09, Paolo Bonzini wrote: >> Il 12/11/2013 12:07, Peter Maydell ha scritto: >>> For the compiler to eliminate this we are relying on: >>> * dead-code elimination of code following a 'break' >>> statement in a case block >>> * constant-folding of "something || 1" to 1 >>> * the compiler having done enough reasoning to be >>> sure that env is not NULL >> >> Yes, it's not trivial, but there are simpler ways to do it. >> >> For example there is no need to make sure that env is non-NULL, only to >> see that "something || 1" is never zero and thus "if (x) y;" is just >> "(void)x; y;". This seems easier to me than DCE after "break" which >> clang is able to do. > > You seem to be trying to reason about what the compiler > might choose to do or how it might be implemented internally. I'm not reasoning about that in general (I was in the context of the message you quoted). I'm saying it's *reasonable* to expect that "-O0" means "reduce compile time, make debugging produce expected results, and try (not too hard) to not break what works at -O2". It's a simple QoI argument based on the fact that people *will* switch back and forth between -O2 and -O0. Of course not everything can be kept to work, since the compilers do pretty surprising optimizations (not counting the ones that break your code of course...). But I think a limited amount of dead code elimination *should* be expected because most people are now preferring "if" to "#ifdef" for compiling out code. If -O0 does not do that, let's move debug builds to -O1. Paolo