On 2020-03-09 19:01, Segher Boessenkool wrote:
> Hi!
> 
> On Mon, Mar 09, 2020 at 01:54:53PM +0100, Richard Biener wrote:
>> I think memory operands are fine - my original concern was about
>> register outputs and SSA form that should reflect the correct def
>> on the EH vs non-EH edge.  From a "miscompile" perspective
>> doing nothig which means pretending the asm actually set the output
>> could lead us to false DCE of the old value:
>>
>>         int foo = 0
>>         try
>>           {
>>             asm volatile ("..." : "=r" (foo));
>>           }
>>         catch (...whatever...)
>>           {
>>             foo should be still zero, but SSA doesn't have the correct use 
>> here
>>           }
>>
>> that means the compiler really assumes the asm will populate the outputs
>> even when it throws.
> 
> How is memory any different here?  In both cases you do not know if it
> is the old value or some new value in foo, after it threw an exception.
> 
> 
> Segher

If foo were a memory operand, the compiler makes no assumptions about
its value.  When you reference it in the catch block it is always read
back from memory.  Only register operands are clobbered and retain
their previous value.  If you compile such an example with -O3, you'll
see that the initial "int foo = 0;" is eliminated from the normal code
path.  It is only set to 0 in the catch block.

Reply via email to