https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78685
Tom de Vries <vries at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vries at gcc dot gnu.org --- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> --- Created attachment 44333 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44333&action=edit proof of concept patch I ran into the same problem with guality test-case pr54200.c, which fails for Og. The relevant part of the test-case is: ... int __attribute__((noinline,noclone)) foo (int z, int x, int b) { if (x == 1) { bar (); return z; } else { int a = (x + z) + b; return a; /* { dg-final { gdb-test 20 "z" "3" } } */ } } ... The problem is that the '(x + z) + b' calculation has a temporary register which gets allocated the register that holds 'z', so when we get to the gdb-test line, z is no longer available. Using this patch I managed to print the correct value of z at the gdb-test line. The patch uses clobbers in gimple to mark the out-of-scope point, purely because that's similar to what was already done for local array variables, and I thought that was the fastest path to getting a proof of concept working. It's more accurate to model this as some sort of use in gimple, and doing so may prevent gimple optimizations which wreck debug info, but perhaps that's not necessary, I suppose that depends on which optimizations are enabled in Og. Anyway, at expand we emit a use for the clobber which seems to do the trick.