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

Thomas Schwinge <tschwinge at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-08-30
                 CC|                            |tschwinge at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
I once (months ago, and only very briefly) looked into this; here are my notes,
if that's helpful -- probably not too much.  ;-)

If I'm now reading my notes correctly, this appeared with trunk r238432
"Allocate constant size dynamic stack space in the prologue",
<http://mid.mail-archive.com/20151125125610.GA19687@linux.vnet.ibm.com>.

    $ build-gcc/gcc/xgcc -Bbuild-gcc/gcc/
source-gcc/gcc/testsuite/gcc.dg/stack-layout-dynamic-1.c
-fno-diagnostics-show-caret -fdiagnostics-color=never
--sysroot=install/nvptx-none -O0 -fomit-frame-pointer -DSTACK_SIZE=8192
-DNO_TRAMPOLINES -DNO_LABEL_VALUES -DSIGNAL_SUPPRESS -S -isystem
build-gcc/nvptx-none/./newlib/targ-include -isystem
source-gcc/newlib/libc/include -o stack-layout-dynamic-1.s

    $ build-gcc/gcc/xgcc -Bbuild-gcc/gcc/
source-gcc/gcc/testsuite/gcc.dg/stack-layout-dynamic-1.c -O0
-fomit-frame-pointer -S
    [...]/source-gcc/gcc/testsuite/gcc.dg/stack-layout-dynamic-1.c: In function
'foo':
    [...]/source-gcc/gcc/testsuite/gcc.dg/stack-layout-dynamic-1.c:7:6:
internal compiler error: RTL check: expected code 'const_int', have 'reg' in
expand_stack_vars, at cfgexpand.c:1196
    0xaa7607 rtl_check_failed_code1(rtx_def const*, rtx_code, char const*, int,
char const*)
            [...]/source-gcc/gcc/rtl.c:811
    0x6a2c42 expand_stack_vars
            [...]/source-gcc/gcc/cfgexpand.c:1196
    0x6b1146 expand_used_vars
            [...]/source-gcc/gcc/cfgexpand.c:2251
    0x6b2a60 execute
            [...]/source-gcc/gcc/cfgexpand.c:6237

    $ build-gcc-offload-nvptx-none/gcc/xgcc -Bbuild-gcc-offload-nvptx-none/gcc/
source-gcc/gcc/testsuite/gcc.dg/stack-layout-dynamic-1.c -O0
-fomit-frame-pointer -S

    #0  internal_error (gmsgid=gmsgid@entry=0x1219800 "RTL check: expected code
'%s', have '%s' in %s, at %s:%d") at [...]/source-gcc/gcc/diagnostic.c:1335
    #1  0x0000000000abfb48 in rtl_check_failed_code1 (r=r@entry=0x7ffff69c9ac8,
code=<optimized out>, code@entry=CONST_INT, file=<optimized out>,
file@entry=0x11b6a58 "[...]/source-gcc/gcc/cfgexpand.c", line=<optimized out>,
line@entry=1198, func=<optimized out>, func@entry=0x11b85b0
<expand_stack_vars(bool (*)(unsigned long), stack_vars_data*)::__FUNCTION__>
"expand_stack_vars") at [...]/source-gcc/gcc/rtl.c:811
    #2  0x00000000006b6bc2 in expand_stack_vars (pred=pred@entry=0x0,
data=data@entry=0x7fffffffcb50) at [...]/source-gcc/gcc/cfgexpand.c:1198
    #3  0x00000000006c5cf7 in expand_used_vars () at
[...]/source-gcc/gcc/cfgexpand.c:2253
    #4  0x00000000006c6252 in (anonymous namespace)::pass_expand::execute
(this=0x16d3be0, fun=0x7ffff6982b28) at [...]/source-gcc/gcc/cfgexpand.c:6239
    #5  0x0000000000a4942d in execute_one_pass (pass=pass@entry=0x16d3be0) at
[...]/source-gcc/gcc/passes.c:2344
    #6  0x0000000000a49a48 in execute_pass_list_1 (pass=0x16d3be0) at
[...]/source-gcc/gcc/passes.c:2428
    #7  0x0000000000a49aa5 in execute_pass_list (fn=0x7ffff6982b28,
