Newsgroups: | comp.arch,comp.compilers |
From: | ddg@cci.com (D. Dale Gulledge) |
Keywords: | C, optimize, design |
Organization: | Northern Telecom Inc., NAS |
References: | 94-10-108 94-10-157 |
Date: | Mon, 31 Oct 1994 22:43:55 GMT |
robertb@HING.LCS.MIT.EDU (Robert Bedichek) writes:
4. Applications and utilities that make system calls like 'stat()'
where the operating system's compilation used a different layout
for the stat buffer.
This is actually a special case of the real driving reason behind the
restriction. C, and therefor C++, allows separate compilation of multiple
compilation units. The compiler has no knowledge of the internals of other
compilation units or any optimizations that may have been done on them, unless
those optimizations would have always been performed. If it is necessary to
pad so that individual fields have a certain alignment, the compiler may be
able to guarantee that. However, completely rearranging the actual layout for
optimization is non-trivial at best and may not be possible in the general
case.
This is not limited to C/C++, but can be extended to any compiler that allows
linking separately compiled modules in such a way that the compiler cannot or
even might not use information generated by the compilation of one module in
the compilation of another module. So long as the optimization may be done at
compile time and the modules are linked later, the problem exists. Making the
optimization optional only exacerbates the problem. If the optimizer is
enabled when one module is compiled and disabled when another that interfaces
it is compiled, the interface will fail.
Simply put, you cannot optimize an interface, unless you can guarantee that
both sides can accept either the optimized or non-optimize versions, or that
both sides will be optimized the same way.
- Dale
--
ddg@cci.com, D. Dale Gulledge, Software Engineer, Northern Telecom,
Directory & Operator Services, 97 Humboldt St., Rochester, NY 14609
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.