[PATCH] D102412: [coro] Preserve scope line for compiler generated functions

Dave Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 13 09:15:55 PDT 2021


kastiglione created this revision.
kastiglione added reviewers: aprantl, aschwaighofer.
Herald added subscribers: lxfind, hiraditya.
kastiglione requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Coro-split functions with an active suspend point have their scope line set to
the line of the suspend point. However for compiler generated functions, this
results in debug info with unconventional results: a file named
`<compiler-generated>` with a non-zero line number. The convention for
`<compiler-generated>` is that the line number is zero.

This change propagates the scope line only for non-compiler generated
functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102412

Files:
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp


Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -849,15 +849,17 @@
 
   auto &Context = NewF->getContext();
 
-  // For async functions / continuations, adjust the scope line of the
-  // clone to the line number of the suspend point. The scope line is
-  // associated with all pre-prologue instructions. This avoids a jump
-  // in the linetable from the function declaration to the suspend point.
+  // For async functions / continuations, adjust the scope line of the clone to
+  // the line number of the suspend point. However, only adjust the scope line
+  // for non-compiler generated functions. The scope line is associated with
+  // all pre-prologue instructions. This avoids a jump in the linetable from
+  // the function declaration to the suspend point.
   if (DISubprogram *SP = NewF->getSubprogram()) {
     assert(SP != OrigF.getSubprogram() && SP->isDistinct());
     if (ActiveSuspend)
       if (auto DL = ActiveSuspend->getDebugLoc())
-        SP->setScopeLine(DL->getLine());
+        if (SP->getFilename() != "<compiler-generated>")
+          SP->setScopeLine(DL->getLine());
     // Update the linkage name to reflect the modified symbol name. It
     // is necessary to update the linkage name in Swift, since the
     // mangling changes for resume functions. It might also be the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102412.345176.patch
Type: text/x-patch
Size: 1483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210513/622e1f5c/attachment.bin>


More information about the llvm-commits mailing list