low level optimization

Joe English jeenglis at alcor.usc.edu
Fri Apr 19 10:52:16 AEST 1991


henry at zoo.toronto.edu (Henry Spencer) writes:
>  There is nothing non-conforming
>about a compiler that does certain optimizations only in favorable situations,
>e.g. when it is compiling all source modules involved.  It has to be able to
>cope with separately-translated files, but that does not require that it
>translate each and every file independently.  It is perfectly entitled to
>notice that it is being asked to process more than one file, and to do its
>optimizations on all of them together rather than each one separately.

What happens, then, if you compile foo.c and bar.c together, 
and later change and recompile bar.c alone?  foo.o (or its equivalent)
might have been optimized to use information that's no longer valid.
Does the Standard say that it's OK for an implementation to 
require recompilation of foo.c at this point?

(My *guess* is that, yes, an implementation is allowed to say "you 
must recompile foo.c" or even generate an incorrect program in
a case like this; as far as I know the C Standard has very little
to say about the programming environment as far as revision control
is concerned.  Ada has rules to handle this sort of situation,
but C doesn't seem to.  Then again, I don't own, and have never even read,
the ANSI C Standard so this is all conjecture.)

>The
>only constraint is that certain aspects of the external behavior of the
>resulting program must not vary with such optimizations.

If that's the case, and given that 'make' and similar utilities
don't keep track of the compilation history, it would be extremely
difficult to do any kind of cross-file interprocedural optimizations
in a conforming C implementation for a conventional (e.g.,
Unixlike) environment.  I have to agree (as painful as it is to do
so) with Jim Giles on this point.



--Joe English

  jeenglis at alcor.usc.edu 
  Apologies in advance to Doug Gwyn et al. for stating an opinion about the 
  Standard without having read it.



More information about the Comp.lang.c mailing list