<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=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 30, 2020, at 4:13 AM, Jeremy Morse via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi Sourabh,<br class=""><br class="">On Mon, Mar 30, 2020 at 8:09 AM Sourabh Singh Tomar via llvm-dev<br class=""><<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""><blockquote type="cite" class="">Under what circumstances should a frontend choose to emit(at -O0(No optimization)) llvm.dbg.value for a local variable.<br class=""><br class="">I saw some debuginfo code in flang(older one), sort of it choose to emit *llvm.dbg.value* for *every load operation* happening on a *local variable*. And as noted below in IR snippet it has already emitted *llvm.dbg.declare* for the local variable.<br class=""></blockquote><br class="">[...]<br class=""><br class=""><blockquote type="cite" class=""> call void @llvm.dbg.declare(metadata i32* %foo, metadata !9, metadata !DIExpression()), !dbg !11<br class="">%0 = load i32, i32* %foo, align 4, !dbg !13<br class=""> call void @llvm.dbg.value(metadata i32 %0, metadata !9, metadata !DIExpression()), !dbg !11<br class=""></blockquote><br class="">My understanding is that this isn't correct: dbg.declare specifies the<br class="">memory address of a variable for the whole lifetime of the function,<br class="">whereas dbg.value (and dbg.addr) specify the value/address until the<br class="">next debug intrinsic. Mixing these two kinds of intrinsics creates<br class="">ambiguity over where the variable location is at different positions<br class="">in the code.<br class=""></div></div></blockquote><div><br class=""></div>Correct, you should not be mixing dbg.declare and other instrinsics for the same variable.</div><div><br class=""></div><div>See also <a href="https://llvm.org/docs/SourceLevelDebugging.html#llvm-dbg-declare" class="">https://llvm.org/docs/SourceLevelDebugging.html#llvm-dbg-declare</a></div><div><br class=""></div><div>-- adrian</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class=""><br class="">If dbg.value intrinsics are to be used and the variable can be located<br class="">in memory too, then the producer needs to specify where the location<br class="">switches from a value to an address (and vice versa) with dbg.value /<br class="">dbg.addr. Awkwardly,I think there are some issues with dbg.addr at -O0<br class="">that Brian ran into here [0, 1], which might need addressing.<br class=""><br class="">[0] <a href="http://lists.llvm.org/pipermail/llvm-dev/2020-February/139500.html" class="">http://lists.llvm.org/pipermail/llvm-dev/2020-February/139500.html</a><br class="">[1] <a href="http://lists.llvm.org/pipermail/llvm-dev/2020-February/139511.html" class="">http://lists.llvm.org/pipermail/llvm-dev/2020-February/139511.html</a><br class=""><br class="">--<br class="">Thanks,<br class="">Jeremy<br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></div></blockquote></div><br class=""></body></html>