Bug 91928

Summary: libgccjit fails on subsequent compilations in ipa-cp
Product: gcc Reporter: Andrea Corallo <andrea.corallo>
Component: jitAssignee: David Malcolm <dmalcolm>
Severity: normal    
Priority: P3    
Version: 9.2.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: 10.0 Last reconfirmed: 2020-01-27 00:00:00
Attachments: repro.c gziped (3Mb uncompressed)

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)
0x7f54abfc412f vec<tree_node*, va_heap, vl_ptr>::operator[](unsigned int)
0x7f54abfc412f ipcp_update_bits
0x7f54abfc412f ipcp_transform_function(cgraph_node*)
0x7f54ac6888e4 execute_one_ipa_transform_pass
0x7f54ac688a59 execute_all_ipa_transforms(bool)
0x7f54ac107000 cgraph_node::expand()
0x7f54ac1076d4 expand_all_functions
0x7f54ac1083dc symbol_table::compile()
0x7f54ac10887d symbol_table::finalize_compilation_unit()
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
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.

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
Backport fix for PR jit/91928


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.

Comment 3 Martin Liška 2020-01-27 14:27:17 UTC
Can we please close the issue?
Comment 4 David Malcolm 2020-01-27 14:36:38 UTC
Marking as resolved based on comments 1 and 2; please reopen if it isn't.