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

            Bug ID: 85072
           Summary: g++ -O1 consumes all memory
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fabian.loeschner at live dot de
  Target Milestone: ---

Created attachment 43750
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43750&action=edit
Example code to reproduce issue, extracts to approx. 5.3MB

Compiling the attached code (uncompressed: 5MB) consumes more than 12GB memory
with -O1 optimization. I cannot test it with more memory at the moment. Using
-O0 does not result in this issue.

The code is generated code (automated solution of partial differential
equations, FEniCS framework) and consists of 1936 subsequent assignment
statements of the form

    A[i++] = some_double_literal * B[some_index] + other_double_literal *
B[some_index] + ...

with around 90 summands per assignment (> 3000 characters per line).

It is not clear to me which optimizer is specifically responsible for the
issue, as adding all -fno flags that are supposedly different from -O0
(determined using -Q --help=optimizers), i.e.:

-fno-tree-ter -fno-tree-sra -fno-tree-slsr -fno-tree-sink -fno-tree-pta
-fno-tree-fre -fno-tree-dse -fno-tree-dominator-opts -fno-tree-dce
-fno-tree-copy-prop -fno-tree-coalesce-vars -fno-tree-ch -fno-tree-ccp
-fno-tree-builtin-call-dce -fno-tree-bit-ccp -fno-ssa-phiopt
-fno-split-wide-types -fno-shrink-wrap -fno-reorder-blocks
-fno-omit-frame-pointer -fno-move-loop-invariants -fno-ipa-reference
-fno-ipa-pure-const -fno-ipa-profile -fno-inline-functions-called-once
-fno-if-conversion2 -fno-if-conversion -fno-guess-branch-probability
-fno-forward-propagate -fno-defer-pop -fno-cprop-registers -fno-compare-elim
-fno-combine-stack-adjustments -fno-branch-count-reg

only results in slower grow of memory consumption but it still does not
terminate with a sensible amount of memory.

Reply via email to