This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Optimization of conditional access to globals: thread-unsafe?


On 22 October 2007 18:34, Andrew Haley wrote:

>  > Again, we are not discussing some particular code sample, and how it
>  > might be fixed, but the problem in general.  Should GCC do
>  > thread-unsafe optimizations, or not?
> 
> We do understand what you're saying, and simply repeating the same
> thing doesn't help.

  Well, just to answer the question at face value, "Yes, of course it should,
because 99.9% of the time the fact of their thread-safety or otherwise is
irrelevant".

  The interesting question of course is how we can get the compiler to
recognize that 0.1% when thread-safety is not just relevant but vital.  That
may still end up requiring some kind of annotation (like 'volatile'), but
defining a clear memory model should allow the compiler to make inferences and
deductions for itself that save the programmer a lot of the work of specifying
what data needs to be thread-safe and when and where.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]