On a Ubuntu 22.04 system we get the following verification error from llvm-dwarfdump --verify:
Verifying c.elf: file format elf64-x86-64
Verifying .debug_abbrev...
Verifying .debug_info Unit Header Chain...
Verifying .debug_types Unit Header Chain...
Verifying non-dwo Units...
Verifying unit: 1 / 2, "b.cpp"
error: DIE has DW_AT_decl_file with an invalid file index 1 (valid values are [0-0])
0x00000037: DW_TAG_variable [4] (0x00000029)
DW_AT_name [DW_FORM_strx1] (indexed (00000004) string = "amem")
DW_AT_type [DW_FORM_ref4] (cu + 0x0040 => {0x00000040} "int")
DW_AT_decl_file [DW_FORM_data1] (0x01)
DW_AT_decl_line [DW_FORM_data1] (3)
DW_AT_external [DW_FORM_flag_present] (true)
DW_AT_declaration [DW_FORM_flag_present] (true)
Verifying unit: 2 / 2, "/home/test/a.cpp"
Verifying dwo Units...
Verifying .debug_line...
warning: .debug_line[0x00000043].prologue.file_names[1] is a duplicate of file_names[0]
Verifying .debug_str_offsets...
error: Aggregated error counts:
error: Invalid file index in DW_AT_decl_file occurred 1 time(s).
Errors detected.
The problem seems to be that the IR generated from translation unit "a.cpp" has 2 entries for its source file, one with absolute pathname as filename and the other with a relative pathname. The fact that the absolute pathname for the source is used on the command line is contributing. After IR linking the wrong fileindex is retained.
[repro.zip](https://github.com/user-attachments/files/17052490/repro.zip)
On a Ubuntu 22.04 system we get the following verification error from llvm-dwarfdump --verify:
```
Verifying c.elf: file format elf64-x86-64
Verifying .debug_abbrev...
Verifying .debug_info Unit Header Chain...
Verifying .debug_types Unit Header Chain...
Verifying non-dwo Units...
Verifying unit: 1 / 2, "b.cpp"
error: DIE has DW_AT_decl_file with an invalid file index 1 (valid values are [0-0])
0x00000037: DW_TAG_variable [4] (0x00000029)
DW_AT_name [DW_FORM_strx1] (indexed (00000004) string = "amem")
DW_AT_type [DW_FORM_ref4] (cu + 0x0040 => {0x00000040} "int")
DW_AT_decl_file [DW_FORM_data1] (0x01)
DW_AT_decl_line [DW_FORM_data1] (3)
DW_AT_external [DW_FORM_flag_present] (true)
DW_AT_declaration [DW_FORM_flag_present] (true)
Verifying unit: 2 / 2, "/home/test/a.cpp"
Verifying dwo Units...
Verifying .debug_line...
warning: .debug_line[0x00000043].prologue.file_names[1] is a duplicate of file_names[0]
Verifying .debug_str_offsets...
error: Aggregated error counts:
error: Invalid file index in DW_AT_decl_file occurred 1 time(s).
Errors detected.
```
The problem seems to be that the IR generated from translation unit "a.cpp" has 2 entries for its source file, one with absolute pathname as filename and the other with a relative pathname. The fact that the absolute pathname for the source is used on the command line is contributing. After IR linking the wrong fileindex is retained.
repro.zip
On a Ubuntu 22.04 system we get the following verification error from llvm-dwarfdump --verify:
The problem seems to be that the IR generated from translation unit "a.cpp" has 2 entries for its source file, one with absolute pathname as filename and the other with a relative pathname. The fact that the absolute pathname for the source is used on the command line is contributing. After IR linking the wrong fileindex is retained.