Files
Nerixyz cacf225ff3 [LLVM][CodeView] Add S_REGREL32_INDIR (#183172)
This adds `RegRelativeIndirSym` (`S_REGREL32_INDIR`) as a record, so we
can emit and dump it (#34392). It encodes a variable at the location
`*($Register+ Offset) + OffsetInUdt` and is used by MSVC in C++ 20
coroutines and C++ 17 structured bindings. Clang also needs this for
coroutines (for `__promise` which has the location `DW_OP_deref,
DW_OP_plus_uconst, 16`).

For example:

```cpp
struct Foo { int a, b; };

void fn() {
  Foo f = {1, 2};
  //  ╰─ S_REGREL32{ reg = rsp, offset = 0 }
  auto &[x, y] = f;
  //     │  ╰─ S_REGREL32_INDIR{ reg = rsp, offset = 8, offset-in-udt = 4, type = int }
  //     ╰─ S_REGREL32_INDIR{ reg = rsp, offset = 8, offset-in-udt = 0, type = int }
}
```

The `S_REGREL32_INDIR` for `y` from above looks like this:

```
│ 08000000 │ 74000000 │ 04000000 │ 4F01 │ 7900 │ 
│ Offset   │ Type     │ OffInUdt │ Reg. │ Name │
```

I prototyped support for this in LLDB's native PDB parser to check the
assumption about the location (in a followup PR).

I was wrong in #182743, thinking that the location was just `$Register +
Offset + OffsetInUdt`. That could've been encoded as a `S_REGREL32`.
Presumably, `S_BPREL32_INDIR` works similar, but I can't get MSVC to
generate this.
2026-03-12 14:04:46 +01:00
..