On Mon, Mar 09, 2020 at 07:42:20PM +0100, J.W. Jagersma wrote: > On 2020-03-09 19:01, Segher Boessenkool wrote: > > On Mon, Mar 09, 2020 at 01:54:53PM +0100, Richard Biener wrote: > >> 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. > > 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.
My question is *why* that is, and/or what in our code makes that so :-) Segher