[llvm] [LLVM][Coroutines] Check variable decl scope instead of optimization level (PR #92978)
Billy Zhu via llvm-commits
llvm-commits at lists.llvm.org
Tue May 21 17:38:57 PDT 2024
https://github.com/zyx-billy created https://github.com/llvm/llvm-project/pull/92978
None
>From 12d3a81eba8adb00bc2c5e81be0e3e72a6245d78 Mon Sep 17 00:00:00 2001
From: Billy Zhu <billyzhu at modular.com>
Date: Tue, 21 May 2024 16:31:29 -0700
Subject: [PATCH 1/2] check inline instead of o0
---
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 22 ++++++++++++--------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index dd9e77a855ef4..38b8dab984db3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2974,10 +2974,12 @@ 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())
+ // Update DILocation only if variable was not inlined.
+ DebugLoc ILoc = I->getDebugLoc();
+ DebugLoc DVILoc = DVI.getDebugLoc();
+ if (ILoc && DVILoc &&
+ DVILoc->getScope()->getSubprogram() ==
+ ILoc->getScope()->getSubprogram())
DVI.setDebugLoc(I->getDebugLoc());
} else if (isa<Argument>(Storage))
InsertPt = F->getEntryBlock().begin();
@@ -3014,11 +3016,13 @@ 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())
- DVR.setDebugLoc(I->getDebugLoc());
+ // Update DILocation only if variable was not inlined.
+ DebugLoc ILoc = I->getDebugLoc();
+ DebugLoc DVRLoc = DVR.getDebugLoc();
+ if (ILoc && DVRLoc &&
+ DVRLoc->getScope()->getSubprogram() ==
+ ILoc->getScope()->getSubprogram())
+ DVR.setDebugLoc(ILoc);
} else if (isa<Argument>(Storage))
InsertPt = F->getEntryBlock().begin();
if (InsertPt) {
>From 9d056611f3d1317c5de3d97e5b51fec3e88884ac Mon Sep 17 00:00:00 2001
From: Billy Zhu <billyzhu at modular.com>
Date: Tue, 21 May 2024 17:37:56 -0700
Subject: [PATCH 2/2] update test
---
...me-variable-O1.ll => coro-debug-frame-variable-inlined.ll} | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
rename llvm/test/Transforms/Coroutines/{coro-debug-frame-variable-O1.ll => coro-debug-frame-variable-inlined.ll} (96%)
diff --git a/llvm/test/Transforms/Coroutines/coro-debug-frame-variable-O1.ll b/llvm/test/Transforms/Coroutines/coro-debug-frame-variable-inlined.ll
similarity index 96%
rename from llvm/test/Transforms/Coroutines/coro-debug-frame-variable-O1.ll
rename to llvm/test/Transforms/Coroutines/coro-debug-frame-variable-inlined.ll
index acd6a08d7c1b8..ff070d9b02acc 100644
--- a/llvm/test/Transforms/Coroutines/coro-debug-frame-variable-O1.ll
+++ b/llvm/test/Transforms/Coroutines/coro-debug-frame-variable-inlined.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -passes='module(coro-early),cgscc(inline,coro-split<reuse-storage>)' -S | FileCheck %s
-; RUN: opt --try-experimental-debuginfo-iterators < %s -passes='module(coro-early),cgscc(inline,coro-split<reuse-storage>)' -S | FileCheck %s
+; RUN: opt < %s -passes='module(coro-early),cgscc(inline,coro-split)' -S | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators < %s -passes='module(coro-early),cgscc(inline,coro-split)' -S | FileCheck %s
; Simplified version from pr#75104.
; Make sure we do not update debug location for hosited dbg.declare intrinsics when optimizing coro frame.
More information about the llvm-commits
mailing list