[PATCH] Make basic asm implicitly clobber memory

Jeff Law law@redhat.com
Mon May 23 15:58:00 GMT 2016


On 05/22/2016 04:33 AM, Andrew Haley wrote:
> On 05/20/2016 07:50 AM, David Wohlferd wrote:
>
>> At a minimum, suddenly forcing an unexpected/unneeded memory clobber
>> can adversely impact the optimization of surrounding code.  This can
>> be particularly annoying if the reason for the asm was to improve
>> performance.  And adding a memory clobber does add a dependency of
>> sorts, which might cause the location of the asm to shift in an
>> unfortunate way.  And there's always the long-shot possibility that
>> some weird quirk or (very) badly-written code will cause the asm to
>> flat out fail when used with a memory clobber.  And if this change
>> does produce any of these problems, I feel pity for whoever has to
>> track it down.
>
> OTOH, if a memory clobber does change code gen it probably changes it
> in a way which better fits user expectations, and perhaps it fixes a
> bug.  That's a win, and it is far, far more important than any other
> consideration.
My thoughts precisely.

>
>> I realize deprecation/removal is drastic.  Especially since basic
>> asm (mostly) works as is.  But fixing memory clobbers while leaving
>> the rest broken feels like half a solution, meaning that some day
>> we're going to have to fiddle with this again.
>
> Yes, we will undoubtedly have to fiddle with basic asm again.  We
> should plan for deprecation.
Right.  There are some fundamental problems with basic asms and I think 
we want to deprecate them in the long term.  In the immediate/medium 
term, I think addressing the memory dependency issue is the right thing 
to do.

While it may make some code somewhere less optimized, it brings the 
basic asm semantics closer to what most programmers expect and prevents 
them from suddenly breaking as the optimizers continue to improve.  If 
someone wants better optimized code, they ought to be using extended 
asms anyway.

Jeff



More information about the Gcc-patches mailing list