https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90197
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P2 Status|UNCONFIRMED |NEW Version|unknown |8.3.1 Keywords| |wrong-debug Last reconfirmed| |2019-04-23 CC| |aoliva at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Ever confirmed|0 |1 Target Milestone|--- |8.4 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. The issue is that the line number program only contains line number 6 and the consumer (gdb) doesn't handle a jump in a stmt sequence as "ending" a line, thus 'next' advances to after the loop. We expand from <bb 2> [local count: 118111600]: [t.c:5:3] # DEBUG BEGIN_STMT [t.c:5:8] # DEBUG BEGIN_STMT [t.c:5:12] # DEBUG i => 0 # DEBUG i => 0 # DEBUG base => base_7(D) [t.c:5:3] if (count_9(D) > 0) goto <bb 3>; [89.00%] else goto <bb 5>; [11.00%] <bb 3> [local count: 105119324]: ivtmp.10_4 = (unsigned long) dst_10(D); _14 = (unsigned int) count_9(D); _15 = _14 * 15; _21 = base_7(D) + _15; <bb 4> [local count: 955630224]: # base_17 = PHI <base_7(D)(3), [t.c:5:40] base_13(4)> # ivtmp.10_6 = PHI <ivtmp.10_4(3), ivtmp.10_5(4)> # DEBUG i => NULL # DEBUG base => base_17 [t.c:6:5] # DEBUG BEGIN_STMT _16 = (void *) ivtmp.10_6; [t.c:6:12] MEM[base: _16, offset: 0B] = base_17; [t.c:5:30] # DEBUG i => D#1 [t.c:5:40] base_13 = base_17 + 15; [t.c:5:40] # DEBUG base => base_13 # DEBUG i => D#1 # DEBUG base => base_13 ivtmp.10_5 = ivtmp.10_6 + 4; [t.c:5:3] if (base_13 != _21) goto <bb 4>; [89.00%] else goto <bb 5>; [11.00%] <bb 5> [local count: 118111601]: [t.c:7:1] return; notice how the only stmt marker inside the loop body is for t.c:6. gimplification shows test (unsigned int * dst, unsigned int base, int count) [t.c:4:1] { [t.c:5:3] # DEBUG BEGIN_STMT [t.c:5:3] { int i; [t.c:5:8] # DEBUG BEGIN_STMT [t.c:5:12] i = 0; [t.c:5:3] goto <D.1912>; <D.1911>: [t.c:6:5] # DEBUG BEGIN_STMT [t.c:6:8] _1 = (long unsigned int) i; [t.c:6:8] _2 = _1 * 4; [t.c:6:8] _3 = dst + _2; [t.c:6:12] [t.c:6:8] *_3 = base; [t.c:5:30] i = i + 1; [t.c:5:40] base = base + 15; <D.1912>: [t.c:5:3] if (i < count) goto <D.1911>; else goto <D.1913>; <D.1913>: so the debug begin_stmt for the loop is attached before the IV initialization. Not sure if that has consequences. The testcase behaves as expected with -gno-statement-frontiers Alex?