<div dir="ltr">While there's no doubt bugs - there's also some intentional places where debug locations are not preserved.<br><br>Specifically when moving instructions across basic blocks, debug locations are intentionally removed (again, there might be some bugs where they are /not/ removed and should be - there are always more bugs) to ensure profile accuracy (eg: if you hoist an instruction above a conditional, then a sample-based profiler sees that that line was executed it might incorrectly conclude that the condition was met when it wasn't) & "jumpy" debugging (where your debugger goes back and forwards a lot all over the code - though, arguably, that's accurate).<br><br>Maybe one day we'll have a bit where we can say "this instruction was hoisted or merged" (and maybe even "this instruction comes from these 3 locations") but for now removing the location is the best option.<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 20, 2019 at 8:07 PM Jan Vesely via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I've recently run into a problem of missing !dbg metadata after the<br>
code has been optimized (even opt -O1).<br>
The original code was generated using llvmlite python package and I've<br>
verified that all instructions have their !dbg metadata present.<br>
After optimizing the module (even opt -O1) I see that some<br>
instructions (~25%) don't have any dbg metadata.<br>
These are mostly getelementptr and bitcasts, but there's also few<br>
fsubs.<br>
One example:<br>
  %.510.i.i = bitcast [2 x double]* %.4 to i8*<br>
  tail call void @llvm.memset.p0i8.i64(i8* nonnull align 8 %.510.i.i, i8 0, i64 16, i1 false) #5, !dbg !2822, !alias.scope !2825, !noalias !2830<br>
<br>
There are no memset calls in the original code. the introduced bitcast is lacking the location metadata.<br>
The behaviour persists across llvm-6/7/git.<br>
Is it just a series of bugs that I'm hitting?<br>
<br>
thanks,<br>
Jan<br>
-- <br>
Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu" target="_blank">jan.vesely@rutgers.edu</a>>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>