
Since ce0c205813c74b4225180ac8a6e40fd52ea88229, we are doing that if a single (LTO) compilation contains more than one compile unit, but the same thing can happen if the non-lto and single-cu lto compilations, typically when the CU ends up (nearly) empty. In my case, this happened when LTO emptied two compile units. Note that the source file name is already a part of the hash, so this can only happen when a single file is compiled and linked twice into the same application (most likely with different preprocessor defintiions). While not exactly common, this pattern is used by some C code to implement "templates". The 2017 patch already hinted at the possibility of doing this unconditionally, and this patch implements that. While the DWARF spec hints at the option of using the type signature hashing algorithm for the DWO_id purposes, AFAICT it does not actually require it, so I believe this change is still conforming. The relevant section of the spec is in Section 3.1.2 "Skeleton Compilation Unit Entries" (in non-normative text): ``` The means of determining a compilation unit ID does not need to be similar or related to the means of determining a type unit signature. However, it should be suitable for detecting file version skew or other kinds of mismatched files and for looking up a full split unit in a DWARF package file (see Section 7.3.5 on page 190). ```
19 lines
941 B
LLVM
19 lines
941 B
LLVM
; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
|
|
; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
|
|
|
|
; The source is an empty file, modified to include/retain an 'int' type, since empty CUs are omitted.
|
|
|
|
; CHECK: DW_AT_GNU_dwo_id [DW_FORM_data8] (0xb1b50e9a23896bc1)
|
|
; CHECK: DW_AT_GNU_dwo_id [DW_FORM_data8] (0xb1b50e9a23896bc1)
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
!llvm.module.flags = !{!3, !4}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (trunk 188230) (llvm/trunk 188234)", isOptimized: false, splitDebugFilename: "foo.dwo", emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !5, globals: !2, imports: !2)
|
|
!1 = !DIFile(filename: "foo.c", directory: "/usr/local/google/home/echristo/tmp")
|
|
!2 = !{}
|
|
!3 = !{i32 2, !"Dwarf Version", i32 3}
|
|
!4 = !{i32 1, !"Debug Info Version", i32 3}
|
|
!5 = !{!6}
|
|
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|