On 1 April 2014 13:09, Alex Bennée <alex.ben...@linaro.org> wrote: > > Richard Henderson <r...@twiddle.net> writes: > >> From: Peter Maydell <peter.mayd...@linaro.org> >> >> The code which patches x86 jump instructions assumes it can do an >> unaligned write of a uint32_t. This is actually safe on x86, but it's >> still undefined behaviour. We have infrastructure for doing efficient >> unaligned accesses which doesn't engage in undefined behaviour, so >> use it. >> >> This is technically fractionally less efficient, at least with gcc 4.6; >> instead of one instruction: >> 7b2: 89 3e mov %edi,(%rsi) >> we get an extra spurious store to the stack slot: >> 7b2: 89 7c 24 64 mov %edi,0x64(%rsp) >> 7b6: 89 3e mov %edi,(%rsi) > > Ehh? Is that gcc just being silly and putting parameters for an inline > on the stack frame?
It's gcc being dumb and not noticing that it has no requirement to store the inline parameter to the stack frame because it's optimised away the reference to the address of the parameter. Possibly more recent gcc versions do better. thanks -- PMM