Re: [PATCH] x86: do not allow to optimize flag_is_changeable_p()

Previous thread: [GIT] MFD pull request by Samuel Ortiz on Tuesday, September 30, 2008 - 1:19 am. (1 message)

Next thread: Re: What is in ubifs-2.6.git by Amit Kumar Sharma on Tuesday, September 30, 2008 - 1:55 am. (2 messages)
From: krzysztof.h1
Date: Tuesday, September 30, 2008 - 1:27 am

Why you call it undocumented. This is information you can find with "info gcc" in the Extendend Asm section:

If your assembler instructions access memory in an unpredictable
fashion, add `memory' to the list of clobbered registers.  This will
cause GCC to not keep memory values cached in registers across the
assembler instruction and not optimize stores or loads to that memory.
You will also want to add the `volatile' keyword if the memory affected
is not listed in the inputs or outputs of the `asm', as the `memory'
clobber does not count as a side-effect of the `asm'.  If you know how
large the accessed memory is, you can add it as input or output but if


See above about adding the memory constrain.

Kind regards,
Krzysztof

----------------------------------------------------------------------
Tanie i proste polaczenia telefoniczne!
Sprawdz >>  http://link.interia.pl/f1f23 


--

From: Jeremy Fitzhardinge
Date: Tuesday, September 30, 2008 - 8:23 am

Yes, you're right.  The pertinent part of the manual is:

    The `volatile' keyword indicates that the instruction has important
    side-effects.  GCC will not delete a volatile `asm' if it is reachable.
    (The instruction can still be deleted if GCC can prove that
    control-flow will never reach the location of the instruction.)  Note
    that even a volatile `asm' instruction can be moved relative to other
    code, including across jump instructions.
      

I normally do my "asm volatile" rant when people try to use it to
enforce ordering, but in this case we just want gcc to not elide the
second use.

So, yes, I think your patch is fine as-is, but it would be worth adding
a comment on the asm (its not necessarily obvious that the
cpuid-capability of a cpu can change).

    J
--

Previous thread: [GIT] MFD pull request by Samuel Ortiz on Tuesday, September 30, 2008 - 1:19 am. (1 message)

Next thread: Re: What is in ubifs-2.6.git by Amit Kumar Sharma on Tuesday, September 30, 2008 - 1:55 am. (2 messages)