Optimization of conditional access to globals: thread-unsafe?
Darryl Miles
darryl-mailinglists@netbauds.net
Mon Oct 29 05:08:00 GMT 2007
David Miller wrote:
> The compiler simply cannot speculatively load or store to variables
> with global visibility.
s/with global visibility/with visibility outside the scope of the
functional unit the compiler is able to see at compile time/
Which basically means the compiler is king for doing these tricks with
CPU registers, areas of the stack and inlined functional units in which
it can be 100% sure about it access to this data.
What are the issues with "speculative loads" ? Is there such a page as
a write only page used by any system GCC targets ? For general usage
the x86 concept of read-only or read-write fits well, which means that
speculative load's are usually a safe optimization.
But I'd be all for a way to allow/disallow each optimization
independently (this give the developer more choice in the matter). With
"speculative loads" enabled by default and "speculative stores" disabled
by default for any multi-threaded code.
As per my other posting have the ability to
__attribute__((disallow_speculative_load,disallow_speculative_store)) or
to __attribute__((allow_speculative_load,allow_speculative_store)) to
pin the issue. With -fdisallow-speculative-load
-fallow-speculative-load etc... for the defaults for the entire file
being compiled.
Darryl
More information about the Gcc
mailing list