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

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 08:55:41 PST 2024


Author: Wei Wang
Date: 2024-01-03T08:55:38-08:00
New Revision: 0faf46befa7c07e58034ef8c6a7cd4bd5715de0a

URL: https://github.com/llvm/llvm-project/commit/0faf46befa7c07e58034ef8c6a7cd4bd5715de0a
DIFF: https://github.com/llvm/llvm-project/commit/0faf46befa7c07e58034ef8c6a7cd4bd5715de0a.diff

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

Follow up #75402 to cover DPValue

Added: 
    

Modified: 
    llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 529f7309a1a273..89a1ad2243c849 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2953,6 +2953,9 @@ 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 +2991,14 @@ 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();


        


More information about the llvm-commits mailing list