<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div>> Can you elaborate what "direct" means? I'm having trouble understanding what the opposite (a non-exact value) would be.</div>
<div><br>
</div>
<div>Apologies, "exact" was a misleading/incorrect term. By direct, I mean that the expression computes the value of the variable, as opposed to its memory address, or the value that it points to. Within LLVM, where we don't have DW_OP_reg/DW_OP_breg but instead
 simply refer to a generic SSA value, this could mean either a register location or stack value.<br>
</div>
<div><br>
</div>
<div>> At the moment we don't make the lvalue/rvalue distinction in LLVM at all. We make an educated guess in AsmPrinter. But that's wrong and something we should strive to fix during this redesigning.</div>
<div><br>
</div>
<div>I think the opposite; I don't believe there's any reason we need to make the explicit lvalue/rvalue distinction until we're writing DWARF. To put it in more general terms, I think that the IR/MIR debug value instructions should only care about how the
 variable's value can be computed. Whether the result of that computation is an lvalue is unimportant within LLVM itself as far as I can tell, and is redundant when it can be computed from just the DIExpression and location operands.<br>
</div>
<div><br>
</div>
<div>>As stated above, I don't think we can trivially determine this, because (at least for dbg.values) this info was lost already in LLVM IR. Unless we say the dbg.declare / dbg.value distinction is what determines lvalues vs. rvalues.</div>
<div><br>
</div>
<div>With the proposed operator, it would be trivial to determine lvalue vs rvalue debug values with a set of rules (ignoring any fragment operator, which may appear at the end but does not affect the location type):</div>
<div><br>
</div>
<div>  1. If the expression is empty, or any location arguments are <span style="font-family: Consolas, Courier, monospace;">
$noreg </span>=> Empty<br>
  2. If the expression ends with <span style="font-family: Consolas, Courier, monospace;">
DW_OP_implicit_ptr</span> => Implicit pointer (rvalue)<br>
  3. If the expression ends with <span style="font-family: Consolas, Courier, monospace;">
DW_OP_stack_value</span> =>Stack value (rvalue)  // LLVM should produce LLVM_direct instead.<br>
  4. If the expression ends with <span style="font-family: Consolas, Courier, monospace;">
DW_OP_LLVM_direct</span>, then...<br>
    4a. If the preceding expression is just <span style="font-family: Consolas, Courier, monospace;">
DW_OP_LLVM_arg, 0</span> and the only location operand is a register => Register location (lvalue)<br>
    4b. Otherwise => Stack value (rvalue)<br>
<div>  5. Otherwise => Memory location (lvalue)</div>
<div><br>
</div>
</div>
<div>This covers all the expected cases without ambiguity or almost any reduced expressiveness. I believe that the only expression that LLVM will not be able to produce like this is
<span style="font-family: Consolas, Courier, monospace;">DW_OP_bregN, DW_OP_stack_value
</span>due to fact that when DW_OP_LLVM_direct is used, this would be written as a register location instead of a stack value. I don't think there are any cases where we would choose to emit a stack value location when we're able to produce a register location
 instead, so this shouldn't be a problem.<br>
</div>
<br>
</body>
</html>