<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Jun 19, 2018 at 5:46 PM Vedant Kumar <<a href="mailto:vsk@apple.com">vsk@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div>Someone (Reid?) mentioned that we could try sinking constants to their point of first use as an alternative, and (IIUC) create new nodes with distinct DebugLocs for each use of a constant. I don't recall the details of that alternative clearly. Based on my (likely incorrect) understanding of it, dropping locations from constants outright might be simpler.<br></div></div></blockquote><div><br></div><div>Our use case was in fastisel, so things are different. I don't think my solution will help you.</div><div><br></div><div>In our case, users were complaining about code like this:</div><div>volatile int do_something;</div><div>void f() {</div><div>  ++do_something;</div><div>  foo(1, 2, 3);</div><div>  ++do_something;<br>}</div><div><br></div><div>We'd generate locations like:</div><div>  .loc line 1</div><div>  incl do_something(%rip)</div><div>  movl $1, %ecx</div><div>

<span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">  movl $2, %edx</span><br></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">  movl $3, %r8d</span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">  .loc line 2 # line 2 starts here, instead of 3 instructions earlier</span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">  callq foo</span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">  .loc line 3</span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">  incl do_something(%rip)</span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div>Our users really wanted the line table entry for line 2 to include the constant materialization code for some VS debugger feature.</div><div><br></div><div>I think if you remove locations from ConstantSDNodes, you might want to add a late pass that propagates source locations backwards onto location-less instructions. This would also avoid some special cases when a basic block starts with an instruction that lacks location information. See CodeViewDebug::beginInstruction and DwarfDebug::beginInstruction for what we do today.</div></div></div>