Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752039Ab0KINAU (ORCPT ); Tue, 9 Nov 2010 08:00:20 -0500 Received: from cantor.suse.de ([195.135.220.2]:34993 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1749667Ab0KINAS (ORCPT ); Tue, 9 Nov 2010 08:00:18 -0500 Date: Tue, 9 Nov 2010 14:00:12 +0100 (CET) From: Michael Matz To: Dave Korn Cc: Andi Kleen , Richard Guenther , Andreas Schwab , Jim , Linux Kernel Mailing List , gcc@gcc.gnu.org Subject: Re: gcc 4.5.1 / as 2.20.51.0.11 miscompiling drivers/char/i8k.c ? In-Reply-To: <4CD843DC.10106@gmail.com> Message-ID: References: <4CD538CA.8010901@xs4all.nl> <87wroostw3.fsf@basil.nowhere.org> <87k4kospnd.fsf@basil.nowhere.org> <877hgorrj1.fsf@basil.nowhere.org> <4CD843DC.10106@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1100 Lines: 44 Hi, On Mon, 8 Nov 2010, Dave Korn wrote: > void foo (void) > { > int x, y, z; > x = 23; > asm ("do something" : "=r" (y) : "r" (x) ); > z = y + 1; > } The case in i8k.c really is different. It does use the value by influencing the return value and the callers use the returned value in conditionals and the like. It really, really _is_ used :-) and if GCC removes the asm (which up to now is only speculation) then it's a GCC bug. The code outlines like so: int i8k_smm (regs) { int rc; asm (... : "=r"(rc) ...); if (rc != 0 || ...) return -EINVAL; return 0; } ... struct regs regs = {.eax = ...} return i8k_smm(regs) ?: regs.eax; ... My speculation is, that the asm is not removed but rather that regs.eax isn't reloaded after the asm because the memory clobber doesn't clobber automatic variables. Ciao, Michael. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/