https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93385
--- Comment #32 from Jakub Jelinek <jakub at gcc dot gnu.org> --- For debug stmts when DCE isn't involved, we already seem to do the right thing, consider -O2 -g: __attribute__((noinline)) static void foo (int a) { int b = 2 * a; int c = 3 * a; a = a + 4; asm volatile ("" : : : "memory"); } void bar (void) { foo (1); foo (7); foo (16); } The clone materializes into: <bb 3> [local count: 1073741824]: # DEBUG D#5 s=> a # DEBUG a => D#5 <bb 2> [local count: 1073741824]: # DEBUG D#1 s=> a # DEBUG BEGIN_STMT # DEBUG b => D#1 * 2 # DEBUG BEGIN_STMT # DEBUG c => D#1 * 3 # DEBUG BEGIN_STMT # DEBUG a => D#1 + 4 # DEBUG BEGIN_STMT __asm__ __volatile__("" : : : "memory"); return; I thought only the first two debug stmts would appear, would need to look up where the a_1(D) is replaced with the D#1 copy and where the corresponding debug source bind is created. Bet we want similar testcase also for when this DCE is used, and no, debug stmts shouldn't be marked as something that should be thrown away, but instead might be reset if we can't do anything better with them.