[PATCH] D96938: [RFC] [Coroutine] [Debug] Insert dbg.declare to entry.resume to print alloca in the coroutine frame under O2

Chuanqi Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 21:11:28 PST 2021


ChuanqiXu added a comment.

In D96938#2583339 <https://reviews.llvm.org/D96938#2583339>, @aprantl wrote:

> Could you post an example that you are interested in at -O2 and show the diff of the LLVM IR for your example before/after this patch? I find it unintuitive that removing the shadow copy improved the debug info, but if don't need it and removing it doesn't pessimize the situation at -O0 we could remove it.

The diff at -O2 before and after this patch is as follows:

   define internal fastcc void @f.resume(%f.Frame* noalias nonnull align 8 dereferenceable(40) %FramePtr) {
   entry.resume:
  -   call void @llvm.dbg.value(metadata %f.Frame* undef, metadata !19, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 16)), !dbg !21
  -   %vFrame = bitcast %f.Frame* %FramePtr to i8*, !dbg !21
  +  %vFrame = bitcast %f.Frame* %FramePtr to i8*, !dbg !19
  +  call void @llvm.dbg.declare(metadata %f.Frame* %FramePtr, metadata !21, metadata !DIExpression(DW_OP_plus_uconst, 16)), !dbg !19

Since the original version would emit the following codes in resume function:

  define internal fastcc void @f.resume(%f.Frame* noalias nonnull align 8 dereferenceable(40) %FramePtr) {
   entry.resume:
     %FramePtr.debug = alloca %f.Frame*, align 8, !dbg !19
    call void @llvm.dbg.declare(metadata %f.Frame** %FramePtr.debug, metadata !21, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 16)), !dbg !19

And `%FramePtr.debug` would be eliminated in SROA pass which would run after Coro-split pass at -O2. So the value for the corresponding declare would be `undef` finally.

> I find it unintuitive that removing the shadow copy improved the debug info, but if don't need it and removing it doesn't pessimize the situation at -O0 we could remove it.

At O0, the difference before and after this patch would be:

  define internal fastcc void @f.resume(%f.Frame* noalias nonnull align 8 dereferenceable(40) %FramePtr) {
   entry.resume:
  -   %FramePtr.debug = alloca %f.Frame*, align 8, !dbg !19
  -   call void @llvm.dbg.declare(metadata %f.Frame** %FramePtr.debug, metadata !21, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 16)), !dbg !19
  +  call void @llvm.dbg.declare(metadata %f.Frame* %FramePtr, metadata !21, metadata !DIExpression(DW_OP_plus_uconst, 16)), !dbg !19

Due to the limits of my knowledge for debug information, I **can't prove** the semantics remain the same. I could only test for it in C++. And for now it looks like this patch keeps the debug behavior.


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

https://reviews.llvm.org/D96938



More information about the llvm-commits mailing list