[PATCH] D142160: [mem2reg][debuginfo] Handle op_deref when converting dbg.declare

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 16:57:47 PST 2023


aprantl added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:1534
+  // The former says that the value of the variable is found by doing:
+  // deref(deref(alloca) + 2), whereas the latter is deref(deref(alloca)) + 2.
+  // If the alloca describes the variable itself, i.e. the expression in the
----------------
I'm not sure the second half of this sentence is necessarily true, I think it's more an emergent behavior of the instruction selector, because at the LLVM IR level we don't really distinguish what DWARF calls location description kinds, but it certainly correct that the two are not equivalent.

One thing you could do is define the semantics of `dbg.declare(alloca, var, DIExpression(DW_OP_deref))` as the alloca holding the canonical address of var, *which may not change throughout the entire function*. Patching LangRef this way would allow you to do the kind of transformation that you need here.

I'm also curious if how we defined llvm.dbg.addr() and if it would be of any use here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142160/new/

https://reviews.llvm.org/D142160



More information about the llvm-commits mailing list