NewExit and epilog PreHeader should has the same debug loc as the original loop
body, instead of original loop exit.
The test is now defining BODY_LOC three times in the EPILOG run. Once should be enough. (The unmodified test incorrectly defines it twice, and you've added a third.)
Am I right that this will set more DebugLoc for epilog case than for prolog? If so, why?
If not - reuse it in the line 654 and give wider name (like NewExitTerminator).
Please add a comment on what test is checking.
NewExit gets its DebugLoc from LatchExit. This DebugLoc is not part of the original loop, it's after the original loop (say loc A).
The conditional branch deciding if epilog will be added to NewExit, which should be part of the original loop in lexical sense.
If a later pass search for debuginfo in RPOT order, it will first find loc A at the conditional branch rather than the merge point of unrolled and epilog loop.
On the other hand, PrologPreHeader gets its debug info from original PreHeader.
Thanks for detailed explanation. Now it is clear for me. I'd add this as a comment: