Skip to content

Commit

Permalink
jit: reset state in varasm.cc [PR117275]
Browse files Browse the repository at this point in the history
PR jit/117275 reports various jit test failures seen on
powerpc64le-unknown-linux-gnu due to hitting this assertion
in varasm.cc on the 2nd compilation in a process:

#2  0x00007ffff63e67d0 in assemble_external_libcall (fun=0x7ffff2a4b1d8)
    at ../../src/gcc/varasm.cc:2650
2650          gcc_assert (!pending_assemble_externals_processed);
(gdb) p pending_assemble_externals_processed
$1 = true

We're not properly resetting state in varasm.cc after a compile
for libgccjit.

Fixed thusly.

gcc/ChangeLog:
	PR jit/117275
	* toplev.cc (toplev::finalize): Call varasm_cc_finalize.
	* varasm.cc (varasm_cc_finalize): New.
	* varasm.h (varasm_cc_finalize): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
  • Loading branch information
davidmalcolm committed Oct 23, 2024
1 parent 9ffcf1f commit 779c039
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions gcc/toplev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,7 @@ toplev::finalize (void)
ira_costs_cc_finalize ();
tree_cc_finalize ();
reginfo_cc_finalize ();
varasm_cc_finalize ();

/* save_decoded_options uses opts_obstack, so these must
be cleaned up together. */
Expand Down
53 changes: 53 additions & 0 deletions gcc/varasm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8854,4 +8854,57 @@ handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED)
switch_to_comdat_section(sect, DECL_NAME (decl));
}

void
varasm_cc_finalize ()
{
first_global_object_name = nullptr;
weak_global_object_name = nullptr;

const_labelno = 0;
size_directive_output = 0;

last_assemble_variable_decl = NULL_TREE;
first_function_block_is_cold = false;
saw_no_split_stack = false;
text_section = nullptr;
data_section = nullptr;
readonly_data_section = nullptr;
sdata_section = nullptr;
ctors_section = nullptr;
dtors_section = nullptr;
bss_section = nullptr;
sbss_section = nullptr;
tls_comm_section = nullptr;
comm_section = nullptr;
lcomm_section = nullptr;
bss_noswitch_section = nullptr;
exception_section = nullptr;
eh_frame_section = nullptr;
in_section = nullptr;
in_cold_section_p = false;
cold_function_name = NULL_TREE;
unnamed_sections = nullptr;
section_htab = nullptr;
object_block_htab = nullptr;
anchor_labelno = 0;
shared_constant_pool = nullptr;
pending_assemble_externals = NULL_TREE;
pending_libcall_symbols = nullptr;

#ifdef ASM_OUTPUT_EXTERNAL
pending_assemble_externals_processed = false;
pending_assemble_externals_set = nullptr;
#endif

weak_decls = NULL_TREE;
initial_trampoline = nullptr;
const_desc_htab = nullptr;
weakref_targets = NULL_TREE;
alias_pairs = nullptr;
tm_clone_hash = nullptr;
trampolines_created = 0;
elf_init_array_section = nullptr;
elf_fini_array_section = nullptr;
}

#include "gt-varasm.h"
2 changes: 2 additions & 0 deletions gcc/varasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ extern rtx assemble_trampoline_template (void);

extern void switch_to_comdat_section (section *, tree);

extern void varasm_cc_finalize ();

#endif // GCC_VARASM_H

0 comments on commit 779c039

Please sign in to comment.