Skip to content

Commit 0faf46b

Browse files
authored
[coroutines][DPValue] Update DILocation in DPValue for hoisted dbg.declare (#76765)
Follow up #75402 to cover DPValue
1 parent a3977c9 commit 0faf46b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,9 @@ void coro::salvageDebugInfo(
29532953
std::optional<BasicBlock::iterator> InsertPt;
29542954
if (auto *I = dyn_cast<Instruction>(Storage)) {
29552955
InsertPt = I->getInsertionPointAfterDef();
2956+
// Update DILocation only in O0 since it is easy to get out of sync in
2957+
// optimizations. See https://github.com/llvm/llvm-project/pull/75104 for
2958+
// an example.
29562959
if (!OptimizeFrame && I->getDebugLoc())
29572960
DVI.setDebugLoc(I->getDebugLoc());
29582961
} else if (isa<Argument>(Storage))
@@ -2988,9 +2991,14 @@ void coro::salvageDebugInfo(
29882991
// dbg.declare does.
29892992
if (DPV.getType() == DPValue::LocationType::Declare) {
29902993
std::optional<BasicBlock::iterator> InsertPt;
2991-
if (auto *I = dyn_cast<Instruction>(Storage))
2994+
if (auto *I = dyn_cast<Instruction>(Storage)) {
29922995
InsertPt = I->getInsertionPointAfterDef();
2993-
else if (isa<Argument>(Storage))
2996+
// Update DILocation only in O0 since it is easy to get out of sync in
2997+
// optimizations. See https://github.com/llvm/llvm-project/pull/75104 for
2998+
// an example.
2999+
if (!OptimizeFrame && I->getDebugLoc())
3000+
DPV.setDebugLoc(I->getDebugLoc());
3001+
} else if (isa<Argument>(Storage))
29943002
InsertPt = F->getEntryBlock().begin();
29953003
if (InsertPt) {
29963004
DPV.removeFromParent();

0 commit comments

Comments
 (0)