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

            Bug ID: 91928
           Summary: libgccjit fails on subsequent compilations in ipa-cp
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: jit
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: andrea.corallo at arm dot com
  Target Milestone: ---

Created attachment 46971
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46971&action=edit
repro.c gziped (3Mb uncompressed)

libgccjit get ice in subsequent compilations.
the attached reproducer compiles code A then B and then recompiling A crash.
I struggle to create a minimal artificial reproducer so I attach the
auto-generated one that is rather big.
I'm quite sure this is related to static structures we store into
gcc/ipa-prop.c and I'm currently looking into it.

$ gcc repro.c -O0 -g3 -o repro -lgccjit
$ ./repro 
compiling A
compiling B
compiling A
during IPA pass: cp
libgccjit.so: error: in operator[], at vec.h:859
0x7f54abfc412f vec<tree_node*, va_heap, vl_embed>::operator[](unsigned int)
        ../../gcc/vec.h:859
0x7f54abfc412f vec<tree_node*, va_heap, vl_ptr>::operator[](unsigned int)
        ../../gcc/vec.h:1425
0x7f54abfc412f ipcp_update_bits
        ../../gcc/ipa-prop.c:5026
0x7f54abfc412f ipcp_transform_function(cgraph_node*)
        ../../gcc/ipa-prop.c:5202
0x7f54ac6888e4 execute_one_ipa_transform_pass
        ../../gcc/passes.c:2231
0x7f54ac688a59 execute_all_ipa_transforms(bool)
        ../../gcc/passes.c:2270
0x7f54ac107000 cgraph_node::expand()
        ../../gcc/cgraphunit.c:2187
0x7f54ac1076d4 expand_all_functions
        ../../gcc/cgraphunit.c:2332
0x7f54ac1083dc symbol_table::compile()
        ../../gcc/cgraphunit.c:2688
0x7f54ac10887d symbol_table::finalize_compilation_unit()
        ../../gcc/cgraphunit.c:2868
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

This reproducer output was run on the current trunk (gcc 10 37584e9) but I see
it affect at least also the gcc-9-branch.

Reply via email to