public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98547] New: GCC spends many minutes instead of seconds building a file with array initialization
@ 2021-01-05 20:33 ilord.tiran at yandex dot ru
  2021-01-05 20:40 ` [Bug c++/98547] " mpolacek at gcc dot gnu.org
  2021-11-25 23:51 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: ilord.tiran at yandex dot ru @ 2021-01-05 20:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98547

            Bug ID: 98547
           Summary: GCC spends many minutes instead of seconds building a
                    file with array initialization
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ilord.tiran at yandex dot ru
  Target Milestone: ---

Hi, GCC Team.

GCC spends a lot of time building the code below, the code in a real project is
compiled for more than an hour. It looks like a GCC has problem with long array
initialization. All versions of GCC that I have tested are affected by this
bug.

GCC/Linux ENV:

$ g++ --version

g++ (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

How to reproduce:

$ time g++ -O3 long_build.cpp -o long_build_gcc

real    6m49,286s
user    6m48,478s
sys     0m0,526s

Clang compiles this code in less than a minute

$ clang++ --version

Ubuntu clang version
11.0.1-++20201126023002+d8e8ae195a2-1~exp1~20201126013616.135
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ time clang++ -O3 long_build.cpp -o long_build_clang

real    0m0,208s
user    0m0,194s
sys     0m0,008s

Output file is huge. It contains copy-paste assembly for each array member
initialization:

proydakov@:~/gcc-bug$ ls -lah
total 1,2M
drwxrwxr-x  2 proydakov proydakov 4,0K янв  5 23:26 .
drwxrwxr-x 19 proydakov proydakov 4,0K ноя 15 22:44 ..
-rwxrwxr-x  1 proydakov proydakov  17K янв  5 22:03 long_build_clang
-rw-rw-r--  1 proydakov proydakov  477 янв  5 23:10 long_build.cpp
-rwxrwxr-x  1 proydakov proydakov 1,2M янв  5 22:48 long_build_gcc
-rw-rw-r--  1 proydakov proydakov  618 янв  5 23:10 long_build.ii

Code snippet:

struct header_t
{
    unsigned msg_id;
    unsigned length;
};
template<typename HEADER, unsigned MTU>
struct packet_t
{
    enum { DATA_SIZE = MTU - sizeof(HEADER) };
    packet_t() : data{}
    {
        header.msg_id = 0;
        header.length = sizeof(HEADER);
    }
    HEADER header;
    char data[DATA_SIZE];
};
struct pool
{
    pool() : packets{}
    {
    }
    packet_t<header_t, 1500> packets[1024 * 16];
};
int main()
{
    pool l;
    return sizeof(l);
}

Best regards, Proydakov Evgeny.

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

* [Bug c++/98547] GCC spends many minutes instead of seconds building a file with array initialization
  2021-01-05 20:33 [Bug c++/98547] New: GCC spends many minutes instead of seconds building a file with array initialization ilord.tiran at yandex dot ru
@ 2021-01-05 20:40 ` mpolacek at gcc dot gnu.org
  2021-11-25 23:51 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-05 20:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98547

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=94957

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Almost surely a dup, perhaps of 94957.

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

* [Bug c++/98547] GCC spends many minutes instead of seconds building a file with array initialization
  2021-01-05 20:33 [Bug c++/98547] New: GCC spends many minutes instead of seconds building a file with array initialization ilord.tiran at yandex dot ru
  2021-01-05 20:40 ` [Bug c++/98547] " mpolacek at gcc dot gnu.org
@ 2021-11-25 23:51 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-25 23:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98547

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes this is a dup of bug 94957.

*** This bug has been marked as a duplicate of bug 94957 ***

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

end of thread, other threads:[~2021-11-25 23:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 20:33 [Bug c++/98547] New: GCC spends many minutes instead of seconds building a file with array initialization ilord.tiran at yandex dot ru
2021-01-05 20:40 ` [Bug c++/98547] " mpolacek at gcc dot gnu.org
2021-11-25 23:51 ` pinskia at gcc dot gnu.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).