Hi, Jan, The patch at http://gcc.gnu.org/ml/gcc-patches/2001-07/msg00399.html added code to remove line number notes from the end of basic blocks after say turning a jump at the end of a basic block into a fallthrough edge.
This unfortunately causes line number info from becoming incorrect for test programs such as: int x; int f() { x = 0; while(1); } We get line number notes for code only up to "x = 0;". The line number note for the empty infinite loop is dropped when the back-edge is turned into a fallthrough edge (?!?). Even if I arrange for the edge from a block to itself to never be regarded as a fallthrough edge (it doesn't seem to make sense to me), loop2 still splits the back-edge such that the loop has separate header and latch blocks, and at the time of the split, we use the same try_to_redirect_by_replacing_jump() function and thus lose debug info. Although I'll be the first to admit that this particular case is not that useful, it has surprised people on the Frysk project (see Sourceware bug 3259, for example). I'm not sufficiently familiar with the code nor do I see a rationale as to why keeping the notes might change the generated code, even though I can imagine it might have to do with a loop becoming empty or some such. I've considered arranging for such notes to be moved to the destination of the edge, but in this case the note would still remain alone in the basic block, and therefore at its end, causing whatever failure mode it is that got you to add that chunk of code. I've also considered adding some nop after the source line number instead of removing, but then I realized that it wouldn't address the potential problem of generating different code for -g and -g0. I don't see any such note-removal code in tidy_fallthru_edge(), from which you claim to have got inspiration, so I wonder if you still remember what kind of failure modes you envisioned, and whether it would make sense to come up with some other means to avoid dropping such line number notes entirely, such as storing line-number-at-the-end information in basic blocks, or something similar for loops, and get such notes re-inserted at some convenient time, such as when re-inserting jumps for fallthru edges that couldn't be satisfied without a jump, or some such. Any other ideas? Thanks in advance, -- Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/ Secretary for FSF Latin America http://www.fsfla.org/ Red Hat Compiler Engineer [EMAIL PROTECTED], gcc.gnu.org} Free Software Evangelist [EMAIL PROTECTED], gnu.org}