[llvm] [debuginfo][coro] Emit debug info labels for coroutine resume points (PR #141937)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 29 05:26:27 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/Transforms/Coroutines/CoroFrame.cpp llvm/lib/Transforms/Coroutines/CoroSplit.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 7fe19ca0d..b8d355f5c 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -689,8 +689,9 @@ static DIType *solveDIType(DIBuilder &Builder, Type *Ty,
 static void buildFrameDebugInfo(Function &F, coro::Shape &Shape,
                                 FrameDataInfo &FrameData) {
   DISubprogram *DIS = F.getSubprogram();
-  // If there is no DISubprogram for F, it implies the function is compiled without
-  // debug info. So we also don't generate debug info for the frame, either.
+  // If there is no DISubprogram for F, it implies the function is compiled
+  // without debug info. So we also don't generate debug info for the frame,
+  // either.
   if (!DIS || !DIS->getUnit() ||
       !dwarf::isCPlusPlus(
           (dwarf::SourceLanguage)DIS->getUnit()->getSourceLanguage()) ||
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index d84886cd1..c59fe5a5b 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -1495,11 +1495,15 @@ private:
 
     DIBuilder DBuilder(*F.getParent(), /*AllowUnresolved*/ false);
     DISubprogram *DIS = F.getSubprogram();
-    // If there is no DISubprogram for F, it implies the function is compiled without
-    // debug info. So we also don't generate debug info for the suspension points, either.
-    bool AddDebugLabels = (DIS && DIS->getUnit() &&
-        (DIS->getUnit()->getEmissionKind() == DICompileUnit::DebugEmissionKind::FullDebug ||
-         DIS->getUnit()->getEmissionKind() == DICompileUnit::DebugEmissionKind::LineTablesOnly));
+    // If there is no DISubprogram for F, it implies the function is compiled
+    // without debug info. So we also don't generate debug info for the
+    // suspension points, either.
+    bool AddDebugLabels =
+        (DIS && DIS->getUnit() &&
+         (DIS->getUnit()->getEmissionKind() ==
+              DICompileUnit::DebugEmissionKind::FullDebug ||
+          DIS->getUnit()->getEmissionKind() ==
+              DICompileUnit::DebugEmissionKind::LineTablesOnly));
 
     // resume.entry:
     //  %index.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32
@@ -1586,12 +1590,14 @@ private:
       PN->addIncoming(S, ResumeBB);
 
       if (AddDebugLabels) {
-         if (DebugLoc SuspendLoc = S->getDebugLoc()) {
-            std::string labelName = ("__coro_resume_" + Twine(SuspendIndex)).str();
-            DILocation& DILoc = *SuspendLoc.get();
-            DILabel *ResumeLabel = DBuilder.createLabel(DIS, labelName, DILoc.getFile(), SuspendLoc.getLine());
-            DBuilder.insertLabel(ResumeLabel, &DILoc, ResumeBB->begin());
-         }
+        if (DebugLoc SuspendLoc = S->getDebugLoc()) {
+          std::string labelName =
+              ("__coro_resume_" + Twine(SuspendIndex)).str();
+          DILocation &DILoc = *SuspendLoc.get();
+          DILabel *ResumeLabel = DBuilder.createLabel(
+              DIS, labelName, DILoc.getFile(), SuspendLoc.getLine());
+          DBuilder.insertLabel(ResumeLabel, &DILoc, ResumeBB->begin());
+        }
       }
 
       ++SuspendIndex;

``````````

</details>


https://github.com/llvm/llvm-project/pull/141937


More information about the llvm-commits mailing list