hulsebos@uunet.uu.net (Rob Hulsebos) (09/08/88)
The well-known construction found in lots of Unix device-drivers: 1st instruction; SPL7(); 2nd instruction; 3rd instruction, etc. etc. SPL0(); last instruction; only works correctly if all code between the spl7-splx calls is translated into assembly-code which is executed after the spl7 and before the splx. However, the optimizer (when enabled) may 'decide' to move some assembly- instructions before the SPL7 or after the SPL0: translated 1st instruction; part of translated 2nd instruction; SPL7(); remainder of translated 2nd instruction; translated 3rd instruction, etc. etc SPL0(); This may create one (or two) time-windows for the duration of the assembly-instructions involved, which may cause the program(s) involved to fail sometimes for mysterious reasons, as the C-code seems to be OK. As optimizers usually know nothing of side-effects of the programs they compile (in our case, the CPU-state is altered), care must be taken when they are used if the compiler-writer(s) can not guarantee that their compiler does not alter the flow of programs. I have never seen any compiler doc which gives such guarantees. Is there anybody who has experience with this subject ? Or has found that his/hers compiler did the 'optimalizations' described above? ------------------------------------------------------------------------------ R.A. Hulsebos, Philips I&E Automation Modules ...!mcvax!philmds!hulsebos Building TQ-III-1 room 11 phone: +31-40-785723 Eindhoven, The Netherlands # cat /dev/disclaimer [Most optimizers that people actually use assume the worst when they see a procedure call and avoid moving any code across one. Even if they do, it'd seem to me that declaring the appropriate variables volatile would usually tell the compiler what it needs to know to avoid unsafe optimizations of this kind. Having said all that, most Unix kernels either seem to be compiled with secret optimizer switches or else with no optimization of device drivers. -John] -- Send compilers articles to ima!compilers or, in a pinch, to Levine@YALE.EDU Plausible paths are { decvax | harvard | yale | bbn}!ima Please send responses to the originator of the message -- I cannot forward mail accidentally sent back to compilers. Meta-mail to ima!compilers-request