<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/210980>210980</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [lldb] DW_OP_call_frame_cfa pushes a host-width value on 32-bit targets
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jielun-wu
      </td>
    </tr>
</table>

<pre>
    `DW_OP_call_frame_cfa` pushes the canonical frame address obtained from call frame information. LLVM's [location-description stack extension](https://llvm.org/docs/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack.html#a-2-5-4) models the CFA as a location description and requires a default-address-space memory location to become a generic value when arithmetic consumes it. The generic type has the target address width, so this conversion must produce a 32-bit value on i386.

LLDB stores the CFA in `lldb::addr_t`, which is always a 64-bit host carrier, constructs `Scalar(cfa)`, and pushes it without target-width normalization. Later arithmetic therefore treats the i386 CFA as a 64-bit value.

## Source Evidence

`Evaluate_DW_OP_call_frame_cfa` in [DWARFExpression.cpp](https://github.com/llvm/llvm-project/blob/main/lldb/source/Expression/DWARFExpression.cpp) obtains and pushes the CFA as follows:

```cpp
addr_t cfa = id.GetCallFrameAddressWithMetadata();
...
eval_ctx.stack.push_back(Scalar(cfa));
eval_ctx.stack.back().SetValueType(Value::ValueType::LoadAddress);
```

`lldb::addr_t` is defined as `uint64_t`, independently of the target address size. The handler does not pass `cfa` through `to_generic` or otherwise canonicalize it to `8 * address_size` before it reaches later stack operations.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU2P2zYQ_TX0ZWBBpmytfPDBG8e5bJCgmyZHY0SOLKYUqZKjdXZ_fUFZ_kCwPRQoYMCSOF9v5r0hxmiOjmgjVo9itZvhwK0Pm5-G7ODmp2FWe_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