From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10771 invoked by alias); 26 Apr 2006 10:29:26 -0000 Received: (qmail 10750 invoked by uid 22791); 26 Apr 2006 10:29:25 -0000 X-Spam-Check-By: sourceware.org Received: from province.act-europe.fr (HELO province.act-europe.fr) (212.157.227.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 26 Apr 2006 10:29:20 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-province.act-europe.fr (Postfix) with ESMTP id 10A4C4ACFE for ; Wed, 26 Apr 2006 12:29:17 +0200 (CEST) Received: from province.act-europe.fr ([127.0.0.1]) by localhost (province.act-europe.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12183-07 for ; Wed, 26 Apr 2006 12:29:16 +0200 (CEST) Received: from [10.10.0.218] (madrid.act-europe.fr [10.10.0.218]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by province.act-europe.fr (Postfix) with ESMTP id CF13F4ACD3 for ; Wed, 26 Apr 2006 12:29:16 +0200 (CEST) Message-ID: <444F4B7E.7080806@adacore.com> Date: Wed, 26 Apr 2006 14:38:00 -0000 From: Nicolas Roche User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050715) MIME-Version: 1.0 To: binutils@sources.redhat.com Subject: Performance issues with -ffunction-sections and dwarf2 debug line info Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00377.txt.bz2 I am using GCC 3.4 and the -ffunction-sections -fdata-sections options along with binutils 2.16.1 (for dead code elimination) When using this functions the debug line info is no more sorted (increasing line and increasing vma) and so on big files with lots of functions you can observe a quadratic behavior for the time needed to read this info (addr2line, ...). The reason is that we are almost always triggering the worst case in add_line_info function in bfd/dwarf2.c. The problem is in gas. Indeed in dwarf2dbg.c a list of sections is maintained (all_segs), but each time a new section is created, it is appended to the beginning of the list.... so if you have the following source: 1 begin function1 2 3 end function1 4 begin function2 5 6 end function2 the line information will be sorted in the following order: 4,5,6,1,2,3 In order to solve this issue we just have to append to the tail of all_segs. Here is the patch I would like to submit to the head and if it is still possible to the binutils 2.17 branch. Thanks in advance for your comments Nicolas Index: dwarf2dbg.c =================================================================== RCS file: /cvs/src/src/gas/dwarf2dbg.c,v retrieving revision 1.81 diff -r1.81 dwarf2dbg.c 128c128,131 < static struct line_seg *all_segs; --- > static struct line_seg *all_segs = NULL; > > /* Pointer to the last item in all_segs. NULL if all_segs is empty */ > static struct line_seg *all_segs_last = NULL; 223c226 < s->next = all_segs; --- > s->next = NULL; 226c229,245 < all_segs = s; --- > > /* Append s at the end of the all_segs list. Appending it to the head is > not recommended as this will break the line debug info order (when > compiling using -ffunction-sections). Ensuring that line appears in order > with increasing VMAs helps reading that info afterward from a > performance point of view (see comments in add_line_info (bfd/dwarf2.c). > */ > if (all_segs_last) > { > all_segs_last->next = s; > all_segs_last = s; > } > else > { > all_segs = s; > all_segs_last = s; > }