pass=<optimized out>) at [...]/source-gcc/gcc/passes.c:2439
    #8  0x000000000070283d in cgraph_node::expand
(this=this@entry=0x7ffff69c6000) at [...]/source-gcc/gcc/cgraphunit.c:1983
    #9  0x0000000000704274 in expand_all_functions () at
[...]/source-gcc/gcc/cgraphunit.c:2119
    #10 symbol_table::compile (this=this@entry=0x7ffff68d2000) at
[...]/source-gcc/gcc/cgraphunit.c:2477
    #11 0x000000000070646a in symbol_table::finalize_compilation_unit
(this=0x7ffff68d2000) at [...]/source-gcc/gcc/cgraphunit.c:2567
    #12 0x0000000000b12fcd in compile_file () at
[...]/source-gcc/gcc/toplev.c:490
    #13 0x000000000055074b in do_compile () at
[...]/source-gcc/gcc/toplev.c:1998
    #14 toplev::main (this=this@entry=0x7fffffffcf20, argc=argc@entry=20,
argv=argv@entry=0x7fffffffd028) at [...]/source-gcc/gcc/toplev.c:2132
    #15 0x0000000000552407 in main (argc=20, argv=0x7fffffffd028) at
[...]/source-gcc/gcc/main.c:39

    (gdb) frame 2
    #2  0x00000000006b6bc2 in expand_stack_vars (pred=pred@entry=0x0,
data=data@entry=0x7fffffffcb50) at [...]/source-gcc/gcc/cfgexpand.c:1198
    1198                    (INTVAL (large_allocsize),
    (gdb) list
    1193                  rtx large_allocsize;
    1194
    1195                  large_allocsize = GEN_INT (large_size);
    1196                  get_dynamic_stack_size (&large_allocsize, 0,
large_align, NULL);
    1197                  loffset = alloc_stack_frame_space
    1198                    (INTVAL (large_allocsize),
    1199                     PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT);
    1200                  large_base = get_dynamic_stack_base (loffset,
large_align);
    1201                  large_allocation_done = true;
    1202                }
    (gdb) print large_allocsize 
    $1 = (rtx) 0x7ffff69c9ac8
    (gdb) call debug_rtx(large_allocsize)
    (reg:DI 26)
    (gdb) print large_size
    $2 = 66048

