public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23477] New: default-initializing array new expression uses memcpy() instead of memset(), bloats executable
@ 2005-08-19  9:21 avi at argo dot co dot il
  2005-08-19 11:35 ` [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: avi at argo dot co dot il @ 2005-08-19  9:21 UTC (permalink / raw)
  To: gcc-bugs

the program 
 
    int main() 
    { 
        new int[10000000](); 
    } 
 
generates a 40MB executable. it compiles into a memcpy() of 40MB of zeros into 
the newly-allocated array. 
 
tested at -O0 and -O3. 
 
gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)

-- 
           Summary: default-initializing array new expression uses memcpy()
                    instead of memset(), bloats executable
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: avi at argo dot co dot il
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23477


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up
  2005-08-19  9:21 [Bug c++/23477] New: default-initializing array new expression uses memcpy() instead of memset(), bloats executable avi at argo dot co dot il
@ 2005-08-19 11:35 ` pinskia at gcc dot gnu dot org
  2005-08-30 10:44 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-19 11:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-19 11:28 -------
This has been semi fixed on the mainline:
main:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %esi
        pushl   %ebx
        subl    $40000000, %esp
        pushl   $40000000
        call    _Znaj
        leal    -40000008(%ebp), %ebx
        pushl   $40000000
        pushl   $0
        pushl   %ebx
        movl    %eax, %esi
        call    memset
        pushl   $40000000
        pushl   %ebx
        pushl   %esi
        call    memcpy
        leal    -8(%ebp), %esp
        xorl    %eax, %eax
        popl    %ebx
        popl    %esi
        popl    %ebp
        ret

But in fact this is worse as the reason for the heap allocation is to avoid  the stack usage at all and now 
there is 40MB allocated on the stack.

The problem is in the middle-end:
  *(int[10000000] *) D.1731 = {};


Note the memcpy is an improvement over what before 4.0.0 had of writting out element by element.

4.1's problem is a regression in terms of stack usage which should not have happen.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |middle-end
     Ever Confirmed|                            |1
  GCC build triplet|i386-redhat-linux           |
   GCC host triplet|i386-redhat-linux           |
 GCC target triplet|i386-redhat-linux           |
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-19 11:28:34
               date|                            |
            Summary|default-initializing array  |[4.1 Regression] default-
                   |new expression uses memcpy()|initializing array new
                   |instead of memset(), bloats |expression uses makes stack
                   |executable                  |usage go way up
   Target Milestone|---                         |4.1.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23477


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up
  2005-08-19  9:21 [Bug c++/23477] New: default-initializing array new expression uses memcpy() instead of memset(), bloats executable avi at argo dot co dot il
  2005-08-19 11:35 ` [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up pinskia at gcc dot gnu dot org
@ 2005-08-30 10:44 ` pinskia at gcc dot gnu dot org
  2005-08-30 11:53 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-30 10:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-30 10:39 -------
*** Bug 23631 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |etienne_lorrain at yahoo dot
                   |                            |fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23477


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up
  2005-08-19  9:21 [Bug c++/23477] New: default-initializing array new expression uses memcpy() instead of memset(), bloats executable avi at argo dot co dot il
  2005-08-19 11:35 ` [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up pinskia at gcc dot gnu dot org
  2005-08-30 10:44 ` pinskia at gcc dot gnu dot org
@ 2005-08-30 11:53 ` rguenth at gcc dot gnu dot org
  2005-08-30 13:31 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-30 11:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at gcc dot gnu dot org  2005-08-30 11:45 -------
I have a patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-08-19 11:28:34         |2005-08-30 11:45:25
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23477


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up
  2005-08-19  9:21 [Bug c++/23477] New: default-initializing array new expression uses memcpy() instead of memset(), bloats executable avi at argo dot co dot il
                   ` (2 preceding siblings ...)
  2005-08-30 11:53 ` rguenth at gcc dot gnu dot org
@ 2005-08-30 13:31 ` rguenth at gcc dot gnu dot org
  2005-08-31 11:22 ` cvs-commit at gcc dot gnu dot org
  2005-08-31 11:43 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-30 13:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at gcc dot gnu dot org  2005-08-30 13:16 -------
Patch submitted.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |08/msg01747.html
           Keywords|                            |patch


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23477


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up
  2005-08-19  9:21 [Bug c++/23477] New: default-initializing array new expression uses memcpy() instead of memset(), bloats executable avi at argo dot co dot il
                   ` (3 preceding siblings ...)
  2005-08-30 13:31 ` rguenth at gcc dot gnu dot org
@ 2005-08-31 11:22 ` cvs-commit at gcc dot gnu dot org
  2005-08-31 11:43 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-08-31 11:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-08-31 11:21 -------
Subject: Bug 23477

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rguenth@gcc.gnu.org	2005-08-31 11:20:48

Modified files:
	gcc            : ChangeLog expr.c 

Log message:
	2005-08-31  Richard Guenther  <rguenther@suse.de>
	
	PR middle-end/23477
	* expr.c (all_zeros_p): New function.
	(expand_expr_real_1): Handle the case of an all-zero
	non-addressable constructor separately.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9855&r2=2.9856
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&r1=1.811&r2=1.812



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23477


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up
  2005-08-19  9:21 [Bug c++/23477] New: default-initializing array new expression uses memcpy() instead of memset(), bloats executable avi at argo dot co dot il
                   ` (4 preceding siblings ...)
  2005-08-31 11:22 ` cvs-commit at gcc dot gnu dot org
@ 2005-08-31 11:43 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-31 11:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at gcc dot gnu dot org  2005-08-31 11:21 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23477


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up
       [not found] <bug-23477-10612@http.gcc.gnu.org/bugzilla/>
@ 2006-01-20 20:51 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-20 20:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2006-01-20 20:51 -------
*** Bug 23631 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23477


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-01-20 20:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-19  9:21 [Bug c++/23477] New: default-initializing array new expression uses memcpy() instead of memset(), bloats executable avi at argo dot co dot il
2005-08-19 11:35 ` [Bug middle-end/23477] [4.1 Regression] default-initializing array new expression uses makes stack usage go way up pinskia at gcc dot gnu dot org
2005-08-30 10:44 ` pinskia at gcc dot gnu dot org
2005-08-30 11:53 ` rguenth at gcc dot gnu dot org
2005-08-30 13:31 ` rguenth at gcc dot gnu dot org
2005-08-31 11:22 ` cvs-commit at gcc dot gnu dot org
2005-08-31 11:43 ` rguenth at gcc dot gnu dot org
     [not found] <bug-23477-10612@http.gcc.gnu.org/bugzilla/>
2006-01-20 20:51 ` pinskia at gcc dot gnu dot org

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).