lkml.org 
[lkml]   [1996]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectIs 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.



\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.101 / U:1.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site