[llvm] [coroutines][DPValue] Update DILocation in DPValue for hoisted dbg.declare (PR #76765)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 2 15:49:24 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Wei Wang (apolloww)

<details>
<summary>Changes</summary>

Follow up #<!-- -->75402 to cover DPValue

---
Full diff: https://github.com/llvm/llvm-project/pull/76765.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+8-2) 


``````````diff
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 529f7309a1a273..690f813b477658 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2953,6 +2953,8 @@ void coro::salvageDebugInfo(
     std::optional<BasicBlock::iterator> InsertPt;
     if (auto *I = dyn_cast<Instruction>(Storage)) {
       InsertPt = I->getInsertionPointAfterDef();
+      // Update DILocation only in O0 since it is easy to get out of sync in optimizations.
+      // See https://github.com/llvm/llvm-project/pull/75104 for an example.
       if (!OptimizeFrame && I->getDebugLoc())
         DVI.setDebugLoc(I->getDebugLoc());
     } else if (isa<Argument>(Storage))
@@ -2988,9 +2990,13 @@ void coro::salvageDebugInfo(
   // dbg.declare does.
   if (DPV.getType() == DPValue::LocationType::Declare) {
     std::optional<BasicBlock::iterator> InsertPt;
-    if (auto *I = dyn_cast<Instruction>(Storage))
+    if (auto *I = dyn_cast<Instruction>(Storage)) {
       InsertPt = I->getInsertionPointAfterDef();
-    else if (isa<Argument>(Storage))
+      // Update DILocation only in O0 since it is easy to get out of sync in optimizations.
+      // See https://github.com/llvm/llvm-project/pull/75104 for an example.
+      if (!OptimizeFrame && I->getDebugLoc())
+        DPV.setDebugLoc(I->getDebugLoc());
+    } else if (isa<Argument>(Storage))
       InsertPt = F->getEntryBlock().begin();
     if (InsertPt) {
       DPV.removeFromParent();

``````````

</details>


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


More information about the llvm-commits mailing list