qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] qemu vs gcc4


From: Avi Kivity
Subject: Re: [Qemu-devel] qemu vs gcc4
Date: Mon, 23 Oct 2006 16:28:51 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060913)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]