<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
If we consider simple test case:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="remarkup-code-block" data-code-lang="text" data-sigil="remarkup-code-block" style="margin: 12px 0px; font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; text-align: left; background-color: rgb(255, 255, 255)">
<pre class="remarkup-code" style="margin: 0px; padding: 12px; background: rgba(71, 87, 120, 0.08); display: block; overflow: auto; border-radius: 3px; font: 12px / 15px Menlo, Consolas, Monaco, monospace">void f1(int);
void f2(int i) {
  f1(1);
  i = i + 5;
  f1(3);
}</pre>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
we can see what are the benefits we get after enabling the DW_OP_entry_value on IR. Please consider looking at <a href="https://reviews.llvm.org/D87233">https://reviews.llvm.org/D87233</a> for more details.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
On a very high level, we introduce a utility within <span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; text-align: left; background-color: rgb(255, 255, 255); display: inline !important">Transforms/Utils/Local.cpp, <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; text-align: start; background-color: rgb(255, 255, 255); display: inline !important">that
 will inspect the IR by trying to find an entry Value for a DIVariable. By introducing such utility, we don't need to carry/introduce any additional info to llvm.dbg.val or DIVariable.</span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The utility can be used at various places (similar to salvageDebugInfo()) during the middle-end phase.</div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Besides this, the <a href="https://reviews.llvm.org/D85012" id="LPlnk507068">https://reviews.llvm.org/D85012</a> is another usage of <span style="font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important">DW_OP_entry_value<span> outside
 of the LiveDebugValues.</span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Best,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Djordje</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Djordje Todorovic <Djordje.Todorovic@syrmia.com><br>
<b>Sent:</b> Tuesday, September 1, 2020 3:54 PM<br>
<b>To:</b> David Stenberg <david.stenberg@ericsson.com>; llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org><br>
<b>Cc:</b> paul.robinson@sony.com <paul.robinson@sony.com>; asowda@cisco.com <asowda@cisco.com>; jeremy.morse@sony.com <jeremy.morse@sony.com>; ibaev@cisco.com <ibaev@cisco.com>; vsk@apple.com <vsk@apple.com>; aprantl@apple.com <aprantl@apple.com>; Petar Jovanovic
 <petar.jovanovic@syrmia.com>; Nikola Tesic <Nikola.Tesic@syrmia.com>; dblaikie@gmail.com <dblaikie@gmail.com><br>
<b>Subject:</b> Re: [llvm-dev] [RFC] [DebugInfo] Using DW_OP_entry_value within LLVM IR</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi David, </div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Thanks for your comments!</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<blockquote style="border-left:3px solid rgb(200,200,200); border-top-color:rgb(200,200,200); border-right-color:rgb(200,200,200); border-bottom-color:rgb(200,200,200); padding-left:1ex; margin-left:0.8ex; color:rgb(102,102,102)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">I just want to add that I think it would neat if the entry values could map into</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">multi-location dbg.values and DBG_VALUEs that are being proposed on this list.</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">For example, if we have:</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">  int local = param1 + param2 + 123;</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">I think it would be good if we would be able to to represent the four different</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">permutations of the values of the parameters being available in the function or</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">as entry values.</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">I have not yet delved into the discussion about the multi-location debug values,</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
<span style="font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">so I don't have any proposals for how that could look.</span><br style="font-size:14.6667px; background-color:rgb(255,255,255)">
</blockquote>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I guess it can (somehow) be mapped into that.  It is clear to me that the usage of the DBG_VALUE_LIST will be appropriate for the "Salvage Debug Info", but the idea of using the entry values on IR level is more general (not very localized), and there is the
 cause of potential complexity, since we need to carry that info throughout IR and use it as a backup.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<b><br>
</b></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Best regards,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Djordje</div>
<div id="x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> David Stenberg <david.stenberg@ericsson.com><br>
<b>Sent:</b> Tuesday, September 1, 2020 11:38 AM<br>
<b>To:</b> Djordje Todorovic <Djordje.Todorovic@syrmia.com>; llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org><br>
<b>Cc:</b> paul.robinson@sony.com <paul.robinson@sony.com>; asowda@cisco.com <asowda@cisco.com>; jeremy.morse@sony.com <jeremy.morse@sony.com>; ibaev@cisco.com <ibaev@cisco.com>; vsk@apple.com <vsk@apple.com>; aprantl@apple.com <aprantl@apple.com>; Petar Jovanovic
 <petar.jovanovic@syrmia.com>; Nikola Tesic <Nikola.Tesic@syrmia.com>; dblaikie@gmail.com <dblaikie@gmail.com><br>
