When the following function’s IR is generated by julia-debug,
function add_mat(a,b)
ni,nj = size(a)
for i=1:ni
for j=1:nj
a[i,j] = a[i,j] + b[i,j]
end
end
end
Some of the @llvm.dbg.value
s are repeated, sometimes even in the next line.
[...]
12 call void @llvm.dbg.value(metadata i8** null, i64 0, metadata !15, metadata !23), !dbg !22
13 call void @llvm.dbg.value(metadata i8** null, i64 0, metadata !16, metadata !23), !dbg !22
[...]
68 call void @llvm.dbg.value(metadata i64 %"#temp#1.010", i64 0, metadata !19, metadata !23), !dbg !22
69 call void @llvm.dbg.value(metadata i64 %"#temp#.09", i64 0, metadata !17, metadata !23), !dbg !22
70 %24 = add i64 %"#temp#1.010", -1, !dbg !29
71 %25 = add i64 %"#temp#.09", -1, !dbg !29
72 %26 = mul i64 %25, %6, !dbg !29
73 %27 = add i64 %24, %26, !dbg !29
74 %28 = getelementptr double, double* %3, i64 %27, !dbg !29
75 %29 = load double, double* %28, align 8, !dbg !29, !tbaa !30
76 call void @llvm.dbg.value(metadata i64 %"#temp#1.010", i64 0, metadata !19, metadata !23), !dbg !22
77 call void @llvm.dbg.value(metadata i64 %"#temp#.09", i64 0, metadata !17, metadata !23), !dbg !22
78 %30 = mul i64 %25, %11, !dbg !29
79 %31 = add i64 %24, %30, !dbg !29
80 %32 = getelementptr double, double* %8, i64 %31, !dbg !29
81 %33 = load double, double* %32, align 8, !dbg !29, !tbaa !30
82 %34 = fadd double %29, %33, !dbg !29
83 call void @llvm.dbg.value(metadata i64 %"#temp#1.010", i64 0, metadata !19, metadata !23), !dbg !22
84 call void @llvm.dbg.value(metadata i64 %"#temp#.09", i64 0, metadata !17, metadata !23), !dbg !22
[...]
The intrinsics are present even around instructions that don’t use the register the intrinsic is about.
So, why is julia-debug producing redundant debug intrinsics ?
I’m having an issue with code generating NVPTX kernels in Polly whenever it has to deal with debug information. Just guessing this might be a possible reason.