This is the mail archive of the
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
On Sun, Oct 28, 2007 at 10:17:38PM -0700, David Miller wrote:
> From: Darryl Miles <email@example.com>
> Date: Mon, 29 Oct 2007 04:53:49 +0000
> > What are the issues with "speculative loads" ?
> The conditional might be protecting whether the pointer is valid and
> can be dereferenced at all.
> int *counter;
> void foo(int counter_is_valid)
> if (counter_is_valid)
GCC will never do a speculative access in this case. That's because
"counter_is_valid" might really mean "counter_is_non_null".
It seems that the original issue can only occur if there is a direct
write to a global, not a write through a pointer.