diff --git a/releasenotes.md b/releasenotes.md index 0f094cd85..65c230010 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -19,6 +19,7 @@ - Union is not properly zero-initialized with designated initializer #1194. - Compile time fmod evaluates to 0 #1195. - Assertion failed when casting (unsigned) argument to enum #1196 +- Correct debug info on parameters without storage. ### Stdlib changes - Add 'zstr' variants for `string::new_format` / `string::tformat`. diff --git a/src/compiler/llvm_codegen_debug_info.c b/src/compiler/llvm_codegen_debug_info.c index 26b7ebe99..726af2068 100644 --- a/src/compiler/llvm_codegen_debug_info.c +++ b/src/compiler/llvm_codegen_debug_info.c @@ -199,9 +199,18 @@ void llvm_emit_debug_parameter(GenContext *c, Decl *parameter, unsigned index) LLVMDIFlagZero); LLVMMetadataRef inline_at = NULL; - if (parameter->is_value) return; + if (parameter->is_value) + { + LLVMDIBuilderInsertDbgValueAtEnd(c->debug.builder, parameter->backend_value, parameter->var.backend_debug_ref, + LLVMDIBuilderCreateExpression(c->debug.builder, NULL, 0), + LLVMDIBuilderCreateDebugLocation(c->context, row, col, c->debug.function, + inline_at), + LLVMGetInsertBlock(c->builder)); + return; + } + LLVMDIBuilderInsertDeclareAtEnd(c->debug.builder, - parameter->is_value ? NULL : parameter->backend_ref, + parameter->backend_ref, parameter->var.backend_debug_ref, LLVMDIBuilderCreateExpression(c->debug.builder, NULL, 0), LLVMDIBuilderCreateDebugLocation(c->context, row, col, c->debug.function, diff --git a/test/test_suite/concurrency/atomic_load_store_debug.c3t b/test/test_suite/concurrency/atomic_load_store_debug.c3t index 50134e96c..0cae6bb9e 100644 --- a/test/test_suite/concurrency/atomic_load_store_debug.c3t +++ b/test/test_suite/concurrency/atomic_load_store_debug.c3t @@ -22,7 +22,6 @@ fn void main() /* #expect: test.ll %.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] } %"any*" = type { ptr, i64 } - @"$ct.test.Ghh" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 12, i64 0, i64 3, [0 x i64] zeroinitializer }, align 8 @.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1 @"$ct.int" = linkonce global %.introspect { i8 2, i64 0, ptr null, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 @@ -59,8 +58,10 @@ entry: ; Function Attrs: define i32 @main(i32 %0, ptr %1) #0 !dbg !33 { entry: - call void @test.main(), !dbg !39 - ret i32 0, !dbg !42 + call void @llvm.dbg.value(metadata i32 %0, metadata !39, metadata !DIExpression()), !dbg !40 + call void @llvm.dbg.value(metadata ptr %1, metadata !41, metadata !DIExpression()), !dbg !40 + call void @test.main(), !dbg !42 + ret i32 0, !dbg !45 } declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 @@ -72,7 +73,6 @@ declare i1 @llvm.expect.i1(i1, i1) #2 !llvm.module.flags = !{!0, !1, !2, !3} !llvm.dbg.cu = !{!4} - !0 = !{i32 2, !"Dwarf Version", i32 4} !1 = !{i32 2, !"Debug Info Version", i32 3} !2 = !{i32 2, !"frame-pointer", i32 2} @@ -112,7 +112,10 @@ declare i1 @llvm.expect.i1(i1, i1) #2 !36 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "char**", baseType: !37, size: 64, align: 64, dwarfAddressSpace: 0) !37 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "char*", baseType: !38, size: 64, align: 64, dwarfAddressSpace: 0) !38 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char) -!39 = !DILocation(line: 18, column: 2, scope: !40) -!40 = distinct !DILexicalBlock(scope: !33, file: !41, line: 18, column: 2) -!41 = !DIFile(filename: "main_stub.c3" -!42 = !DILocation(line: 19, column: 9, scope: !40) +!39 = !DILocalVariable(name: ".anon", arg: 1, scope: !33 +!40 = !DILocation(line: 10, column: 9, scope: !33) +!41 = !DILocalVariable(name: ".anon", arg: 2, scope: !33 +!42 = !DILocation(line: 18, column: 2, scope: !43) +!43 = distinct !DILexicalBlock(scope: !33, file: !44, line: 18, column: 2) +!44 = !DIFile(filename: "main_stub.c3" +!45 = !DILocation(line: 19, column: 9, scope: !43)