[PATCH] D75338: [Coroutines] Use dbg.declare for frame variables

Brian Gesiak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 28 04:13:28 PST 2020


modocache created this revision.
modocache added reviewers: vsk, jmorse, GorNishanov, lewissbaker, wenlei.
Herald added subscribers: hiraditya, aprantl, EricWF.
Herald added a project: LLVM.
modocache marked an inline comment as done.
modocache added inline comments.
Herald added a subscriber: ormris.


================
Comment at: llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll:877
+!653 = !DILocalVariable(name: "j", scope: !649, file: !5, line: 32, type: !130)
+!654 = !DILocation(line: 32, column: 7, scope: !649)
----------------
Beginner question of mine: is there a good way to reduce this debugging metadata to just the nodes that are necessary for my test? The 654 (!!) nodes here are the result of having run `llvm-reduce` on this test case, but I think many of these remaining nodes come from my having `#include <experimental/coroutine>` in my test program, and not actually necessary for the test case.


https://gist.github.com/modocache/ed7c62f6e570766c0f39b35dad675c2f
is an example of a small C++ program that uses C++20 coroutines that
is difficult to debug, due to the loss of debug info for variables that
"spill" across coroutine suspension boundaries. This patch addresses
that issue by inserting 'llvm.dbg.declare' intrinsics that point the
debugger to the variables' location at an offset to the coroutine frame.

With this patch, I confirmed that running the 'frame variable' commands in
https://gist.github.com/modocache/ed7c62f6e570766c0f39b35dad675c2f at
the specified breakpoints results in the correct values being printed
for coroutine frame variables 'i' and 'j' when using an lldb built from
trunk, as well as with gdb 8.3 (lldb 9.0.1, however, could not print the
values). The added test case also verifies this improved behavior.

The existing coro-debug.ll test case is also modified to reflect the
locations at which Clang actually places calls to 'dbg.declare', and
additional checks are added to ensure this patch works as intended in that
example as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75338

Files:
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll
  llvm/test/Transforms/Coroutines/coro-debug.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75338.247220.patch
Type: text/x-patch
Size: 75473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200228/f5630c46/attachment.bin>


More information about the llvm-commits mailing list