<div dir="ltr"><div style="min-height:100%"><div class="gmail-nH" style="width:1422.22px"><div class="gmail-nH" style=""><div class="gmail-nH gmail-bkL"><div class="gmail-no" style="display:flex;width:1422.22px"><div class="gmail-nH gmail-bkK gmail-nn" style="min-height:1px;overflow:hidden;width:1180.22px"><div class="gmail-nH"><div class="gmail-nH"><div class="gmail-nH gmail-ar4 gmail-z"><div class="gmail-aeI"><div class="gmail-AO" style=""><div id="gmail-:3" class="gmail-Tm gmail-aeJ" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;overflow-y:scroll;padding-right:0px;height:576px"><div id="gmail-:1" class="gmail-aeF" style="padding:0px;vertical-align:bottom;min-height:386.157px"><div class="gmail-nH"><div class="gmail-nH"><div class="gmail-nH gmail-g"><table class="gmail-Bs gmail-nH gmail-iY gmail-bAt" cellpadding="0" style="border-spacing:0px;padding:0px;border-collapse:collapse;width:1094.68px;display:block"><tbody><tr><td class="gmail-Bu gmail-bAn" style="vertical-align:top;padding:0px;display:block;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><div class="gmail-nH gmail-if" style="margin:0px 16px 0px 0px;padding:0px"><div class="gmail-nH gmail-aHU" style=""><div class="gmail-nH gmail-hx" style="background-color:transparent;min-width:502px;padding:0px"><div class="gmail-nH"><div class="gmail-h7 gmail-bg gmail-ie gmail-nH gmail-oy8Mbf gmail-j23lnd gmail-Aqhktf" tabindex="-1" style="clear:both;padding-bottom:0px;max-width:100000px;outline:none"><div class="gmail-Bk" style="margin-bottom:0px;border-width:0px;border-top-style:solid;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:rgb(239,239,239);border-right-color:initial;border-left-color:initial;border-bottom-color:initial;border-radius:0px;width:1078.08px"><div class="gmail-G3 gmail-G2 gmail-afm" style="padding-top:0px;background-color:transparent;border-width:1px 0px 0px;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-right-color:initial;border-bottom-color:rgba(100,121,143,0.12);border-left-color:initial;border-top-style:solid;border-top-color:rgba(100,121,143,0.12);border-radius:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"><div id="gmail-:1tvd"><div class="gmail-adn gmail-ads" style="border-left:none;padding:0px;display:flex"><div class="gmail-gs" style="margin:0px;padding:0px 0px 20px;width:1006.1px"><div class="gmail-"><div id="gmail-:1tvg" class="gmail-ii gmail-gt gmail-adO" style="font-size:0.875rem;direction:ltr;margin:8px 0px 0px;padding:0px"><div id="gmail-:1tvf" class="gmail-a3s gmail-aXjCH" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif"><div style="overflow-wrap: break-word;"><div><span class="gmail-im" style="color:rgb(80,0,80)"><blockquote type="cite"><div><div>> My understanding is that this isn't correct: dbg.declare specifies the<br>memory address of a variable for the whole lifetime of the function,<br>whereas dbg.value (and dbg.addr) specify the value/address until the<br>next debug intrinsic. Mixing these two kinds of intrinsics creates<br>ambiguity over where the variable location is at different positions<br>in the code.<br></div></div></blockquote><div><br></div></span>          > <span style="background-color:transparent">Correct, you should not be mixing dbg.declare and other </span>instrinsics<span style="background-color:transparent"> for the same variable</span></div><div><br></div><div>How about patching up llvm for the same, currently the IR showed above is valid and can be processed by llvm for target code generation.</div><div>Should we move ahead invalidate this behavior as in "declare and value intrinsic can't be specified for same local variable". ?</div><div><br></div><div>So that no FE should generate this sort of thing in first place. clang doesn't do that so this change should not affect clang.</div><div><br></div><div>Thanks,</div><div>Sourabh.</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></td></tr></tbody></table></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 31, 2020 at 2:24 AM Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@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="overflow-wrap: break-word;"><br><div><br><blockquote type="cite"><div>On Mar 30, 2020, at 4:13 AM, Jeremy Morse via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div>Hi Sourabh,<br><br>On Mon, Mar 30, 2020 at 8:09 AM Sourabh Singh Tomar via llvm-dev<br><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br><blockquote type="cite">Under what circumstances should a frontend choose to emit(at -O0(No optimization)) llvm.dbg.value for a local variable.<br><br>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></blockquote><br>[...]<br><br><blockquote type="cite"> call void @llvm.dbg.declare(metadata i32* %foo, metadata !9, metadata !DIExpression()), !dbg !11<br>%0 = load i32, i32* %foo, align 4, !dbg !13<br>  call void @llvm.dbg.value(metadata i32 %0, metadata !9, metadata !DIExpression()), !dbg !11<br></blockquote><br>My understanding is that this isn't correct: dbg.declare specifies the<br>memory address of a variable for the whole lifetime of the function,<br>whereas dbg.value (and dbg.addr) specify the value/address until the<br>next debug intrinsic. Mixing these two kinds of intrinsics creates<br>ambiguity over where the variable location is at different positions<br>in the code.<br></div></div></blockquote><div><br></div>Correct, you should not be mixing dbg.declare and other instrinsics for the same variable.</div><div><br></div><div>See also <a href="https://llvm.org/docs/SourceLevelDebugging.html#llvm-dbg-declare" target="_blank">https://llvm.org/docs/SourceLevelDebugging.html#llvm-dbg-declare</a></div><div><br></div><div>-- adrian</div><div><br></div><div><blockquote type="cite"><div><div><br>If dbg.value intrinsics are to be used and the variable can be located<br>in memory too, then the producer needs to specify where the location<br>switches from a value to an address (and vice versa) with dbg.value /<br>dbg.addr. Awkwardly,I think there are some issues with dbg.addr at -O0<br>that Brian ran into here [0, 1], which might need addressing.<br><br>[0] <a href="http://lists.llvm.org/pipermail/llvm-dev/2020-February/139500.html" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2020-February/139500.html</a><br>[1] <a href="http://lists.llvm.org/pipermail/llvm-dev/2020-February/139511.html" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2020-February/139511.html</a><br><br>--<br>Thanks,<br>Jeremy<br>_______________________________________________<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" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></div></div></blockquote></div><br></div></blockquote></div>