[llvm] [CodeView] Match MSVC implicit this records for Visual Studio (PR #214289)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 8 02:06:37 PDT 2026
Nerixyz wrote:
I think this is more of a bug with the Visual Studio debugger. Both LLDB and WinDbg will show the value of `this` when it's available.
---
Long aside: The range for `this` looks slightly off. I'll use the example from above. You can also check it on compiler explorer: https://godbolt.org/z/3caPTnha7
```asm
; foo::foo() [addr = 0001:0032, code size = 24]:
140001020: 50 push rax
140001021: 48 89 0c 24 mov QWORD PTR [rsp],rcx
140001025: 48 8b 04 24 mov rax,QWORD PTR [rsp] ; ⎤ "Real" range of `this`
140001029: c7 00 01 00 00 00 mov DWORD PTR [rax],0x1 ; ⎤ DEFRANGE of `this` │
14000102f: c7 40 04 02 00 00 00 mov DWORD PTR [rax+0x4],0x2 ; │ [0001:0041,+15) │
140001036: 59 pop rcx ; │ ⎦
140001037: c3 ret ; ⎦
```
We say that `this`ranges from `[0x140001029, 0x140001038)`, but you can see in the disassembly, that `[rsp]` is set to the `this` value at `0x140001021` - so one instruction after, we already have the value. Similar for the end: with `pop rcx`, we remove the value from the stack, so at the `ret`, `this` is no longer at `[rcx]`.
https://github.com/llvm/llvm-project/pull/214289
More information about the llvm-commits
mailing list