GCC Middle and Back End API Reference
stringpool.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tree.h"
#include "cpplib.h"
#include "gt-stringpool.h"
Include dependency graph for stringpool.cc:

Data Structures

struct  string_pool_data
 
struct  string_pool_data_extra
 

Functions

static hashnode alloc_node (cpp_hash_table *)
 
static int mark_ident (struct cpp_reader *, hashnode, const void *)
 
static voidstringpool_ggc_alloc (size_t x)
 
void init_stringpool (void)
 
const charggc_alloc_string (const char *contents, int length MEM_STAT_DECL)
 
tree get_identifier (const char *text)
 
tree get_identifier_with_length (const char *text, size_t length)
 
tree maybe_get_identifier (const char *text)
 
void stringpool_statistics (void)
 
static int maybe_delete_ident (struct cpp_reader *pfile, hashnode h, const void *v)
 
void ggc_mark_stringpool (void)
 
void ggc_purge_stringpool (void)
 
void gt_pch_p_S (void *obj, void *x, gt_pointer_operator op, void *cookie)
 
void gt_pch_n_S (const void *x)
 
void gt_pch_n_S2 (const void *x, size_t string_len)
 
void gt_pch_nx (const char *&x)
 
void gt_pch_nx (char *&x)
 
void gt_pch_nx (unsigned char *&x)
 
void gt_pch_nx (unsigned char &x)
 
void gt_pch_nx (unsigned char *x, gt_pointer_operator op, void *cookie)
 
void gt_pch_save_stringpool (void)
 
void gt_pch_fixup_stringpool (void)
 
void gt_pch_restore_stringpool (void)
 

Variables

struct htident_hash
 
struct htident_hash_extra
 
static struct string_pool_dataspd
 
static struct string_pool_data_extraspd2
 

Function Documentation

◆ alloc_node()

static hashnode alloc_node ( cpp_hash_table * table)
static
Allocate a hash node.   

References GCC_IDENT_TO_HT_IDENT, and make_node().

Referenced by init_stringpool(), and omp_accumulate_sibling_list().

◆ get_identifier()

tree get_identifier ( const char * text)
Return an IDENTIFIER_NODE whose name is TEXT (a null-terminated string).
If an identifier with that name has previously been referred to,
the same node is returned this time.   

References ggc_alloc(), HT_IDENT_TO_GCC_IDENT, and ident_hash.

Referenced by add_builtin_type(), add_detected_attribute_1(), autofdo::afdo_indirect_call(), attr_access::array_as_string(), asan_add_global(), asan_emit_stack_protection(), asan_finish_file(), asan_global_struct(), asan_memfn_rtl(), asan_poison_variables(), assemble_external_libcall(), assign_parms_augmented_arg_list(), build_builtin_function(), build_common_tree_nodes(), build_complex_type(), build_constant_desc(), build_cxa_atexit_decl(), build_dso_handle_decl(), build_fn_decl(), build_gcov_exit_decl(), build_gcov_info_var_registration(), build_info(), build_init_ctor(), build_libfunc_function_visibility(), tree_switch_conversion::switch_conversion::build_one_array(), build_personality_function(), build_var(), cgraph_build_static_cdtor_1(), rt_bb_visited::check(), clone_function_name(), clone_function_name(), clone_function_name_numbered(), common_function_versions(), copy_decl_for_dup_finish(), coverage_obj_finish(), coverage_obj_init(), create_access_replacement(), create_assumption_fn(), function_reader::create_function(), create_loop_fn(), create_odr_indicator(), create_omp_child_function(), create_one_component_var(), create_parallel_loop(), create_tmp_var_name(), cgraph_node::create_virtual_clone(), create_vop_var(), decl_attributes(), declare_weak(), default_emutls_var_fields(), default_external_stack_protect_fail(), default_hidden_stack_protect_fail(), default_mangle_assembler_name(), default_stack_protect_guard(), dw2_force_const_mem(), dwarf2out_register_external_die(), emit_library_call_value_1(), expand_builtin_fork_or_exec(), expand_omp_target(), expand_simd_clones(), finalize_nesting_tree_1(), autofdo::function_instance::find_icall_target_map(), finish_builtin_struct(), gen_block_die(), get_alias_symbol(), get_chain_field(), get_descriptor_type(), get_emutls_object_type(), get_file_function_name(), get_frame_type(), get_gnu_namespace(), get_nl_goto_field(), get_spill_slot_decl(), get_trampoline_type(), gimple_init_gcov_profiler(), gimplify_adjust_omp_clauses_1(), gimplify_bind_expr(), gimplify_oacc_declare(), init_eh(), init_ic_make_global_vars(), init_one_libfunc_visibility(), initialize_sizetypes(), install_var_field(), is_cxx_auto(), lhd_set_decl_assembler_name(), lhd_simulate_enum_decl(), lhd_simulate_record_decl(), lower_omp_critical(), lower_omp_target(), lower_rec_simd_input_clauses(), make_attribute(), make_temp_ssa_name(), oacc_replace_fn_attrib_attr(), omp_discover_declare_target_tgt_fn_r(), omp_discover_declare_target_var_r(), omp_finish_file(), omp_mark_declare_variant(), omp_resolve_declare_variant(), output_comdat_type_unit(), output_comp_unit(), function_reader::parse_mem_expr(), prefix_name(), process_pending_assemble_externals(), push_dummy_function(), read_identifier(), remap_type_1(), rest_of_decl_compilation(), self_referential_size(), set_call_expr_flags(), set_stack_check_libfunc(), set_user_assembler_libfunc(), set_user_assembler_name(), simd_clone_mangle(), strub_set_fndt_mode_to(), tm_mangle(), ubsan_create_data(), ubsan_expand_vptr_ifn(), ubsan_get_source_location_type(), ubsan_get_type_descriptor_type(), and ubsan_type_descriptor().

