[Bug lto/65015] LTO produces randomly ordered debug information
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 16 10:06:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65015
--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #18)
> Created attachment 34753 [details]
> A patch
even for -flto-partition=none we produce
45: 0000000000000000 0 FILE LOCAL DEFAULT ABS ccPyi2gu.o
In theory we can also emit a .file directive before each variable/function
we output (from location info). I suppose the debugger consumes them
for backtraces?
Thus produce
.file "test.c"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
call helper
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.file "dependency.c"
.type helper, @function
helper:
.LFB1:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $1, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1:
.size helper, .-helper
.ident "GCC: (GNU) 5.0.0 20150213 (experimental)"
.section .note.GNU-stack,"",@progbits
but appearantly as/ld doesn't handle multiple global .file directives well?
I get
45: 0000000000000000 0 FILE LOCAL DEFAULT ABS dependency.c
46: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.c
47: 00000000004005b1 11 FUNC LOCAL DEFAULT 13 helper
...
71: 00000000004005a6 11 FUNC GLOBAL DEFAULT 13 main
so 'helper' is associated with test.c wrongly(?)
Patch I was playing with (for functions only):
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 220677)
+++ gcc/varasm.c (working copy)
@@ -1713,6 +1713,10 @@ assemble_start_function (tree decl, cons
char tmp_label[100];
bool hot_label_written = false;
+ if (targetm.asm_file_start_file_directive
+ && in_lto_p)
+ output_file_directive (asm_out_file, DECL_SOURCE_FILE (decl));
+
if (flag_reorder_blocks_and_partition)
{
ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LHOTB", const_labelno);
@@ -7042,7 +7046,9 @@ default_file_start (void)
&& !(flag_verbose_asm || flag_debug_asm || flag_dump_rtl_in_asm))
fputs (ASM_APP_OFF, asm_out_file);
- if (targetm.asm_file_start_file_directive)
+ if (targetm.asm_file_start_file_directive
+ /* LTO produced units have no meaningful main_input_filename. */
+ && !in_lto_p)
output_file_directive (asm_out_file, main_input_filename);
}
which shows an alternative to <artificial> by picking a random source
file name via
output_file_directive (asm_out_file, DEC_SOURCE_FILE
(symtab->first_defined_symbol ()->decl));
That said, I think we can go with <artificial> for now and try to improve
that later. I'm going to test an adjusted patch using in_lto_p again.
More information about the Gcc-bugs
mailing list