<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109227>109227</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DWARF] DWARF verification error with LTO - invalid FileID
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wolfy1961
</td>
</tr>
</table>
<pre>
[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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVt1uqzgQfhrnZhQEBpJwkYv0UHYr7apS1bO9jAwewLvGRrZJ2n36lU3SJv3bY0VAmJlvP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