◆ get_identifier_with_length()

tree get_identifier_with_length ( const char * text,
size_t length )

◆ ggc_alloc_string()

const char * ggc_alloc_string ( const char * contents,
int length MEM_STAT_DECL )
Allocate and return a string constant of length LENGTH, containing
CONTENTS.  If LENGTH is -1, CONTENTS is assumed to be a
nul-terminated string, and the length is calculated using strlen.   

References ggc_alloc(), and ggc_alloc_atomic().

Referenced by gen_interclass_conv_libfunc(), gen_intraclass_conv_libfunc(), gen_libfunc(), gimple_build_asm_1(), output_file_names(), and parse_output_constraint().

◆ ggc_mark_stringpool()

void ggc_mark_stringpool ( void )
Mark the trees hanging off the identifier node for GGC.  These are
handled specially (not using gengtype) because identifiers are only
roots during one part of compilation.   

References ggc_alloc(), ident_hash, ident_hash_extra, mark_ident(), and NULL.

Referenced by ggc_mark_roots().

◆ ggc_purge_stringpool()

void ggc_purge_stringpool ( void )
Purge the identifier hash of identifiers which are no longer
referenced.   

References ggc_alloc(), ggc_marked_p(), ident_hash, ident_hash_extra, maybe_delete_ident(), and NULL.

Referenced by ggc_mark_roots().

◆ gt_pch_fixup_stringpool()

void gt_pch_fixup_stringpool ( void )
Return the stringpool to its state before gt_pch_save_stringpool
was called.   

Referenced by gt_pch_save().

◆ gt_pch_n_S()

void gt_pch_n_S ( const void * x)
PCH pointer-walking routine for strings.   

References CONST_CAST, gt_pch_note_object(), and gt_pch_p_S().

Referenced by gt_pch_nx(), gt_pch_nx(), and gt_pch_nx().

◆ gt_pch_n_S2()

void gt_pch_n_S2 ( const void * x,
size_t string_len )

◆ gt_pch_nx() [1/5]

void gt_pch_nx ( char *& x)

References gt_pch_n_S().

◆ gt_pch_nx() [2/5]

void gt_pch_nx ( const char *& x)
User-callable entry point for marking string X.   

References gt_pch_n_S().

◆ gt_pch_nx() [3/5]

void gt_pch_nx ( unsigned char & x)

◆ gt_pch_nx() [4/5]

void gt_pch_nx ( unsigned char *& x)

References gt_pch_n_S().

◆ gt_pch_nx() [5/5]

void gt_pch_nx ( unsigned char * x,
gt_pointer_operator op,
void * cookie )

References ggc_alloc(), and NULL.

◆ gt_pch_p_S()

void gt_pch_p_S ( void * obj,
void * x,
gt_pointer_operator op,
void * cookie )
Pointer-walking routine for strings (not very interesting, since
strings don't contain pointers).   

References gcc_unreachable.

Referenced by gt_pch_n_S(), gt_pch_n_S2(), gt_pch_note_object(), gt_pch_note_reorder(), and gt_pch_save().

◆ gt_pch_restore_stringpool()

void gt_pch_restore_stringpool ( void )
A PCH file has been restored, which loaded SPD; fill the real hash table
from SPD.   

Referenced by gt_pch_restore().

◆ gt_pch_save_stringpool()

◆ init_stringpool()

void init_stringpool ( void )
Initialize the string pool.   

References alloc_node(), ggc_alloc(), ident_hash, ident_hash_extra, and stringpool_ggc_alloc().

Referenced by general_init().

◆ mark_ident()

static int mark_ident ( struct cpp_reader * pfile,
hashnode h,
const void * v )
static
Mark an identifier for GC.   

References ggc_alloc(), and HT_IDENT_TO_GCC_IDENT.

Referenced by ggc_mark_stringpool().

◆ maybe_delete_ident()

static int maybe_delete_ident ( struct cpp_reader * pfile,
hashnode h,
const void * v )
static
Return true if an identifier should be removed from the table.   

References ggc_alloc(), ggc_marked_p(), and HT_IDENT_TO_GCC_IDENT.

Referenced by ggc_purge_stringpool().

◆ maybe_get_identifier()

tree maybe_get_identifier ( const char * text)
If an identifier with the name TEXT (a null-terminated string) has
previously been referred to, return that node; otherwise return
NULL_TREE.   

References ggc_alloc(), HT_IDENT_TO_GCC_IDENT, ident_hash, and NULL_TREE.

Referenced by assemble_name_resolve(), and dw2_force_const_mem().

◆ stringpool_ggc_alloc()

static void * stringpool_ggc_alloc ( size_t x)
static

References ggc_alloc_atomic().

Referenced by init_stringpool().

◆ stringpool_statistics()

void stringpool_statistics ( void )
Report some basic statistics about the string pool.   

References ggc_alloc(), and ident_hash.

Referenced by dump_memory_report().

Variable Documentation

◆ ident_hash

struct ht* ident_hash
String pool for GCC.
   Copyright (C) 2000-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
String text, identifier text and identifier node allocator.
Identifiers are uniquely stored in a hash table.

We use cpplib's hash table implementation.  libiberty's
hashtab.c is not used because it requires 100% average space
overhead per string, which is unacceptable.  Also, this algorithm
is faster.   

Referenced by get_identifier(), get_identifier_with_length(), ggc_mark_stringpool(), ggc_purge_stringpool(), gt_pch_save_stringpool(), init_stringpool(), maybe_get_identifier(), and stringpool_statistics().

◆ ident_hash_extra

◆ spd

◆ spd2