Closed matthiaskrgr closed 6 years ago
It looks like rust 1.18 looks ok but rust 1.19 is affected by this bug.
@matthiaskrgr hey, the problem that you're seeing: Are all of the "strange debuginfo" cases pointing solely to an empty line at line 0 of some file or another? Or do they sometimes point to empty lines at other lines (namely nonzero ones) within some file?
(I ask because we're musing whether this might be somehow related to our use of so-called "dummy spans" which do not actually correspond to a true location in the source code.)
FWIW, the bogus info seems to be associated with function arguments / return values being copied.
@pnkfelix I think at some point I had some code that would generate debuginfo for non line-0s at a file but currently I fail to come up with an example :(
Same problem with C++: https://godbolt.org/g/doMWzu
Minimized test case:
; ModuleID = '<stdin>'
source_filename = "uw.rs"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
declare void @foo(i64*) unnamed_addr
; Function Attrs: uwtable
define void @bar() unnamed_addr #0 !dbg !4 {
%1 = alloca i64, align 8, !dbg !8
store i64 0, i64* %1, align 8, !dbg !8
br label %l
l: ; preds = %0
call void @foo(i64* %1), !dbg !8
ret void, !dbg !9
}
attributes #0 = { uwtable "no-frame-pointer-elim"="true" "probe-stack"="__rust_probestack" }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3}
!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "clang LLVM (rustc version 1.25.0-nightly (b1f8e6fb0 2018-02-22))", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "uw.rs", directory: "/home/bs/src/rust-play")
!2 = !{}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = distinct !DISubprogram(name: "test", linkageName: "bar", scope: !5, file: !1, line: 5, type: !6, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, templateParams: !2, variables: !2)
!5 = !DINamespace(name: "uw", scope: null)
!6 = !DISubroutineType(types: !7)
!7 = !{null}
!8 = !DILocation(line: 6, scope: !4)
!9 = !DILocation(line: 8, scope: !4)
Removing the branch makes the problem go away.
https://reviews.llvm.org/D43093 takes care of it
The patch was pushed: https://github.com/llvm-mirror/llvm/commit/4d4a317f80ffff0d1069982643f1741523147dd4
triage: P-medium
We'll pick this up when LLVM is next updated, I suppose.
The commit is included in the current rustc nightly llvm. I also failed to reproduce the bug with godbolt rustc nightly. Closing.
original issue here: https://github.com/mattgodbolt/compiler-explorer/issues/832 It seems that strange debuginfo generated for empty lines that don't actually contain any code.
I tried to get some asm with debugginfo for this code (line 1 intentionally left blank)
RUSTFLAGS="--emit asm -C codegen-units=1" cargo build
asm:
expand
```asm .text .file "2w54mzeydaqfl1v6-1462b45f848398765c56e5e1177871c7.rs" .section .text._ZN7asmtest4test17h7e90db8b716e9d37E,"ax",@progbits .p2align 4, 0x90 .type _ZN7asmtest4test17h7e90db8b716e9d37E,@function _ZN7asmtest4test17h7e90db8b716e9d37E: .Lfunc_begin0: .file 1 "src/main.rs" .loc 1 2 0 .cfi_startproc .cfi_personality 155, DW.ref.rust_eh_personality .cfi_lsda 27, .Lexception0 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset %rbp, -16 movq %rsp, %rbp .cfi_def_cfa_register %rbp subq $144, %rsp leaq -120(%rbp), %rdi .Ltmp13: .loc 1 3 0 prologue_end callq _ZN33_$LT$alloc..vec..Vec$LT$T$GT$$GT$3new17hb6ae429368ed332cE .Ltmp14: jmp .LBB0_2 .LBB0_1: .loc 1 2 0 movq -16(%rbp), %rdi callq _Unwind_Resume@PLT ud2 .LBB0_2: .Ltmp0: .loc 1 0 0 is_stmt 0 leaq -120(%rbp), %rdi .Ltmp15: .loc 1 4 0 is_stmt 1 movl $1, %esi callq _ZN33_$LT$alloc..vec..Vec$LT$T$GT$$GT$4push17h574bafd95a15ebf0E .Ltmp1: jmp .LBB0_3 .LBB0_3: .Ltmp2: .loc 1 0 0 is_stmt 0 leaq -120(%rbp), %rdi .loc 1 5 0 is_stmt 1 movl $2, %esi callq _ZN33_$LT$alloc..vec..Vec$LT$T$GT$$GT$4push17h574bafd95a15ebf0E .Ltmp3: jmp .LBB0_5 .Ltmp16: .LBB0_4: .loc 1 0 0 is_stmt 0 leaq -120(%rbp), %rdi .loc 1 8 0 is_stmt 1 callq _ZN4core3ptr13drop_in_place17h327fe38e616aea9fE jmp .LBB0_1 .LBB0_5: .Ltmp4: .loc 1 0 0 is_stmt 0 leaq -120(%rbp), %rdi .Ltmp17: .loc 1 6 0 is_stmt 1 movl $3, %esi callq _ZN33_$LT$alloc..vec..Vec$LT$T$GT$$GT$4push17h574bafd95a15ebf0E .Ltmp5: jmp .LBB0_6 .LBB0_6: .loc 1 0 0 is_stmt 0 leaq -120(%rbp), %rax .loc 1 7 0 is_stmt 1 movq %rax, -32(%rbp) movq -32(%rbp), %rax movq %rax, -24(%rbp) .Ltmp18: .loc 1 7 0 is_stmt 0 movq -24(%rbp), %rdi .Ltmp6: leaq _ZN61_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..fmt..Debug$GT$3fmt17hdcb2b03ddacca383E(%rip), %rsi callq _ZN4core3fmt10ArgumentV13new17h231294433b1d2ca9E .Ltmp7: movq %rdx, -128(%rbp) movq %rax, -136(%rbp) jmp .LBB0_7 .LBB0_7: movq -136(%rbp), %rax movq %rax, -48(%rbp) movq -128(%rbp), %rcx movq %rcx, -40(%rbp) .Ltmp19: .loc 1 7 0 movq .Lconst.4(%rip), %r9 .Ltmp8: movq %rsp, %rdx movq $1, (%rdx) leaq .Lref.2(%rip), %rsi movl $2, %edi movl %edi, %edx movl $1, %edi movl %edi, %r8d leaq -96(%rbp), %rdi leaq -48(%rbp), %rcx callq _ZN4core3fmt9Arguments16new_v1_formatted17h5eb46b1d77c9d642E .Ltmp9: jmp .LBB0_8 .LBB0_8: .Ltmp10: .loc 1 0 0 leaq -96(%rbp), %rdi .loc 1 7 0 callq _ZN3std2io5stdio6_print17hbf362274afcfa890E@PLT .Ltmp11: jmp .LBB0_9 .Ltmp20: .LBB0_9: .loc 1 0 0 leaq -120(%rbp), %rdi .loc 1 8 0 is_stmt 1 callq _ZN4core3ptr13drop_in_place17h327fe38e616aea9fE addq $144, %rsp popq %rbp retq .Ltmp21: .LBB0_11: .Ltmp12: .loc 1 0 0 is_stmt 0 movl %edx, %ecx movq %rax, -16(%rbp) movl %ecx, -8(%rbp) jmp .LBB0_4 .Lfunc_end0: .size _ZN7asmtest4test17h7e90db8b716e9d37E, .Lfunc_end0-_ZN7asmtest4test17h7e90db8b716e9d37E .cfi_endproc .section .gcc_except_table,"a",@progbits .p2align 2 GCC_except_table0: .Lexception0: .byte 255 .byte 155 .asciz "\303\200" .byte 3 .byte 65 .long .Lfunc_begin0-.Lfunc_begin0 .long .Ltmp0-.Lfunc_begin0 .long 0 .byte 0 .long .Ltmp0-.Lfunc_begin0 .long .Ltmp3-.Ltmp0 .long .Ltmp12-.Lfunc_begin0 .byte 0 .long .Ltmp3-.Lfunc_begin0 .long .Ltmp4-.Ltmp3 .long 0 .byte 0 .long .Ltmp4-.Lfunc_begin0 .long .Ltmp11-.Ltmp4 .long .Ltmp12-.Lfunc_begin0 .byte 0 .long .Ltmp11-.Lfunc_begin0 .long .Lfunc_end0-.Ltmp11 .long 0 .byte 0 .p2align 2 .section .text._ZN7asmtest4main17hbd02c537ffc5977bE,"ax",@progbits .p2align 4, 0x90 .type _ZN7asmtest4main17hbd02c537ffc5977bE,@function _ZN7asmtest4main17hbd02c537ffc5977bE: .Lfunc_begin1: .loc 1 9 0 is_stmt 1 .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset %rbp, -16 movq %rsp, %rbp .cfi_def_cfa_register %rbp .Ltmp22: .loc 1 10 0 prologue_end callq _ZN7asmtest4test17h7e90db8b716e9d37E .loc 1 11 0 popq %rbp retq .Ltmp23: .Lfunc_end1: .size _ZN7asmtest4main17hbd02c537ffc5977bE, .Lfunc_end1-_ZN7asmtest4main17hbd02c537ffc5977bE .cfi_endproc .section .text.main,"ax",@progbits .globl main .p2align 4, 0x90 .type main,@function main: .Lfunc_begin2: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset %rbp, -16 movq %rsp, %rbp .cfi_def_cfa_register %rbp subq $16, %rsp leaq _ZN7asmtest4main17hbd02c537ffc5977bE(%rip), %rax movb __rustc_debug_gdb_scripts_section__(%rip), %cl movslq %edi, %rdx movq %rax, %rdi movq %rsi, -8(%rbp) movq %rdx, %rsi movq -8(%rbp), %rdx movb %cl, -9(%rbp) callq _ZN3std2rt10lang_start17h7216235e6b8b786fE movl %eax, %r8d movl %r8d, %eax addq $16, %rsp popq %rbp retq .Lfunc_end2: .size main, .Lfunc_end2-main .cfi_endproc .type str.0,@object .section .rodata.str.0,"a",@progbits str.0: .ascii "my vector is: " .size str.0, 14 .type str.1,@object .section .rodata.str.1,"a",@progbits str.1: .byte 10 .size str.1, 1 .type .Lref.2,@object .section .data.rel.ro..Lref.2,"aw",@progbits .p2align 3 .Lref.2: .quad str.0 .quad 14 .quad str.1 .quad 1 .size .Lref.2, 32 .type .Lref.3,@object .section .rodata..Lref.3,"a",@progbits .p2align 3 .Lref.3: .quad 1 .quad 0 .quad 3 .zero 8 .quad 3 .zero 8 .long 32 .long 0 .byte 3 .zero 7 .size .Lref.3, 64 .type .Lconst.4,@object .section .data.rel.ro..Lconst.4,"aw",@progbits .p2align 3 .Lconst.4: .quad .Lref.3 .size .Lconst.4, 8 .type __rustc_debug_gdb_scripts_section__,@object .section .debug_gdb_scripts,"aMS",@progbits .weak __rustc_debug_gdb_scripts_section__ __rustc_debug_gdb_scripts_section__: .asciz "\001gdb_load_rust_pretty_printers.py" .size __rustc_debug_gdb_scripts_section__, 34 .hidden _ZN33_$LT$alloc..vec..Vec$LT$T$GT$$GT$3new17hb6ae429368ed332cE .hidden _ZN33_$LT$alloc..vec..Vec$LT$T$GT$$GT$4push17h574bafd95a15ebf0E .hidden _ZN61_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..fmt..Debug$GT$3fmt17hdcb2b03ddacca383E .hidden _ZN4core3fmt10ArgumentV13new17h231294433b1d2ca9E .hidden _ZN4core3fmt9Arguments16new_v1_formatted17h5eb46b1d77c9d642E .hidden _ZN4core3ptr13drop_in_place17h327fe38e616aea9fE .hidden _ZN3std2rt10lang_start17h7216235e6b8b786fE .section .debug_str,"MS",@progbits,1 .Linfo_string0: .asciz "clang LLVM (rustc version 1.25.0-nightly (27a046e93 2018-02-18))" .Linfo_string1: .asciz "src/main.rs" .Linfo_string2: .asciz "/tmp/asmtest" .Linfo_string3: .asciz "asmtest" .Linfo_string4: .asciz "_ZN7asmtest4test17h7e90db8b716e9d37E" .Linfo_string5: .asciz "test" .Linfo_string6: .asciz "_ZN7asmtest4main17hbd02c537ffc5977bE" .Linfo_string7: .asciz "main" .Linfo_string8: .asciz "v" .Linfo_string9: .asciz "alloc" .Linfo_string10: .asciz "vec" .Linfo_string11: .asciz "buf" .Linfo_string12: .asciz "raw_vec" .Linfo_string13: .asciz "ptr" .Linfo_string14: .asciz "core" .Linfo_string15: .asciz "pointer" .Linfo_string16: .asciz "nonzero" .Linfo_string17: .asciz "__0" .Linfo_string18: .asciz "i32" .Linfo_string19: .asciz "*const i32" .Linfo_string20: .asciz "NonZero<*const i32>" .Linfo_string21: .asciz "_marker" .Linfo_string22: .asciz "marker" .Linfo_string23: .asciz "PhantomData"
.Linfo_string24:
.asciz "Unique"
.Linfo_string25:
.asciz "cap"
.Linfo_string26:
.asciz "usize"
.Linfo_string27:
.asciz "a"
.Linfo_string28:
.asciz "heap"
.Linfo_string29:
.asciz "Heap"
.Linfo_string30:
.asciz "RawVec"
.Linfo_string31:
.asciz "len"
.Linfo_string32:
.asciz "Vec"
.Linfo_string33:
.asciz "__arg0"
.Linfo_string34:
.asciz "&alloc::vec::Vec"
.section .debug_abbrev,"",@progbits
.byte 1
.byte 17
.byte 1
.byte 37
.byte 14
.byte 19
.byte 5
.byte 3
.byte 14
.byte 16
.byte 23
.byte 27
.byte 14
.ascii "\264B"
.byte 25
.byte 17
.byte 1
.byte 85
.byte 23
.byte 0
.byte 0
.byte 2
.byte 57
.byte 1
.byte 3
.byte 14
.byte 0
.byte 0
.byte 3
.byte 46
.byte 1
.byte 17
.byte 1
.byte 18
.byte 6
.byte 64
.byte 24
.byte 110
.byte 14
.byte 3
.byte 14
.byte 58
.byte 11
.byte 59
.byte 11
.byte 0
.byte 0
.byte 4
.byte 11
.byte 1
.byte 85
.byte 23
.byte 0
.byte 0
.byte 5
.byte 52
.byte 0
.byte 2
.byte 24
.byte 3
.byte 14
.ascii "\210\001"
.byte 15
.byte 58
.byte 11
.byte 59
.byte 11
.byte 73
.byte 19
.byte 0
.byte 0
.byte 6
.byte 11
.byte 1
.byte 17
.byte 1
.byte 18
.byte 6
.byte 0
.byte 0
.byte 7
.byte 46
.byte 0
.byte 17
.byte 1
.byte 18
.byte 6
.byte 64
.byte 24
.byte 110
.byte 14
.byte 3
.byte 14
.byte 58
.byte 11
.byte 59
.byte 11
.byte 106
.byte 25
.byte 0
.byte 0
.byte 8
.byte 19
.byte 1
.byte 3
.byte 14
.byte 11
.byte 11
.ascii "\210\001"
.byte 15
.byte 0
.byte 0
.byte 9
.byte 13
.byte 0
.byte 3
.byte 14
.byte 73
.byte 19
.ascii "\210\001"
.byte 15
.byte 56
.byte 11
.byte 0
.byte 0
.byte 10
.byte 19
.byte 0
.byte 3
.byte 14
.byte 11
.byte 11
.ascii "\210\001"
.byte 15
.byte 0
.byte 0
.byte 11
.byte 15
.byte 0
.byte 73
.byte 19
.byte 3
.byte 14
.byte 0
.byte 0
.byte 12
.byte 36
.byte 0
.byte 3
.byte 14
.byte 62
.byte 11
.byte 11
.byte 11
.byte 0
.byte 0
.byte 0
.section .debug_info,"",@progbits
.Lcu_begin0:
.long 361
.short 4
.long .debug_abbrev
.byte 8
.byte 1
.long .Linfo_string0
.short 28
.long .Linfo_string1
.long .Lline_table_start0
.long .Linfo_string2
.quad 0
.long .Ldebug_ranges1
.byte 2
.long .Linfo_string3
.byte 3
.quad .Lfunc_begin0
.long .Lfunc_end0-.Lfunc_begin0
.byte 1
.byte 86
.long .Linfo_string4
.long .Linfo_string5
.byte 1
.byte 2
.byte 4
.long .Ldebug_ranges0
.byte 5
.byte 3
.byte 145
.ascii "\210\177"
.long .Linfo_string8
.byte 1
.byte 1
.byte 3
.long 160
.byte 6
.quad .Ltmp18
.long .Ltmp19-.Ltmp18
.byte 5
.byte 2
.byte 145
.byte 104
.long .Linfo_string33
.byte 1
.byte 1
.byte 7
.long 355
.byte 0
.byte 0
.byte 0
.byte 7
.quad .Lfunc_begin1
.long .Lfunc_end1-.Lfunc_begin1
.byte 1
.byte 86
.long .Linfo_string6
.long .Linfo_string7
.byte 1
.byte 9
.byte 0
.byte 2
.long .Linfo_string9
.byte 2
.long .Linfo_string10
.byte 8
.long .Linfo_string32
.byte 24
.byte 8
.byte 9
.long .Linfo_string11
.long 196
.byte 8
.byte 0
.byte 9
.long .Linfo_string31
.long 348
.byte 8
.byte 16
.byte 0
.byte 0
.byte 2
.long .Linfo_string12
.byte 8
.long .Linfo_string30
.byte 16
.byte 8
.byte 9
.long .Linfo_string13
.long 262
.byte 8
.byte 0
.byte 9
.long .Linfo_string25
.long 348
.byte 8
.byte 8
.byte 9
.long .Linfo_string27
.long 243
.byte 1
.byte 0
.byte 0
.byte 0
.byte 2
.long .Linfo_string28
.byte 10
.long .Linfo_string29
.byte 0
.byte 1
.byte 0
.byte 0
.byte 2
.long .Linfo_string14
.byte 2
.long .Linfo_string13
.byte 8
.long .Linfo_string24
.byte 8
.byte 8
.byte 9
.long .Linfo_string15
.long 298
.byte 8
.byte 0
.byte 9
.long .Linfo_string21
.long 323
.byte 1
.byte 0
.byte 0
.byte 0
.byte 2
.long .Linfo_string16
.byte 8
.long .Linfo_string20
.byte 8
.byte 8
.byte 9
.long .Linfo_string17
.long 332
.byte 8
.byte 0
.byte 0
.byte 0
.byte 2
.long .Linfo_string22
.byte 10
.long .Linfo_string23
.byte 0
.byte 1
.byte 0
.byte 0
.byte 11
.long 341
.long .Linfo_string19
.byte 12
.long .Linfo_string18
.byte 5
.byte 4
.byte 12
.long .Linfo_string26
.byte 7
.byte 8
.byte 11
.long 160
.long .Linfo_string34
.byte 0
.section .debug_ranges,"",@progbits
.Ldebug_ranges0:
.quad .Ltmp15
.quad .Ltmp16
.quad .Ltmp17
.quad .Ltmp20
.quad 0
.quad 0
.Ldebug_ranges1:
.quad .Lfunc_begin0
.quad .Lfunc_end0
.quad .Lfunc_begin1
.quad .Lfunc_end1
.quad 0
.quad 0
.section .debug_macinfo,"",@progbits
.Lcu_macro_begin0:
.byte 0
.section .debug_pubnames,"",@progbits
.long .LpubNames_end0-.LpubNames_begin0
.LpubNames_begin0:
.short 2
.long .Lcu_begin0
.long 365
.long 47
.asciz "test"
.long 42
.asciz "asmtest"
.long 318
.asciz "marker"
.long 124
.asciz "main"
.long 257
.asciz "ptr"
.long 191
.asciz "raw_vec"
.long 252
.asciz "core"
.long 150
.asciz "alloc"
.long 293
.asciz "nonzero"
.long 155
.asciz "vec"
.long 238
.asciz "heap"
.long 0
.LpubNames_end0:
.section .debug_pubtypes,"",@progbits
.long .LpubTypes_end0-.LpubTypes_begin0
.LpubTypes_begin0:
.short 2
.long .Lcu_begin0
.long 365
.long 332
.asciz "*const i32"
.long 348
.asciz "usize"
.long 298
.asciz "NonZero<*const i32>"
.long 160
.asciz "Vec"
.long 243
.asciz "Heap"
.long 323
.asciz "PhantomData"
.long 196
.asciz "RawVec"
.long 355
.asciz "&alloc::vec::Vec"
.long 341
.asciz "i32"
.long 262
.asciz "Unique"
.long 0
.LpubTypes_end0:
.hidden DW.ref.rust_eh_personality
.weak DW.ref.rust_eh_personality
.section .data.DW.ref.rust_eh_personality,"aGw",@progbits,DW.ref.rust_eh_personality,comdat
.p2align 3
.type DW.ref.rust_eh_personality,@object
.size DW.ref.rust_eh_personality, 8
DW.ref.rust_eh_personality:
.quad rust_eh_personality
.section ".note.GNU-stack","",@progbits
.section .debug_line,"",@progbits
.Lline_table_start0:
```