Skip to content

Commit

Permalink
{DebugInfo][LSR] Don't cache dbg.value that are already undef
Browse files Browse the repository at this point in the history
The SCEV-based salvaging method caches dbg.value information pre-LSR so
that salvaging may be attempted post-LSR. If the dbg.value are already
undef pre-LSR then a salvage attempt would be fruitless, so avoid
caching them.

Reviewed By: StephenTozer

Differential Revision: https://reviews.llvm.org/D107448
  • Loading branch information
Chris Jackson committed Aug 5, 2021
1 parent ec51370 commit 113a06f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Expand Up @@ -6222,6 +6222,9 @@ DbgGatherSalvagableDVI(Loop *L, ScalarEvolution &SE,
if (!DVI)
continue;

if (DVI->isUndef())
continue;

if (DVI->hasArgList())
continue;

Expand Down
6 changes: 5 additions & 1 deletion llvm/test/Transforms/LoopStrengthReduce/pr51329.ll
Expand Up @@ -2,7 +2,10 @@
;
; Test that LSR SCEV-based salvaging does not crash when translating SCEVs
; that contain integers with binary representations greater than 64-bits.
; Also show that no salvaging attempt is made for dbg.value that are undef
; pre-LSR.
;
; CHECK: call void @llvm.dbg.value(metadata i64 undef, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_plus_uconst, 228, DW_OP_stack_value))
; CHECK: call void @llvm.dbg.value(metadata i64 %var2, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_plus_uconst, 228, DW_OP_stack_value))


Expand All @@ -23,6 +26,7 @@ init:

Label_d0: ; preds = %Label_d0, %init
%var3 = phi i64 [ %var2, %init ], [ %var4, %Label_d0 ]
call void @llvm.dbg.value(metadata i64 undef, metadata !11, metadata !DIExpression(DW_OP_plus_uconst, 228, DW_OP_stack_value)), !dbg !12
call void @llvm.dbg.value(metadata i64 %var2, metadata !11, metadata !DIExpression(DW_OP_plus_uconst, 228, DW_OP_stack_value)), !dbg !12
%var4 = add i64 %var3, -1
%var5 = icmp eq i64 %var4, 0
Expand All @@ -47,4 +51,4 @@ Label_1bc: ; preds = %Label_d0
!9 = !DIBasicType(name: "my_type", size: 64, encoding: DW_ATE_unsigned)
!10 = !{!11}
!11 = !DILocalVariable(name: "my_var", arg: 1, scope: !5, file: !1, line: 904320, type: !8)
!12 = !DILocation(line: 904544, scope: !5)
!12 = !DILocation(line: 904544, scope: !5)

0 comments on commit 113a06f

Please sign in to comment.