public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: bkoz@redhat.com To: gcc-gnats@gcc.gnu.org Subject: optimization/9767: explicit instantiation of class members unoptimized? Date: Thu, 20 Feb 2003 05:56:00 -0000 [thread overview] Message-ID: <20030220054634.16853.qmail@sources.redhat.com> (raw) >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 <ostream> namespace std { #if 1 template basic_ostream<char>& basic_ostream<char>::write(const char*, streamsize); #else template class basic_ostream<char>; #endif } >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2003-02-20 5:56 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-02-20 5:56 bkoz [this message] 2003-03-22 5:07 bangerth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20030220054634.16853.qmail@sources.redhat.com \ --to=bkoz@redhat.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).