<b>Subject:</b> Re: [llvm-dev] [RFC] [DebugInfo] Using DW_OP_entry_value within LLVM IR</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">Hi!<br>
<br>
On Tue, 2020-09-01 at 07:35 +0000, Djordje Todorovic wrote:<br>
> Hi all,<br>
> <br>
> The debug entry values feature introduces new DWARF symbols (tags, attributes,<br>
> operations) on caller (call site) as well as on callee side; and the intention<br>
> is to improve debugging user experience by using the functionality (especially<br>
> in “optimized” code by turning “<optimized_out>” values into real values). The<br>
> call site information includes info about call itself (described with<br>
> DW_TAG_call_site) with corresponding children representing function arguments<br>
> at the call site (described with DW_TAG_call_site_params). The most interesting<br>
> DWARF attribute for us (here) is DW_AT_call_value which contains a DWARF<br>
> expression which represents a value of the parameter at the time of the call.<br>
> For the context of this RFC, more relevant part of the feature is the callee<br>
> side, and it refers to new DWARF operation - DW_OP_entry_value, used to<br>
> indicate that in some situations we can use parameter’s entry value as a real<br>
> value in the current frame. It relies on the call-site info provided, and the<br>
> more DW_AT_call_value generated, the more debug location inputs using<br>
> DW_OP_entry_value will be turned into real values.<br>
> <br>
> Current implementation in LLVM<br>
> <br>
> Currently in LLVM, we generate the DW_OP_entry_values *only* for unmodified<br>
> parameters during the LiveDebugValues pass, for the places where the Code<br>
> Generation truncated live range of the parameters. The potential of the<br>
> functionality goes beyond this, and it means we should be able to use the entry<br>
> values even for modified parameters iff the modification could be expressed in<br>
> terms of its entry value. In addition, there are cases where we can express<br>
> values of local variables in terms of some parameter’s entry-values (e.g. int<br>
> local = param + 2;).<br>
> <br>
> Proposal<br>
> <br>
> The idea of this RFC is to introduce an idea/discussion of using the<br>
> DW_OP_entry_value not only at the end of LLVM pipeline (within<br>
> LiveDebugValues). There are cases it could be useful at IR level; i.e. for<br>
> unused arguments (please take a look into <br>
> <a href="https://protect2.fireeye.com/v1/url?k=16c671b9-4876ec21-16c63122-861fcb972bfc-e4488a7f57de3412&q=1&e=4f293e8b-6a1f-4a80-9de1-30399c7295a6&u=https%3A%2F%2Freviews.llvm.org%2FD85012">
https://protect2.fireeye.com/v1/url?k=16c671b9-4876ec21-16c63122-861fcb972bfc-e4488a7f57de3412&q=1&e=4f293e8b-6a1f-4a80-9de1-30399c7295a6&u=https%3A%2F%2Freviews.llvm.org%2FD85012</a><br>
> ); I believe there are a lot of cases where an IR pass drops/cuts variable’s<br>
> debug value info where an entry value can fall back on as a backup location.<br>
> There could be multiple ways of implementation, but in general, we need to<br>
> extend metadata describing the debug value to support/refer to entry<br>
> value/backup value as well (and when primary location is lost, the value with<br>
> DW_OP_entry_value becomes the primary one). One way could be extending of<br>
> llvm.dbg.value with an additional operand as following:<br>
> <br>
>                llvm.dbg.value(…, DIEntryValExpression(DW_OP_uconst, 5)) //<br>
> DIEntryValExpression implicitly contains DW_OP_entry_value operation<br>
> <br>
> The bottom line is that the production of call-site side of the feature stays<br>
> the same, but LLVM will have more freedom to generate more of<br>
> DW_OP_entry_values operation on the callee side.<br>
> <br>
> Any thoughts on this?<br>
<br>
I just want to add that I think it would neat if the entry values could map into<br>
multi-location dbg.values and DBG_VALUEs that are being proposed on this list.<br>
<br>
For example, if we have:<br>
<br>
  int local = param1 + param2 + 123;<br>
<br>
I think it would be good if we would be able to to represent the four different<br>
permutations of the values of the parameters being available in the function or<br>
as entry values.<br>
<br>
I have not yet delved into the discussion about the multi-location debug values,<br>
so I don't have any proposals for how that could look.<br>
<br>
Best regards,<br>
David<br>
<br>
> Best regards,<br>
> Djordje<br>
</div>
</span></font></div>
</div>
</body>
</html>