From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raghavendra D Prabhu Subject: Re: [Qemu-devel] [PATCH 2/3] Add fno-strict-overflow Date: Tue, 5 Jul 2011 21:06:15 +0530 Message-ID: <20110705153615.GB4463@Xye> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org To: Peter Maydell Return-path: Received: from mail-pz0-f46.google.com ([209.85.210.46]:46374 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416Ab1GEPgX (ORCPT ); Tue, 5 Jul 2011 11:36:23 -0400 Received: by pzk9 with SMTP id 9so2554403pzk.19 for ; Tue, 05 Jul 2011 08:36:22 -0700 (PDT) Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: * On Mon, Jul 04, 2011 at 11:38:30PM +0100, Peter Maydell wrote: >On 4 July 2011 23:00, Raghavendra D Prabhu wrote: >> This is to avoid gcc optimizating out the comparison in assert, >> due to assumption of signed overflow being undefined by default (-Werror=strict-overflow). > >>--- a/Makefile.hw >>+++ b/Makefile.hw >>@@ -9,7 +9,7 @@ include $(SRC_PATH)/rules.mak >> $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw) >> -QEMU_CFLAGS+=-I.. -I$(SRC_PATH)/fpu >> +QEMU_CFLAGS+=-I.. -I$(SRC_PATH)/fpu -fno-strict-overflow > >Can you give a more detailed description of the problem this is trying >to solve? I think it would be nicer if we could remove the assumptions >about signed overflows instead, if that's practical. Following line in pcie.c:pcie_add_capability:505 assert(offset < offset + size); is what the compiler was warning about. The compiler optimizes out that comparison without fno-strict-overflow flag. More information about it is here - http://www.airs.com/blog/archives/120 -- as already mentioned by Stefan. > >(Also, if we do want to add this compiler flag then it ought to be >done in configure I think, as we do for -fno-strict-aliasing.) > Globally adding that flag can limits the optimizations of gcc since in other places (loops) the undefined behavior can be advantageous, hence added only to Makefile.hw. >-- PMM > -------------------------- Raghavendra Prabhu GPG Id : 0xD72BE977 Fingerprint: B93F EBCB 8E05 7039 CD3C A4B8 A616 DCA1 D72B E977 www: wnohang.net