[llvm] Handle #dbg_values in SROA. (PR #94070)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 10:51:49 PDT 2024


================
@@ -129,9 +129,8 @@ define void @test3(ptr %x) {
 ; CHECK-DEBUGLOC-LABEL: @test3(
 ; CHECK-DEBUGLOC-NEXT:  entry:
 ; CHECK-DEBUGLOC-NEXT:    [[A_SROA_0:%.*]] = alloca [22 x i8], align 8, !dbg [[DBG47:![0-9]+]]
-; CHECK-DEBUGLOC-NEXT:      #dbg_value(ptr undef, [[META44:![0-9]+]], !DIExpression(), [[DBG47]])
+; CHECK-DEBUGLOC-NEXT:      #dbg_value(ptr [[A_SROA_0]], [[META44:![0-9]+]], !DIExpression(), [[DBG47]])
 ; CHECK-DEBUGLOC-NEXT:    [[B_SROA_0:%.*]] = alloca [18 x i8], align 2, !dbg [[DBG48:![0-9]+]]
-; CHECK-DEBUGLOC-NEXT:      #dbg_value(ptr undef, [[META45:![0-9]+]], !DIExpression(), [[DBG48]])
----------------
SLTozer wrote:

Yes, I think these should be undef. It _probably_ doesn't matter for the Swift use-case so much, since these dbg_values are being used like declares, but in general it's safe to delete undef dbg_declares because there can only be one per variable. There can be many dbg_values for a single variable, and so deleting an undef dbg_value can result in incorrect debug info by not ending the scope of any preceding dbg_value. So, for the dbg_value case it'd be semantically consistent to undef them rather than delete them - the RemoveRedundantDbgInfo pass will delete them later on if it's safe to do so.

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


More information about the llvm-commits mailing list