Here's a simple testcase. Compile with -O2 and look at the
-fdump-tree-all-lineno dumps:
int foo (int);
int bar (int a)
{
int ndir = 0;
int b;
b = foo (a);
while (b--)
ndir = foo (ndir);
}
Early on, the ndir = 0 assignment is marked for line 4. Then the 0 gets
propogated into a phi without a line number, which ends up associated with the
while loop (in a larger testcase, with the end of the instruction before the
loop instead of the start of the loop - not sure why a difference). The
original assignment is DCE'd.
Then an exactly identical initialization is rematerialized (not surprising),
and the closest line number we could find was the line number of the statement
before the phi.
Obviously stepping over this in GDB looks unnecessarily strange.
Perhaps some PHI arguments could have line number information to be used on
edges when coming out of SSA?
FYI, original testcase comes from GDB's selftest.exp; we get a very surprising
line number associated with the first real instruction.
--
Summary: tree-ssa loses line numbers for initializations
Product: gcc
Version: 4.0.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: drow at gcc dot gnu dot org
GCC host triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26475