Restart with...

    Breakpoint 2, get_dynamic_stack_size (psize=psize@entry=0x7fffffffcaa0,
size_align=size_align@entry=0, required_align=required_align@entry=524288,
pstack_usage_size=pstack_usage_size@entry=0x0) at
[...]/source-gcc/gcc/explow.c:1192
    1192    {
    (gdb) print *psize                           
    $1 = (rtx) 0x7ffff69afb00
    (gdb) call debug_rtx(*psize)                       
    (const_int 66048 [0x10200])

Later, in gcc/explow.c:get_dynamic_stack_size, gcc/explow.c:round_push is
called, which turns the "const_int" into "reg:DI".

This is avoided if removing the MAX_STACK_ALIGNMENT definition from
gcc/config/nvptx/nvptx.h (which seems a bit random indeed; TODO: look up
details), but while removing a bunch of internal compiler errors, that also
causes a bunch of "sorry, unimplemented: target cannot support alloca"
regressions all over the place:

    [-PASS:-]{+FAIL:+} gcc.c-torture/execute/pr65369.c   -O0  (test for excess
errors)
    [-PASS:-]{+UNRESOLVED:+} gcc.c-torture/execute/pr65369.c   -O0  [-execution
test-]
    [-PASS:-]{+compilation failed to produce executable+}
    {+FAIL:+} gcc.c-torture/execute/pr65369.c   -O1  (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gcc.c-torture/execute/pr65369.c   -O1  [-execution
test-]
    [-PASS:-]{+compilation failed to produce executable+}
    {+FAIL:+} gcc.c-torture/execute/pr65369.c   -O2  (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gcc.c-torture/execute/pr65369.c   -O2  [-execution
test-]
    [-PASS:-]{+compilation failed to produce executable+}
    {+FAIL:+} gcc.c-torture/execute/pr65369.c   -O3 -g  (test for excess
errors)
    [-PASS:-]{+UNRESOLVED:+} gcc.c-torture/execute/pr65369.c   -O3 -g 
[-execution test-]
    [-PASS:-]{+compilation failed to produce executable+}
    {+FAIL:+} gcc.c-torture/execute/pr65369.c   -Os  (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gcc.c-torture/execute/pr65369.c   -Os  [-execution
test-]{+compilation failed to produce executable+}

    Running
/scratch/tschwing/nvidiak20-2/openacc/nvptx-trunk-light-work/source-gcc/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp
...
    PASS: tmpdir-gcc.dg-struct-layout-1/t001 c_compat_main_tst.o compile
    [-PASS:-]{+FAIL:+} tmpdir-gcc.dg-struct-layout-1/t001 c_compat_x_tst.o
compile
    [-PASS:-]{+FAIL:+} tmpdir-gcc.dg-struct-layout-1/t001 c_compat_y_tst.o
compile
    [-PASS:-]{+UNRESOLVED:+} tmpdir-gcc.dg-struct-layout-1/t001
c_compat_x_tst.o-c_compat_y_tst.o link 
    [-PASS:-]{+UNRESOLVED:+} tmpdir-gcc.dg-struct-layout-1/t001
c_compat_x_tst.o-c_compat_y_tst.o execute 
    [...]

    [-PASS:-]{+FAIL:+} gcc.dg/pr32293.c (test for excess errors)

    [-PASS:-]{+FAIL:+} gcc.dg/graphite/pr29581-1.c (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gcc.dg/graphite/pr29581-1.c [-execution
test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} gcc.dg/graphite/pr29581-3.c (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gcc.dg/graphite/pr29581-3.c [-execution
test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} gcc.dg/graphite/pr29581-4.c (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gcc.dg/graphite/pr29581-4.c [-execution
test-]{+compilation failed to produce executable+}


    Running
/scratch/tschwing/nvidiak20-2/openacc/nvptx-trunk-light-work/source-gcc/gcc/testsuite/g++.dg/compat/struct-layout-1.exp
...
    PASS: tmpdir-g++.dg-struct-layout-1/t001 cp_compat_main_tst.o compile
    [-PASS:-]{+FAIL:+} tmpdir-g++.dg-struct-layout-1/t001 cp_compat_x_tst.o
compile
    [-PASS:-]{+FAIL:+} tmpdir-g++.dg-struct-layout-1/t001 cp_compat_y_tst.o
compile
    [-FAIL:-]{+UNRESOLVED:+} tmpdir-g++.dg-struct-layout-1/t001
cp_compat_x_tst.o-cp_compat_y_tst.o link 
    {+UNRESOLVED: tmpdir-g++.dg-struct-layout-1/t001
cp_compat_x_tst.o-cp_compat_y_tst.o execute+} 
    [...]

    UNSUPPORTED: g++.dg/cpp0x/gen-attrs-52.C  -std=c++98
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/gen-attrs-52.C  -std=c++11 (test for excess
errors)
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/gen-attrs-52.C  -std=c++14 (test for excess
errors)

    [-PASS:-]{+FAIL:+} g++.dg/opt/20050511-1.C  -std=gnu++98 (test for excess
errors)
    [-PASS:-]{+UNRESOLVED:+} g++.dg/opt/20050511-1.C  -std=gnu++98 [-execution
test-]
    [-PASS:-]{+compilation failed to produce executable+}
    {+FAIL:+} g++.dg/opt/20050511-1.C  -std=gnu++11 (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} g++.dg/opt/20050511-1.C  -std=gnu++11 [-execution
test-]
    [-PASS:-]{+compilation failed to produce executable+}
    {+FAIL:+} g++.dg/opt/20050511-1.C  -std=gnu++14 (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} g++.dg/opt/20050511-1.C  -std=gnu++14 [-execution
test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36444.C   -O0  (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36444.C   -O1  (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36444.C   -O2  (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36444.C   -O3 -g  (test for excess
errors)
    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36444.C   -Os  (test for excess errors)

    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36445.C   -O0  (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36445.C   -O1  (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36445.C   -O2  (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36445.C   -O3 -g  (test for excess
errors)
    [-PASS:-]{+FAIL:+} g++.dg/torture/pr36445.C   -Os  (test for excess errors)

Reply via email to