I’ve been looking through the various bits of debug info machinery in LLVM today, and I’m a bit unsure of the current status of
From what I could find,
dbg.addr was added in 2017 after an RFC as a way of tracking locations of variables in memory which move rather than staying fixed (where
dbg.declare can be used). Debug info docs currently describe
dbg.declare as deprecated, with
dbg.addr as its intended replacement.
At the moment though, it does not seem like Clang or the optimisation passes add
dbg.addr intrinsics by default. There are also a few open issues which suggest
dbg.addr doesn’t quite work correctly at the moment.
Is there a plan to fix issues in this area and make
dbg.addr the default? Perhaps @rnk may know, since they added it originally.
My apologies if I’ve missed something obvious here!
Currently, we only produce
dbg.addr intrinsics if the
use-dbg-addr flag is passed, and this path has errors that haven’t been fixed for some time (as you’ve noted). The most recent word from Reid - who wrote the RFC and added
dbg.addr - was that “we should remove dbg.addr since it sounds like dbg.value+DW_OP_deref is the preferred representation of the same thing”.
On the other hand there has been some recent work to improve support for the intrinsic, most notably @gottesmm has submitted a number of patches to improve support for it, particularly in relation to coroutines, so there is at least some investment. In my personal opinion though, I would favour removing
dbg.addr and using
dbg.value (or even better where appropriate,
Yes, dbg.addr should be removed. We have new and better mechanisms to express the same ideas.
[scrambles to remove
dbg.addr from his frontend…]
Are there any examples of IR showing the equivalent
DW_OP_deref for a given
dbg.addr? Perhaps a Compiler Explorer link…?
@llvm.dbg.value(metadata ptr %foo, metadata <local var metadata>, metadata !DIExpression(DW_OP_deref))
seems to work equivalently to
@llvm.dbg.addr(metadata ptr %foo, metadata <local var metadata>, metadata !DIExpression())
So I guess that’s all there is to it. Whew!
Thanks for everyone’s replies on this topic a few months back.
There seems to be clear enough agreement that
dbg.addr should go away. I’m happy to take on the work of removing it, as I think it will make things easier to follow for the next person who investigates LLVM’s debug info support.
Perhpas I should wait for @OCHyams’s Assignment Tracking patch stack to be merged first though…? I expect I would need to update many of the same files.