From 113a06f7a50010b555a0fdabc9db0a8338e2f2a8 Mon Sep 17 00:00:00 2001 From: Chris Jackson Date: Thu, 5 Aug 2021 15:46:09 +0100 Subject: [PATCH] {DebugInfo][LSR] Don't cache dbg.value that are already undef 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 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 3 +++ llvm/test/Transforms/LoopStrengthReduce/pr51329.ll | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index eea5623..a126c54 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -6222,6 +6222,9 @@ DbgGatherSalvagableDVI(Loop *L, ScalarEvolution &SE, if (!DVI) continue; + if (DVI->isUndef()) + continue; + if (DVI->hasArgList()) continue; diff --git a/llvm/test/Transforms/LoopStrengthReduce/pr51329.ll b/llvm/test/Transforms/LoopStrengthReduce/pr51329.ll index f8f1c48..ffdb785 100644 --- a/llvm/test/Transforms/LoopStrengthReduce/pr51329.ll +++ b/llvm/test/Transforms/LoopStrengthReduce/pr51329.ll @@ -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)) @@ -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 @@ -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) \ No newline at end of file -- 2.7.4