Bug 91928 - libgccjit fails on subsequent compilations in ipa-cp
Summary: libgccjit fails on subsequent compilations in ipa-cp
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: jit (show other bugs)
Version: 9.2.0
: P3 normal
Target Milestone: ---
Assignee: David Malcolm
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-28 08:33 UTC by Andrea Corallo
Modified: 2019-10-05 09:02 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 10.0
Last reconfirmed:


Attachments
repro.c gziped (3Mb uncompressed) (92.09 KB, application/gzip)
2019-09-28 08:33 UTC, Andrea Corallo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrea Corallo 2019-09-28 08:33:26 UTC
Created attachment 46971 [details]
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.
Comment 1 akrl 2019-10-03 12:40:28 UTC
Author: akrl
Date: Thu Oct  3 12:39:55 2019
New Revision: 276507

URL: https://gcc.gnu.org/viewcvs?rev=276507&root=gcc&view=rev
Log:
PR jit/91928

	* ipa-cp.c (ipa_cp_c_finalize): Release ipcp_transformation_sum.
	* ipa-prop.c (ipcp_free_transformation_sum): New function.
	* ipa-prop.h (ipcp_free_transformation_sum): Add declaration.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-cp.c
    trunk/gcc/ipa-prop.c
    trunk/gcc/ipa-prop.h
Comment 2 akrl 2019-10-05 09:02:57 UTC
Author: akrl
Date: Sat Oct  5 09:02:25 2019
New Revision: 276625

URL: https://gcc.gnu.org/viewcvs?rev=276625&root=gcc&view=rev
Log:
Backport fix for PR jit/91928

gcc/ChangeLog

2019-10-05  Andrea Corallo  <andrea.corallo@arm.com>

	Backport from mainline
	2019-10-03  Andrea Corallo  <andrea.corallo@arm.com>
	* gcc/ipa-cp.c (ipa_cp_c_finalize): Release ipcp_transformation_sum
	when finished.
	* ipa-prop.c (ipcp_free_transformation_sum): New function.
	* ipa-prop.h (ipcp_free_transformation_sum): Add declaration.


Modified:
    branches/gcc-9-branch/gcc/ChangeLog
    branches/gcc-9-branch/gcc/ipa-cp.c
    branches/gcc-9-branch/gcc/ipa-prop.c
    branches/gcc-9-branch/gcc/ipa-prop.h