Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!rice!uupsi!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c Subject: Re: low level optimization Message-ID: <25751:Apr1908:31:0191@kramden.acf.nyu.edu> Date: 19 Apr 91 08:31:01 GMT References: <21660@lanl.gov> <1991Apr17.190243.24691@watmath.waterloo.edu> <21703@lanl.gov> Organization: IR Lines: 58 In article <21703@lanl.gov> jlg@cochiti.lanl.gov (Jim Giles) writes: > The only information available to the compiler about > procedures that are separately compiled are the names of routines > that the current procedure calls and the number and type of their > arguments and results (if any). This is incorrect. The standard makes no special allowance for ``the names of routines that the current procedure calls and [etc.].'' Each C source file has a *meaning* dependent solely upon the information in that file and its inclusions. Nevertheless, optimizations do not change that meaning and may depend upon other information. > For a language which requires > separate compilation, _NO_OTHER_INFORMATION_ is known about an > external procedure. This is incorrect. Again, the meaning of a source file depends solely upon that source file, prototypes in #includes, etc., but lots of other information may be known to the compiler. > The reason is that _all_ other characteristics > of an external procedure are allowed to _change_ without the need to > recompile any uses of that procedure. This is incorrect. Compilation consists of translation (like foo.c becoming foo.o) and loading (like foo.o and bar.o becoming a.out). The *translation* of one file is independent of other files, but the *loading* depends on all the files together. > The bottom line is that separate compilation implies that procedures > may be used together for which the _source_ of the separate routines > has never even existed in the same programming environment and only > the object code has been distributed. This is incorrect. The ANSI C standard requires separate compilation. It does not define ``the same programming environment'' or ``distributed.'' (As I pointed out in my previous article, a conforming compiler may produce object code that includes the entire source code, so Jim's statement is obviously wrong.) > Further, even the object code > of each may not be available at the time each of the other procedures > is compiled. This is incorrect. Compilation includes loading, and loading requires all object code for the program. It's true that the other objects may not be available at *translation* time, but optimizations aren't restricted to translation time. > Hence, under separate compilation there may be no internal > information about other procedures used when a given procedure is compiled > because such information may not exist, may be speculative, or may > subsequently change without notice. This is incorrect. The correct information may be carried along with each object file. ---Dan