Hi Bernd,
Could you point me at the code generating these NOPs
It is in cfgrtl.c:fixup_reorder_chain() nb = split_edge (e); if (!INSN_P (BB_END (nb))) BB_END (nb) = emit_insn_after_noloc (gen_nop (), BB_END (nb), nb); INSN_LOCATION (BB_END (nb)) = e->goto_locus;
and maybe a testcase)?
Full testcase attached. Compile with -O0 -g.
Also, is this the only case you know of or are there others?
Sorry, I have not investigated this. The problem was reported to me by a GDB engineer, who was investigating gdb's failure to apply breakpoints to the correct locations under some circumstances (such as the code in the testcase). There may well be other tests that have similar properties, especially loops that are unrolled or goto statements that cross basic blocks.
Cheers Nick
volatile int v; volatile int w; void loop_test (void) { v = 0; while (v < 3) /* Loop 1 condition */ { v++; /* Loop 1 increment */ } v = -42; for (v = 0; v < 3; ) /* Loop 2 */ { v++; /* Loop 2 increment */ } v = -42; w = 42; for (v = 0; /* Loop 3 initialization */ v < 3; /* Loop 3 condition */ v++) /* Loop 3 increment */ { w = w - v; } v = 0; goto b; /* Loop 4 initial goto */ a: v++; b: if (v < 3) goto a; /* Loop 4 condition */ } int main (int argc, char **argv) { loop_test (); return 0; }