[llvm] [DebugInfo][LoopIdiomRecognize] Fix #82582: Wrong debug location update in processLoopStoreOfLoopLoad (PR #82608)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 02:15:49 PST 2024


================
@@ -0,0 +1,103 @@
+; RUN: opt < %s -passes=loop-idiom -S | FileCheck %s
+
+; Function Attrs: noinline nounwind uwtable
+define dso_local void @fun(ptr noalias noundef %a, ptr noalias noundef %b) #0 !dbg !10 {
+
+; CHECK-LABEL: entry:
+; CHECK-NOT: call void @llvm.memcpy.p0.p0.i64{{.*}}dbg {{![0-9]+}}
+entry:
+  tail call void @llvm.dbg.value(metadata ptr %a, metadata !17, metadata !DIExpression()), !dbg !18
+  tail call void @llvm.dbg.value(metadata ptr %b, metadata !19, metadata !DIExpression()), !dbg !18
+  tail call void @llvm.dbg.value(metadata i64 2047, metadata !20, metadata !DIExpression()), !dbg !23
+  br label %for.body, !dbg !24
+
+for.body:                                         ; preds = %entry, %for.body
+  %i.01 = phi i64 [ 2047, %entry ], [ %dec, %for.body ]
+  tail call void @llvm.dbg.value(metadata i64 %i.01, metadata !20, metadata !DIExpression()), !dbg !23
+  %arrayidx = getelementptr inbounds i32, ptr %b, i64 %i.01, !dbg !25
+  %0 = load i32, ptr %arrayidx, align 4, !dbg !25
+  %arrayidx1 = getelementptr inbounds i32, ptr %a, i64 %i.01, !dbg !28
+  store i32 %0, ptr %arrayidx1, align 4, !dbg !29
+  %dec = add nsw i64 %i.01, -1, !dbg !30
+  tail call void @llvm.dbg.value(metadata i64 %dec, metadata !20, metadata !DIExpression()), !dbg !23
+  %cmp = icmp sge i64 %dec, 0, !dbg !31
+  br i1 %cmp, label %for.body, label %for.end, !dbg !24, !llvm.loop !32
+
+for.end:                                          ; preds = %for.body
+  ret void, !dbg !35
+}
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+; Function Attrs: noinline nounwind uwtable
+define dso_local i32 @main() #0 !dbg !36 {
+entry:
+  %a = alloca [2048 x i32], align 16
+  %b = alloca [2048 x i32], align 16
+  tail call void @llvm.dbg.declare(metadata ptr %a, metadata !39, metadata !DIExpression()), !dbg !43
+  tail call void @llvm.dbg.declare(metadata ptr %b, metadata !44, metadata !DIExpression()), !dbg !45
+  %arraydecay = getelementptr inbounds [2048 x i32], ptr %a, i64 0, i64 0, !dbg !46
+  %arraydecay1 = getelementptr inbounds [2048 x i32], ptr %b, i64 0, i64 0, !dbg !47
+  call void @fun(ptr noundef %arraydecay, ptr noundef %arraydecay1), !dbg !48
+  ret i32 0, !dbg !49
+}
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
----------------
SLTozer wrote:

For these tests, we prefer to drop the function attributes if they aren't necessary for the test to pass.

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


More information about the llvm-commits mailing list