Boost logo

Boost :

From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2006-11-14 08:47:52


On 11/14/06, Peter Bindels <dascandy_at_[hidden]> wrote:
> On 14/11/06, Giovanni Piero Deretta <gpderetta_at_[hidden]> wrote:
> > While it is likely that most compilers will do whole program
> > optimizations in the future and be able to reorder across compilation
> > units, I think that it is extremely unlikely that compilers will ever
> > reorder instructions in pure assembly modules. First of all because to
> > do whole program optimization they need special data produced during
> > compilation (that assembler modules lack), and also because they would
> > render assembler programming useless. IMHO of course.
>
> If you properly wrap the assembly code in asm volatile segments the
> compiler should not touch them for anything. If you do not, it could
> change it for anything. The linker can change around anything it
> wants, in theory, and that's the one performing the whole-program
> optimizations. If they move stuff around it could get duplicated, but
> there should be an option telling the linker not to try that (possibly
> with regard to a specific function), so that current practices
> (specifically those relating to atomicity and protected instructions)
> aren't made useless. I'm not sure whether you can specify that in the
> code, although I expect some construction will be created to allow
> that specifically for supporting header-based libraries.

By external assembler modules, i meant .S files. You can't hardly wrap
them using volatile asm statements as there is no concept of volatile
nor asm statement there. I do not claim to know how smart linkers do
WPO, but I think that they need more informations than plain machine
code (note that when it is the time for the linker to do its job,
object files have already been generated). This extra info is
generated during compilation and probably includes the internal
compiler representation of that module. As long as you feed your
assembler modules to a plain assembler you should be safe.

gpd


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk