From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23282 invoked by alias); 20 Feb 2003 05:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 23262 invoked by uid 71); 20 Feb 2003 05:56:01 -0000 Resent-Date: 20 Feb 2003 05:56:01 -0000 Resent-Message-ID: <20030220055601.23261.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, bkoz@redhat.com Received: (qmail 16854 invoked by uid 48); 20 Feb 2003 05:46:34 -0000 Message-Id: <20030220054634.16853.qmail@sources.redhat.com> Date: Thu, 20 Feb 2003 05:56:00 -0000 From: bkoz@redhat.com Reply-To: bkoz@redhat.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/9767: explicit instantiation of class members unoptimized? X-SW-Source: 2003-02/txt/msg00968.txt.bz2 List-Id: >Number: 9767 >Category: optimization >Synopsis: explicit instantiation of class members unoptimized? >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Feb 20 05:56:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: bkoz@redhat.com >Release: gcc version 3.4 20030217 (experimental), maybe gcc-3.3 >Organization: >Environment: x86/linux >Description: Apparently, explicit instantation of class templates is outputting code for member functions that is not optimized. See below. The codegen for the explicit instantiation of just the write member function is optimized, at -02 and -O1. In particular, the _M_write function is inlined. However, when the same member function is instantiated during the instantiation of the whole class, this member function has substantially different codegen. In particular, the _M_write function is not inlined. The only way to get this same codegen for just the instantiation of the member function itself is to use '-O0'. Ouch. Please help! Sample output below. For just the member function instantiation: _ZNSo5writeEPKci: .LFB1548: pushl %ebp .LCFI0: movl %esp, %ebp .LCFI1: leal -24(%ebp), %eax pushl %esi .LCFI2: pushl %ebx .LCFI3: subl $32, %esp .LCFI4: movl 8(%ebp), %ebx movl %eax, (%esp) movl 16(%ebp), %esi movl %ebx, 4(%esp) .LEHB0: call _ZNSo6sentryC1ERSo .LEHE0: cmpb $0, -24(%ebp) jne .L43 .L2: movl -20(%ebp), %eax movl (%eax), %edx movl -12(%edx), %esi addl %esi, %eax testb $32, 13(%eax) jne .L44 .L40: addl $32, %esp movl %ebx, %eax popl %ebx popl %esi popl %ebp ret .p2align 4,,7 .L43: movl (%ebx), %eax movl -12(%eax), %edx leal (%edx,%ebx), %eax movl 124(%eax), %edx movl 12(%ebp), %eax movl (%edx), %ecx movl %esi, 8(%esp) movl %eax, 4(%esp) movl %edx, (%esp) .LEHB1: call *48(%ecx) cmpl %esi, %eax je .L2 movl (%ebx), %eax movl %ebx, %edx movl -12(%eax), %ecx addl %ecx, %edx movl 20(%edx), %eax movl %edx, (%esp) orl $1, %eax movl %eax, 4(%esp) call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .LEHE1: jmp .L2 .p2align 4,,7 .L44: call _ZSt18uncaught_exceptionv testb %al, %al jne .L40 movl -20(%ebp), %eax movl (%eax), %edx movl -12(%edx), %ecx addl %ecx, %eax movl 124(%eax), %edx testl %edx, %edx je .L40 movl (%edx), %eax movl %edx, (%esp) .LEHB2: call *24(%eax) incl %eax jne .L40 movl -20(%ebp), %eax movl (%eax), %edx movl -12(%edx), %esi addl %esi, %eax movl 20(%eax), %edx movl %eax, (%esp) orl $1, %edx movl %edx, 4(%esp) call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate jmp .L40 .p2align 4,,7 .L41: .L11: movl %eax, %ebx movl -20(%ebp), %eax movl (%eax), %edx movl -12(%edx), %ecx addl %ecx, %eax testb $32, 13(%eax) jne .L45 .L25: .L26: movl %ebx, (%esp) call _Unwind_Resume .LEHE2: .L45: call _ZSt18uncaught_exceptionv testb %al, %al jne .L25 movl -20(%ebp), %eax movl (%eax), %edx movl -12(%edx), %esi addl %esi, %eax movl 124(%eax), %edx testl %edx, %edx je .L25 movl (%edx), %eax movl %edx, (%esp) call *24(%eax) incl %eax jne .L25 movl -20(%ebp), %eax movl (%eax), %edx movl -12(%edx), %ecx addl %ecx, %eax movl 20(%eax), %edx movl %eax, (%esp) orl $1, %edx movl %edx, 4(%esp) call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate jmp .L25 And the same function clipped from the whole class instantiation: _ZNSo5writeEPKci: .LFB1627: pushl %ebp .LCFI124: movl %esp, %ebp .LCFI125: subl $40, %esp .LCFI126: movl %ebx, -8(%ebp) .LCFI127: movl 8(%ebp), %ebx movl %esi, -4(%ebp) .LCFI128: leal -24(%ebp), %esi movl %ebx, 4(%esp) movl %esi, (%esp) .LEHB104: call _ZNSo6sentryC1ERSo .LEHE104: cmpb $0, -24(%ebp) je .L813 movl %ebx, (%esp) movl 16(%ebp), %eax movl %eax, 8(%esp) movl 12(%ebp), %eax movl %eax, 4(%esp) .LEHB105: call _ZNSo8_M_writeEPKci <--------FUCKED .LEHE105: .L813: movl %esi, (%esp) .LEHB106: call _ZNSo6sentryD1Ev .LEHE106: movl %ebx, %eax movl -4(%ebp), %esi movl -8(%ebp), %ebx movl %ebp, %esp popl %ebp ret .p2align 4,,7 .L819: .L815: .L817: movl %esi, (%esp) movl %eax, %ebx call _ZNSo6sentryD1Ev movl %ebx, (%esp) .LEHB107: call _Unwind_Resume >How-To-Repeat: compile the following with '-O2 -S' #include namespace std { #if 1 template basic_ostream& basic_ostream::write(const char*, streamsize); #else template class basic_ostream; #endif } >Fix: >Release-Note: >Audit-Trail: >Unformatted: