From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gc0nc-0005sg-Nx for qemu-devel@nongnu.org; Mon, 23 Oct 2006 10:29:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gc0na-0005sE-E3 for qemu-devel@nongnu.org; Mon, 23 Oct 2006 10:29:08 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gc0na-0005sB-7C for qemu-devel@nongnu.org; Mon, 23 Oct 2006 10:29:06 -0400 Received: from [64.78.21.128] (helo=mis011-1.exch011.intermedia.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gc0na-00010B-4a for qemu-devel@nongnu.org; Mon, 23 Oct 2006 10:29:06 -0400 Message-ID: <453CD1A3.2060206@qumranet.com> Date: Mon, 23 Oct 2006 16:28:51 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] qemu vs gcc4 References: <45391B22.1050608@palmsource.com> <200610231320.08914.paul@codesourcery.com> <453CCAAF.9080904@qumranet.com> <200610231510.47140.paul@codesourcery.com> In-Reply-To: <200610231510.47140.paul@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: qemu-devel@nongnu.org Paul Brook wrote: >>> That's exactly what my gcc4 hacks do. >>> >>> It gets complicated because a x86 uses variable length insn encodings so >>> you don't know where insn boundaries are, and a jmp instruction is larger >>> than a ret instruction so it's not always possible to do a straight >>> replacement. >>> >> how about >> >> void some_generated_instruction(u32 a1, u32 s2) >> { >> // code >> asm volatile ( "" ); >> } >> >> >> that will force the code to fall through to the null asm code, avoiding >> premature returns. >> >> if the code uses 'return' explicitly, turn it to a goto just before the >> 'asm volatile'. >> > > We already do that. It doesn't stop gcc putting the return in the middle of > the function. > > Paul > void f1(); void f2(); void f(int *z, int x, int y) { if (x) { *z = x; f1(); } else { *z = y; f2(); } asm volatile (""); } works, with gcc -O2 -fno-reorder-blocks. removing either the asm or the -f flag doesn't. No idea if it's consistent across architectures. (the function calls are there to prevent cmov optimizations) -- error compiling committee.c: too many arguments to function