[llvm] [coroutines][DPValue] Update DILocation in DPValue for hoisted dbg.declare (PR #76765)
Wei Wang via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 2 15:48:56 PST 2024
https://github.com/apolloww created https://github.com/llvm/llvm-project/pull/76765
Follow up #75402 to cover DPValue
>From ba65c4392f67a8c3c871f53a4af620626462980e Mon Sep 17 00:00:00 2001
From: Wei Wang <apollo.mobility at gmail.com>
Date: Tue, 2 Jan 2024 15:47:08 -0800
Subject: [PATCH] [coroutines][DPValue] Update DILocation in DPValue for
hoisted dbg.declare
---
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
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();
More information about the llvm-commits
mailing list