Messages in this thread | | | Date | Wed, 1 May 1996 19:46:43 -0700 | From | (Tom May) | Subject | Is clobber "memory" in include/asm-i386/system.h necessary? |
| |
In include/asm-i386/system.h there are numerous uses of __asm__ which clobber "memory". For reference, here they are:
#define mb() __asm__ __volatile__ ("" : : :"memory") #define sti() __asm__ __volatile__ ("sti": : :"memory") #define cli() __asm__ __volatile__ ("cli": : :"memory")
#define save_flags(x) \ __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
#define restore_flags(x) \ __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
#define iret() __asm__ __volatile__ ("iret": : :"memory")
(Uh, iret() is never even used . . .)
This clobber seems unnecessary since none of these instructions modify memory that gcc doesn't know about, and any memory that is modified by other means (hardware, interrupt handlers, etc.) is (should be?) accounted for in other ways such as by using volatile.
As an experiment, I removed the clobbers, built a kernel, and it ran fine (but if you try this at home, you will trigger the gcc common subexpression elimination bug, so until it is fixed for real, your kernel may or may not work).
So what's up with these clobbers? If they aren't necessary, they should be removed because they have a detrimental effect on code generation. If they are necessary, how about a comment explaining why?
Tom.
| |