<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">I'd like to improve the situation with setting breakpoints on lines with assignments or inlinable calls. This email outlines problem areas, possible solutions, and why I think emitting extra nops at -O0 might be the best solution.</div><div class=""><br class=""></div><div class=""># Problem 1: Assignments</div><div class=""><br class=""></div><div class="">Counter to user expectation, a breakpoint on a line containing an assignment is reached when the assignment happens, not before the r.h.s is evaluated.</div><div class=""><br class=""></div><div class="">## Example: Can't step into bar()</div><div class=""><br class=""></div><div class=""> 1| foo = // Set a breakpoint here. Note that it's not possible to step into bar().</div><div class=""> 2| bar();</div><div class=""><br class=""></div><div class="">One solution is to set the location of the assignment to the location of the r.h.s (line 2). The problem with this approach is that it becomes impossible to set a breakpoint on line 1.</div><div class=""><br class=""></div><div class="">Another solution is to emit a nop (on line 1) prior to emitting the r.h.s, and to emit an artificial location on the assignment's store instruction. This makes it possible to step to line 1 before line 2, and prevents users from stepping back to line 1 after line 2.</div><div class=""><br class=""></div><div class=""># Problem 2: Inlinable calls</div><div class=""><br class=""></div><div class="">Instructions from an inlined function don't have debug locations within the caller. This can make it impossible to set a breakpoint on a line that contains a call to an inlined function.</div><div class=""><br class=""></div><div class="">## Example: Can't set a breakpoint on a call</div><div class=""><br class=""></div><div class="">It's easier to see the bug via Godbolt: <a href="https://godbolt.org/z/scwF20" class="">https://godbolt.org/z/scwF20</a>. Note that it's not possible to set a breakpoint on line 9 (on "inline_me"). At the IR-level, we do emit an unconditional branch with a location that's on line 9, but we have to drop that branch during ISel.</div><div class=""><br class=""></div><div class="">The only solution to this problem (afaik) is to insert a nop before inlinable calls. In this example the nop would be on line 9.</div><div class=""><br class=""></div><div class="">One alternative I've heard is to make the first inlined instruction look like it's located within the caller, but that actually introduces a bug. You wouldn't be able to set a breakpoint on the relevant location in the inlined callee.</div><div class=""><br class=""></div><div class=""># Proposal</div><div class=""><br class=""></div><div class="">As outlined above, I think the best way to address issues with setting breakpoints on assignments and calls is to insert nops with suitable locations at -O0. These nops would lower to a target-specific nop at -O0, and lower to nothing at -O1 or greater (like @llvm.donothing).</div><div class=""><br class=""></div><div class="">The tentative plan is to introduce an intrinsic (say, @llvm.dbg.nop) to accomplish this.</div><div class=""><br class=""></div><div class="">I don't anticipate there being a substantial compile-time impact, but haven't actually measured this yet. I'd like to get some feedback before going forward. Let me know what you think!</div><div class=""><br class=""></div><div class="">thanks,</div><div class="">vedant</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>