https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78685
Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.org See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=54200 --- Comment #9 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Tom de Vries from comment #8) > Created attachment 44333 [details] > 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. Please submit the patch to the gcc-patches mailing list for review! Thanks.