From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24588 invoked by alias); 16 Feb 2015 10:06:33 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 24543 invoked by uid 48); 16 Feb 2015 10:06:30 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/65015] LTO produces randomly ordered debug information Date: Mon, 16 Feb 2015 10:06:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg01705.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65015 --- Comment #19 from Richard Biener --- (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 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 for now and try to improve that later. I'm going to test an adjusted patch using in_lto_p again.