This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/81488] New: gcc goes off the limits allocating memory in gimple-ssa-strength-reduction.c


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

            Bug ID: 81488
           Summary: gcc goes off the limits allocating memory in
                    gimple-ssa-strength-reduction.c
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: babokin at gmail dot com
  Target Milestone: ---

Created attachment 41792
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41792&action=edit
reproducer

gcc trunk, rev250217, x86_64.

The attached test case was obtained by reducing the bigger test case with
another SSA problem, which is manifested as the following:
 IMM ERROR : (use_p : tree - 0x7f06c0e56d68:0x7f06c0e56d88)_95049
for SSA_NAME: _95049 in statement:
slsr_55910 = PHI <_95049(199), _95049(200)>
PHI argument
_95049
for PHI node
slsr_55910 = PHI <_95049(199), _95049(200)>
during GIMPLE pass: slsr

Anyway, during the test case reduction (which keep the program at all reduction
steps correct and UB-free) compilation started consuming enormous amount of
memory - basically all available on the machine (128Gb) and crashing after
that. Compilation doesn't take long, it's typically about 2 minutes before it
crashes.

Here's example of the stack while gcc actively allocating memory:


#0  0x00007f7aa06ab70b in __memset_sse2 () from /lib64/libc.so.6
#1  0x0000000000a65e4f in ggc_internal_alloc(unsigned long, void (*)(void*),
unsigned long, unsigned long) () at ../../gcc/gcc/ggc-page.c:1392
#2  0x0000000000f4acd9 in ggc_internal_alloc (s=<optimized out>) at
../../gcc/gcc/ggc.h:130
#3  allocate_phi_node (len=<optimized out>) at
../../gcc/gcc/tree-phinodes.c:117
#4  make_phi_node (len=<optimized out>, var=<optimized out>) at
../../gcc/gcc/tree-phinodes.c:174
#5  create_phi_node(tree_node*, basic_block_def*) () at
../../gcc/gcc/tree-phinodes.c:342
#6  0x000000000159219b in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2405
#7  0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#8  0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#9  0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#10 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#11 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#12 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#13 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#14 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#15 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#16 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#17 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#18 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#19 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#20 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#21 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#22 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#23 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#24 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#25 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#26 0x00000000015926ce in create_phi_basis(slsr_cand_d*, gimple*, tree_node*,
unsigned int, bool) () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:2386
#27 0x0000000001592e29 in replace_conditional_candidate (c=0x2bb6e60) at
../../gcc/gcc/gimple-ssa-strength-reduction.c:2446
#28 replace_uncond_cands_and_profitable_phis(slsr_cand_d*) () at
../../gcc/gcc/gimple-ssa-strength-reduction.c:2545
#29 0x0000000001592c2d in
replace_uncond_cands_and_profitable_phis(slsr_cand_d*) () at
../../gcc/gcc/gimple-ssa-strength-reduction.c:2552
#30 0x0000000001597ff0 in analyze_candidates_and_replace () at
../../gcc/gcc/gimple-ssa-strength-reduction.c:3732
#31 (anonymous namespace)::pass_strength_reduction::execute(function*) () at
../../gcc/gcc/gimple-ssa-strength-reduction.c:3843
#32 0x0000000000dd0cfb in execute_one_pass(opt_pass*) () at
../../gcc/gcc/passes.c:2492
#33 0x0000000000dd1555 in execute_pass_list_1(opt_pass*) () at
../../gcc/gcc/passes.c:2581
#34 0x0000000000dd1567 in execute_pass_list_1(opt_pass*) () at
../../gcc/gcc/passes.c:2582
#35 0x0000000000dd1599 in execute_pass_list(function*, opt_pass*) () at
../../gcc/gcc/passes.c:2592
#36 0x0000000000ae3c80 in cgraph_node::expand() () at
../../gcc/gcc/cgraphunit.c:2052
#37 0x0000000000ae4e01 in expand_all_functions () at
../../gcc/gcc/cgraphunit.c:2188
#38 symbol_table::compile() [clone .part.54] () at
../../gcc/gcc/cgraphunit.c:2540
#39 0x0000000000ae72a7 in compile (this=0x7f7a99f00100) at
../../gcc/gcc/cgraphunit.c:2632
#40 symbol_table::finalize_compilation_unit (this=0x7f7a99f00100) at
../../gcc/gcc/cgraphunit.c:2629
#41 0x0000000000e9e958 in compile_file () at ../../gcc/gcc/toplev.c:493
#42 0x0000000000800526 in do_compile () at ../../gcc/gcc/toplev.c:2021
#43 toplev::main(int, char**) () at ../../gcc/gcc/toplev.c:2155
#44 0x000000000080252b in main (argc=15, argv=0x7ffda4815b68) at
../../gcc/gcc/main.c:39


My point is that some thresholds are obviously missing and gcc should not
consume that much memory. Also, the speed of memory allocation hints that there
might be a bug in the algorithm allocating memory.

To reproduce:
> g++ -std=c++11 -O3 -c func.cpp

Note that -O2 compilation takes just 0.38 seconds and 28Mb on memory.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]