[llvm] 113a06f - {DebugInfo][LSR] Don't cache dbg.value that are already undef

Chris Jackson via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 5 11:17:21 PDT 2021


Author: Chris Jackson
Date: 2021-08-05T19:16:43+01:00
New Revision: 113a06f7a50010b555a0fdabc9db0a8338e2f2a8

URL: https://github.com/llvm/llvm-project/commit/113a06f7a50010b555a0fdabc9db0a8338e2f2a8
DIFF: https://github.com/llvm/llvm-project/commit/113a06f7a50010b555a0fdabc9db0a8338e2f2a8.diff

LOG: {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

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    llvm/test/Transforms/LoopStrengthReduce/pr51329.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index eea5623b94fc1..a126c54d4248e 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 f8f1c48eeaa86..ffdb785b8ef8f 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


        


More information about the llvm-commits mailing list