From 8813a647b5f81fb32955f8ec2438d73e9e6280d4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sun, 9 Oct 2016 13:19:48 +0200 Subject: [PATCH] tree-ssa.c (target_for_debug_bind, [...]): Use VAR_P and/or VAR_OR_FUNCTION_DECL_P macros. * tree-ssa.c (target_for_debug_bind, verify_phi_args, ssa_undefined_value_p, maybe_optimize_var): Use VAR_P and/or VAR_OR_FUNCTION_DECL_P macros. * tree-chkp.c (chkp_register_var_initializer, chkp_make_static_bounds, chkp_get_bounds_for_decl_addr, chkp_parse_array_and_component_ref, chkp_find_bounds_1): Likewise. * ipa-polymorphic-call.c (decl_maybe_in_construction_p): Likewise. * hsa-gen.c (get_symbol_for_decl): Likewise. * cgraphunit.c (check_global_declaration, analyze_functions, handle_alias_pairs, thunk_adjust, cgraph_node::expand_thunk): Likewise. * gimple-fold.c (can_refer_decl_in_current_unit_p, canonicalize_constructor_val, gimple_get_virt_method_for_vtable): Likewise. * tree.c (set_decl_section_name, copy_node_stat, need_assembler_name_p, free_lang_data_in_decl, find_decls_types_r, merge_dllimport_decl_attributes, handle_dll_attribute, decl_init_priority_insert, auto_var_in_fn_p, array_at_struct_end_p, verify_type): Likewise. * gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior, find_explicit_erroneous_behavior): Likewise. * sdbout.c (sdbout_toplevel_data, sdbout_late_global_decl): Likewise. * ipa.c (process_references): Likewise. * tree-chkp-opt.c (chkp_get_check_result): Likewise. * varasm.c (get_block_for_decl, use_blocks_for_decl_p, make_decl_rtl, notice_global_symbol, assemble_variable, mark_decl_referenced, build_constant_desc, output_constant_def_contents, do_assemble_alias, make_decl_one_only, default_section_type_flags, categorize_decl_for_section, default_encode_section_info): Likewise. * trans-mem.c (requires_barrier): Likewise. * gimple-expr.c (mark_addressable): Likewise. * cfgexpand.c (add_scope_conflicts_1, expand_one_var, expand_used_vars_for_block, clear_tree_used, stack_protect_decl_p, expand_debug_expr): Likewise. * tree-dump.c (dequeue_and_dump): Likewise. * ubsan.c (instrument_bool_enum_load): Likewise. * tree-pretty-print.c (print_declaration): Likewise. * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise. * tree-ssa-uninit.c (warn_uninitialized_vars): Likewise. * asan.c (asan_protect_global, instrument_derefs): Likewise. * tree-into-ssa.c (rewrite_stmt, maybe_register_def, pass_build_ssa::execute): Likewise. * var-tracking.c (var_debug_decl, track_expr_p): Likewise. * tree-ssa-loop-ivopts.c (force_expr_to_var_cost, split_address_cost): Likewise. * ipa-split.c (test_nonssa_use, consider_split, mark_nonssa_use): Likewise. * tree-inline.c (insert_debug_decl_map, remap_ssa_name, can_be_nonlocal, remap_decls, copy_debug_stmt, initialize_inlined_parameters, add_local_variables, reset_debug_binding, replace_locals_op): Likewise. * dse.c (can_escape): Likewise. * ipa-devirt.c (compare_virtual_tables, referenced_from_vtable_p): Likewise. * tree-diagnostic.c (default_tree_printer): Likewise. * tree-streamer-in.c (unpack_ts_decl_common_value_fields, unpack_ts_decl_with_vis_value_fields, lto_input_ts_decl_common_tree_pointers): Likewise. * builtins.c (builtin_save_expr, fold_builtin_expect, readonly_data_expr): Likewise. * tree-ssa-structalias.c (new_var_info, get_constraint_for_ssa_var, create_variable_info_for, set_uids_in_ptset, visit_loadstore): Likewise. * gimple-streamer-out.c (output_gimple_stmt): Likewise. * gimplify.c (force_constant_size, gimplify_bind_expr, gimplify_decl_expr, gimplify_var_or_parm_decl, gimplify_compound_lval, gimplify_init_constructor, gimplify_modify_expr, gimplify_asm_expr, gimplify_oacc_declare, gimplify_type_sizes): Likewise. * cgraphbuild.c (record_reference, record_type_list, mark_address, mark_load, mark_store, pass_build_cgraph_edges::execute): Likewise. * tree-ssa-live.c (mark_all_vars_used_1, remove_unused_scope_block_p, remove_unused_locals): Likewise. * tree-ssa-alias.c (ptr_deref_may_alias_decl_p, ptrs_compare_unequal, ref_maybe_used_by_call_p_1, call_may_clobber_ref_p_1): Likewise. * function.c (instantiate_expr, instantiate_decls_1, setjmp_vars_warning, add_local_decl): Likewise. * alias.c (ao_ref_from_mem, get_alias_set, compare_base_symbol_refs): Likewise. * tree-stdarg.c (find_va_list_reference, va_list_counter_struct_op, va_list_ptr_read, va_list_ptr_write, check_all_va_list_escapes, optimize_va_list_gpr_fpr_size): Likewise. * tree-nrv.c (pass_nrv::execute): Likewise. * tsan.c (instrument_expr): Likewise. * tree-ssa-dce.c (remove_dead_stmt): Likewise. * vtable-verify.c (verify_bb_vtables): Likewise. * tree-dfa.c (ssa_default_def, set_ssa_default_def, get_ref_base_and_extent): Likewise. * toplev.c (wrapup_global_declaration_1, wrapup_global_declaration_2): Likewise. * tree-sra.c (static bool constant_decl_p, find_var_candidates, analyze_all_variable_accesses): Likewise. * tree-nested.c (get_nonlocal_debug_decl, convert_nonlocal_omp_clauses, note_nonlocal_vla_type, note_nonlocal_block_vlas, convert_nonlocal_reference_stmt, get_local_debug_decl, convert_local_omp_clauses, convert_local_reference_stmt, nesting_copy_decl, remap_vla_decls): Likewise. * tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Likewise. * stmt.c (decl_overlaps_hard_reg_set_p): Likewise. * dbxout.c (dbxout_late_global_decl, dbxout_type_fields, dbxout_symbol, dbxout_common_check): Likewise. * expr.c (expand_assignment, expand_expr_real_2, expand_expr_real_1, string_constant): Likewise. * hsa.c (hsa_get_declaration_name): Likewise. * passes.c (rest_of_decl_compilation): Likewise. * tree-ssanames.c (make_ssa_name_fn): Likewise. * tree-streamer-out.c (pack_ts_decl_common_value_fields, pack_ts_decl_with_vis_value_fields, write_ts_decl_common_tree_pointers): Likewise. * stor-layout.c (place_field): Likewise. * symtab.c (symtab_node::maybe_create_reference, symtab_node::verify_base, symtab_node::make_decl_local, symtab_node::copy_visibility_from, symtab_node::can_increase_alignment_p): Likewise. * dwarf2out.c (add_var_loc_to_decl, tls_mem_loc_descriptor, decl_by_reference_p, reference_to_unused, rtl_for_decl_location, fortran_common, add_location_or_const_value_attribute, add_scalar_info, add_linkage_name, set_block_abstract_flags, local_function_static, gen_variable_die, dwarf2out_late_global_decl, optimize_one_addr_into_implicit_ptr, optimize_location_into_implicit_ptr): Likewise. * gimple-low.c (record_vars_into): Likewise. * ipa-visibility.c (update_vtable_references): Likewise. * tree-ssa-address.c (fixed_address_object_p, copy_ref_info): Likewise. * lto-streamer-out.c (tree_is_indexable, get_symbol_initial_value, DFS::DFS_write_tree_body, write_symbol): Likewise. * langhooks.c (lhd_warn_unused_global_decl, lhd_set_decl_assembler_name): Likewise. * attribs.c (decl_attributes): Likewise. * except.c (output_ttype): Likewise. * varpool.c (varpool_node::get_create, ctor_for_folding, varpool_node::assemble_decl, varpool_node::create_alias): Likewise. * fold-const.c (fold_unary_loc): Likewise. * ipa-prop.c (ipa_compute_jump_functions_for_edge, ipa_find_agg_cst_from_init): Likewise. * omp-low.c (expand_omp_regimplify_p, expand_omp_taskreg, expand_omp_target, lower_omp_regimplify_p, grid_reg_assignment_to_local_var_p, grid_remap_prebody_decls, find_link_var_op): Likewise. * tree-chrec.c (chrec_contains_symbols): Likewise. * tree-cfg.c (verify_address, verify_expr, verify_expr_location_1, gimple_duplicate_bb, move_stmt_op, replace_block_vars_by_duplicates, execute_fixup_cfg): Likewise. From-SVN: r240900 --- gcc/ChangeLog | 146 +++++++++++++++++++++++++++++++++ gcc/alias.c | 6 +- gcc/asan.c | 4 +- gcc/attribs.c | 2 +- gcc/builtins.c | 8 +- gcc/cfgexpand.c | 20 ++--- gcc/cgraphbuild.c | 14 ++-- gcc/cgraphunit.c | 14 ++-- gcc/dbxout.c | 10 +-- gcc/dse.c | 2 +- gcc/dwarf2out.c | 51 ++++++------ gcc/except.c | 2 +- gcc/expr.c | 16 ++-- gcc/fold-const.c | 2 +- gcc/function.c | 9 +- gcc/gimple-expr.c | 2 +- gcc/gimple-fold.c | 12 ++- gcc/gimple-low.c | 2 +- gcc/gimple-ssa-isolate-paths.c | 6 +- gcc/gimple-streamer-out.c | 2 +- gcc/gimplify.c | 33 ++++---- gcc/hsa-gen.c | 9 +- gcc/hsa.c | 2 +- gcc/ipa-devirt.c | 6 +- gcc/ipa-polymorphic-call.c | 2 +- gcc/ipa-prop.c | 4 +- gcc/ipa-split.c | 10 +-- gcc/ipa-visibility.c | 3 +- gcc/ipa.c | 2 +- gcc/langhooks.c | 4 +- gcc/lto-streamer-out.c | 17 ++-- gcc/omp-low.c | 20 ++--- gcc/passes.c | 6 +- gcc/sdbout.c | 6 +- gcc/simplify-rtx.c | 2 +- gcc/stmt.c | 2 +- gcc/stor-layout.c | 2 +- gcc/symtab.c | 14 ++-- gcc/toplev.c | 6 +- gcc/trans-mem.c | 2 +- gcc/tree-cfg.c | 26 +++--- gcc/tree-chkp-opt.c | 2 +- gcc/tree-chkp.c | 20 ++--- gcc/tree-chrec.c | 2 +- gcc/tree-dfa.c | 7 +- gcc/tree-diagnostic.c | 2 +- gcc/tree-dump.c | 3 +- gcc/tree-inline.c | 32 +++----- gcc/tree-into-ssa.c | 7 +- gcc/tree-nested.c | 28 +++---- gcc/tree-nrv.c | 2 +- gcc/tree-pretty-print.c | 4 +- gcc/tree-sra.c | 7 +- gcc/tree-ssa-address.c | 7 +- gcc/tree-ssa-alias.c | 14 ++-- gcc/tree-ssa-dce.c | 2 +- gcc/tree-ssa-live.c | 12 ++- gcc/tree-ssa-loop-ivopts.c | 4 +- gcc/tree-ssa-structalias.c | 14 ++-- gcc/tree-ssa-uninit.c | 2 +- gcc/tree-ssa.c | 9 +- gcc/tree-ssanames.c | 2 +- gcc/tree-stdarg.c | 12 +-- gcc/tree-streamer-in.c | 14 ++-- gcc/tree-streamer-out.c | 14 ++-- gcc/tree-vect-data-refs.c | 2 +- gcc/tree.c | 40 ++++----- gcc/tsan.c | 4 +- gcc/ubsan.c | 2 +- gcc/var-tracking.c | 7 +- gcc/varasm.c | 50 ++++++----- gcc/varpool.c | 15 ++-- gcc/vtable-verify.c | 2 +- 73 files changed, 460 insertions(+), 392 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 02a286806ee..efa0b76539e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,151 @@ 2016-10-09 Jakub Jelinek + * tree-ssa.c (target_for_debug_bind, verify_phi_args, + ssa_undefined_value_p, maybe_optimize_var): Use VAR_P and/or + VAR_OR_FUNCTION_DECL_P macros. + * tree-chkp.c (chkp_register_var_initializer, chkp_make_static_bounds, + chkp_get_bounds_for_decl_addr, chkp_parse_array_and_component_ref, + chkp_find_bounds_1): Likewise. + * ipa-polymorphic-call.c (decl_maybe_in_construction_p): Likewise. + * hsa-gen.c (get_symbol_for_decl): Likewise. + * cgraphunit.c (check_global_declaration, analyze_functions, + handle_alias_pairs, thunk_adjust, cgraph_node::expand_thunk): + Likewise. + * gimple-fold.c (can_refer_decl_in_current_unit_p, + canonicalize_constructor_val, gimple_get_virt_method_for_vtable): + Likewise. + * tree.c (set_decl_section_name, copy_node_stat, + need_assembler_name_p, free_lang_data_in_decl, find_decls_types_r, + merge_dllimport_decl_attributes, handle_dll_attribute, + decl_init_priority_insert, auto_var_in_fn_p, array_at_struct_end_p, + verify_type): Likewise. + * gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior, + find_explicit_erroneous_behavior): Likewise. + * sdbout.c (sdbout_toplevel_data, sdbout_late_global_decl): Likewise. + * ipa.c (process_references): Likewise. + * tree-chkp-opt.c (chkp_get_check_result): Likewise. + * varasm.c (get_block_for_decl, use_blocks_for_decl_p, make_decl_rtl, + notice_global_symbol, assemble_variable, mark_decl_referenced, + build_constant_desc, output_constant_def_contents, do_assemble_alias, + make_decl_one_only, default_section_type_flags, + categorize_decl_for_section, default_encode_section_info): Likewise. + * trans-mem.c (requires_barrier): Likewise. + * gimple-expr.c (mark_addressable): Likewise. + * cfgexpand.c (add_scope_conflicts_1, expand_one_var, + expand_used_vars_for_block, clear_tree_used, stack_protect_decl_p, + expand_debug_expr): Likewise. + * tree-dump.c (dequeue_and_dump): Likewise. + * ubsan.c (instrument_bool_enum_load): Likewise. + * tree-pretty-print.c (print_declaration): Likewise. + * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise. + * tree-ssa-uninit.c (warn_uninitialized_vars): Likewise. + * asan.c (asan_protect_global, instrument_derefs): Likewise. + * tree-into-ssa.c (rewrite_stmt, maybe_register_def, + pass_build_ssa::execute): Likewise. + * var-tracking.c (var_debug_decl, track_expr_p): Likewise. + * tree-ssa-loop-ivopts.c (force_expr_to_var_cost, split_address_cost): + Likewise. + * ipa-split.c (test_nonssa_use, consider_split, mark_nonssa_use): + Likewise. + * tree-inline.c (insert_debug_decl_map, remap_ssa_name, + can_be_nonlocal, remap_decls, copy_debug_stmt, + initialize_inlined_parameters, add_local_variables, + reset_debug_binding, replace_locals_op): Likewise. + * dse.c (can_escape): Likewise. + * ipa-devirt.c (compare_virtual_tables, referenced_from_vtable_p): + Likewise. + * tree-diagnostic.c (default_tree_printer): Likewise. + * tree-streamer-in.c (unpack_ts_decl_common_value_fields, + unpack_ts_decl_with_vis_value_fields, + lto_input_ts_decl_common_tree_pointers): Likewise. + * builtins.c (builtin_save_expr, fold_builtin_expect, + readonly_data_expr): Likewise. + * tree-ssa-structalias.c (new_var_info, get_constraint_for_ssa_var, + create_variable_info_for, set_uids_in_ptset, visit_loadstore): + Likewise. + * gimple-streamer-out.c (output_gimple_stmt): Likewise. + * gimplify.c (force_constant_size, gimplify_bind_expr, + gimplify_decl_expr, gimplify_var_or_parm_decl, + gimplify_compound_lval, gimplify_init_constructor, + gimplify_modify_expr, gimplify_asm_expr, gimplify_oacc_declare, + gimplify_type_sizes): Likewise. + * cgraphbuild.c (record_reference, record_type_list, mark_address, + mark_load, mark_store, pass_build_cgraph_edges::execute): Likewise. + * tree-ssa-live.c (mark_all_vars_used_1, remove_unused_scope_block_p, + remove_unused_locals): Likewise. + * tree-ssa-alias.c (ptr_deref_may_alias_decl_p, ptrs_compare_unequal, + ref_maybe_used_by_call_p_1, call_may_clobber_ref_p_1): Likewise. + * function.c (instantiate_expr, instantiate_decls_1, + setjmp_vars_warning, add_local_decl): Likewise. + * alias.c (ao_ref_from_mem, get_alias_set, compare_base_symbol_refs): + Likewise. + * tree-stdarg.c (find_va_list_reference, va_list_counter_struct_op, + va_list_ptr_read, va_list_ptr_write, check_all_va_list_escapes, + optimize_va_list_gpr_fpr_size): Likewise. + * tree-nrv.c (pass_nrv::execute): Likewise. + * tsan.c (instrument_expr): Likewise. + * tree-ssa-dce.c (remove_dead_stmt): Likewise. + * vtable-verify.c (verify_bb_vtables): Likewise. + * tree-dfa.c (ssa_default_def, set_ssa_default_def, + get_ref_base_and_extent): Likewise. + * toplev.c (wrapup_global_declaration_1, wrapup_global_declaration_2): + Likewise. + * tree-sra.c (static bool constant_decl_p, find_var_candidates, + analyze_all_variable_accesses): Likewise. + * tree-nested.c (get_nonlocal_debug_decl, + convert_nonlocal_omp_clauses, note_nonlocal_vla_type, + note_nonlocal_block_vlas, convert_nonlocal_reference_stmt, + get_local_debug_decl, convert_local_omp_clauses, + convert_local_reference_stmt, nesting_copy_decl, remap_vla_decls): + Likewise. + * tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Likewise. + * stmt.c (decl_overlaps_hard_reg_set_p): Likewise. + * dbxout.c (dbxout_late_global_decl, dbxout_type_fields, + dbxout_symbol, dbxout_common_check): Likewise. + * expr.c (expand_assignment, expand_expr_real_2, expand_expr_real_1, + string_constant): Likewise. + * hsa.c (hsa_get_declaration_name): Likewise. + * passes.c (rest_of_decl_compilation): Likewise. + * tree-ssanames.c (make_ssa_name_fn): Likewise. + * tree-streamer-out.c (pack_ts_decl_common_value_fields, + pack_ts_decl_with_vis_value_fields, + write_ts_decl_common_tree_pointers): Likewise. + * stor-layout.c (place_field): Likewise. + * symtab.c (symtab_node::maybe_create_reference, + symtab_node::verify_base, symtab_node::make_decl_local, + symtab_node::copy_visibility_from, + symtab_node::can_increase_alignment_p): Likewise. + * dwarf2out.c (add_var_loc_to_decl, tls_mem_loc_descriptor, + decl_by_reference_p, reference_to_unused, rtl_for_decl_location, + fortran_common, add_location_or_const_value_attribute, + add_scalar_info, add_linkage_name, set_block_abstract_flags, + local_function_static, gen_variable_die, dwarf2out_late_global_decl, + optimize_one_addr_into_implicit_ptr, + optimize_location_into_implicit_ptr): Likewise. + * gimple-low.c (record_vars_into): Likewise. + * ipa-visibility.c (update_vtable_references): Likewise. + * tree-ssa-address.c (fixed_address_object_p, copy_ref_info): + Likewise. + * lto-streamer-out.c (tree_is_indexable, get_symbol_initial_value, + DFS::DFS_write_tree_body, write_symbol): Likewise. + * langhooks.c (lhd_warn_unused_global_decl, + lhd_set_decl_assembler_name): Likewise. + * attribs.c (decl_attributes): Likewise. + * except.c (output_ttype): Likewise. + * varpool.c (varpool_node::get_create, ctor_for_folding, + varpool_node::assemble_decl, varpool_node::create_alias): Likewise. + * fold-const.c (fold_unary_loc): Likewise. + * ipa-prop.c (ipa_compute_jump_functions_for_edge, + ipa_find_agg_cst_from_init): Likewise. + * omp-low.c (expand_omp_regimplify_p, expand_omp_taskreg, + expand_omp_target, lower_omp_regimplify_p, + grid_reg_assignment_to_local_var_p, grid_remap_prebody_decls, + find_link_var_op): Likewise. + * tree-chrec.c (chrec_contains_symbols): Likewise. + * tree-cfg.c (verify_address, verify_expr, verify_expr_location_1, + gimple_duplicate_bb, move_stmt_op, replace_block_vars_by_duplicates, + execute_fixup_cfg): Likewise. + PR tree-optimization/77901 * tree-ssa-reassoc.c (optimize_range_tests_var_bound): Only optimize if ranges[i].exp is SSA_NAME when looking for >= and only when diff --git a/gcc/alias.c b/gcc/alias.c index 277125e01ae..19e9208ac97 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -310,7 +310,7 @@ ao_ref_from_mem (ao_ref *ref, const_rtx mem) /* If this is a reference based on a partitioned decl replace the base with a MEM_REF of the pointer representative we created during stack slot partitioning. */ - if (TREE_CODE (base) == VAR_DECL + if (VAR_P (base) && ! is_global_var (base) && cfun->gimple_df->decls_to_pointers != NULL) { @@ -870,7 +870,7 @@ get_alias_set (tree t) /* If we've already determined the alias set for a decl, just return it. This is necessary for C++ anonymous unions, whose component variables don't look like union members (boo!). */ - if (TREE_CODE (t) == VAR_DECL + if (VAR_P (t) && DECL_RTL_SET_P (t) && MEM_P (DECL_RTL (t))) return MEM_ALIAS_SET (DECL_RTL (t)); @@ -2087,7 +2087,7 @@ compare_base_symbol_refs (const_rtx x_base, const_rtx y_base) return -1; /* Anchors contains static VAR_DECLs and CONST_DECLs. We are safe to ignore CONST_DECLs because they are readonly. */ - if (TREE_CODE (x_decl) != VAR_DECL + if (!VAR_P (x_decl) || (!TREE_STATIC (x_decl) && !TREE_PUBLIC (x_decl))) return 0; diff --git a/gcc/asan.c b/gcc/asan.c index 4fe2447fe7f..3a4b5f708dc 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1351,7 +1351,7 @@ asan_protect_global (tree decl) return false; return true; } - if (TREE_CODE (decl) != VAR_DECL + if (!VAR_P (decl) /* TLS vars aren't statically protectable. */ || DECL_THREAD_LOCAL_P (decl) /* Externs will be protected elsewhere. */ @@ -1810,7 +1810,7 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, || bitsize != size_in_bytes * BITS_PER_UNIT) return; - if (TREE_CODE (inner) == VAR_DECL + if (VAR_P (inner) && offset == NULL_TREE && bitpos >= 0 && DECL_SIZE (inner) diff --git a/gcc/attribs.c b/gcc/attribs.c index 9a886214ec4..e66349a1325 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -553,7 +553,7 @@ decl_attributes (tree *node, tree attributes, int flags) /* Layout the decl in case anything changed. */ if (spec->type_required && DECL_P (*node) - && (TREE_CODE (*node) == VAR_DECL + && (VAR_P (*node) || TREE_CODE (*node) == PARM_DECL || TREE_CODE (*node) == RESULT_DECL)) relayout_decl (*node); diff --git a/gcc/builtins.c b/gcc/builtins.c index facecd3cfef..6c68198fcc5 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -691,7 +691,7 @@ builtin_save_expr (tree exp) if (TREE_CODE (exp) == SSA_NAME || (TREE_ADDRESSABLE (exp) == 0 && (TREE_CODE (exp) == PARM_DECL - || (TREE_CODE (exp) == VAR_DECL && !TREE_STATIC (exp))))) + || (VAR_P (exp) && !TREE_STATIC (exp))))) return exp; return save_expr (exp); @@ -7141,9 +7141,7 @@ fold_builtin_expect (location_t loc, tree arg0, tree arg1, tree arg2) } while (TREE_CODE (inner) == COMPONENT_REF || TREE_CODE (inner) == ARRAY_REF); - if ((TREE_CODE (inner) == VAR_DECL - || TREE_CODE (inner) == FUNCTION_DECL) - && DECL_WEAK (inner)) + if (VAR_OR_FUNCTION_DECL_P (inner) && DECL_WEAK (inner)) return NULL_TREE; } @@ -8813,7 +8811,7 @@ readonly_data_expr (tree exp) understand). */ if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR - || (TREE_CODE (exp) == VAR_DECL && TREE_STATIC (exp))) + || (VAR_P (exp) && TREE_STATIC (exp))) return decl_readonly_section (exp, 0); else return false; diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 4190f7f0aed..c7a2faa7200 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -576,7 +576,7 @@ add_scope_conflicts_1 (basic_block bb, bitmap work, bool for_conflict) size_t *v; /* Nested function lowering might introduce LHSs that are COMPONENT_REFs. */ - if (TREE_CODE (lhs) != VAR_DECL) + if (!VAR_P (lhs)) continue; if (DECL_RTL_IF_SET (lhs) == pc_rtx && (v = decl_to_stack_part->get (lhs))) @@ -1571,7 +1571,7 @@ expand_one_var (tree var, bool toplevel, bool really_expand) var = SSAVAR (var); - if (TREE_TYPE (var) != error_mark_node && TREE_CODE (var) == VAR_DECL) + if (TREE_TYPE (var) != error_mark_node && VAR_P (var)) { if (is_global_var (var)) return 0; @@ -1608,7 +1608,7 @@ expand_one_var (tree var, bool toplevel, bool really_expand) if (TREE_CODE (origvar) == SSA_NAME) { - gcc_assert (TREE_CODE (var) != VAR_DECL + gcc_assert (!VAR_P (var) || (!DECL_EXTERNAL (var) && !DECL_HAS_VALUE_EXPR_P (var) && !TREE_STATIC (var) @@ -1616,7 +1616,7 @@ expand_one_var (tree var, bool toplevel, bool really_expand) && !DECL_HARD_REGISTER (var) && really_expand)); } - if (TREE_CODE (var) != VAR_DECL && TREE_CODE (origvar) != SSA_NAME) + if (!VAR_P (var) && TREE_CODE (origvar) != SSA_NAME) ; else if (DECL_EXTERNAL (var)) ; @@ -1631,7 +1631,7 @@ expand_one_var (tree var, bool toplevel, bool really_expand) if (really_expand) expand_one_error_var (var); } - else if (TREE_CODE (var) == VAR_DECL && DECL_HARD_REGISTER (var)) + else if (VAR_P (var) && DECL_HARD_REGISTER (var)) { if (really_expand) { @@ -1689,7 +1689,7 @@ expand_used_vars_for_block (tree block, bool toplevel) /* Expand all variables at this level. */ for (t = BLOCK_VARS (block); t ; t = DECL_CHAIN (t)) if (TREE_USED (t) - && ((TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != RESULT_DECL) + && ((!VAR_P (t) && TREE_CODE (t) != RESULT_DECL) || !DECL_NONSHAREABLE (t))) expand_one_var (t, toplevel, true); @@ -1708,7 +1708,7 @@ clear_tree_used (tree block) for (t = BLOCK_VARS (block); t ; t = DECL_CHAIN (t)) /* if (!TREE_STATIC (t) && !DECL_EXTERNAL (t)) */ - if ((TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != RESULT_DECL) + if ((!VAR_P (t) && TREE_CODE (t) != RESULT_DECL) || !DECL_NONSHAREABLE (t)) TREE_USED (t) = 0; @@ -1984,7 +1984,7 @@ stack_protect_decl_p () if (!is_global_var (var)) { tree var_type = TREE_TYPE (var); - if (TREE_CODE (var) == VAR_DECL + if (VAR_P (var) && (TREE_CODE (var_type) == ARRAY_TYPE || TREE_ADDRESSABLE (var) || (RECORD_OR_UNION_TYPE_P (var_type) @@ -4275,7 +4275,7 @@ expand_debug_expr (tree exp) /* This decl was probably optimized away. */ if (!op0) { - if (TREE_CODE (exp) != VAR_DECL + if (!VAR_P (exp) || DECL_EXTERNAL (exp) || !TREE_STATIC (exp) || !DECL_NAME (exp) @@ -4876,7 +4876,7 @@ expand_debug_expr (tree exp) tree decl = get_ref_base_and_extent (TREE_OPERAND (exp, 0), &bitoffset, &bitsize, &maxsize, &reverse); - if ((TREE_CODE (decl) == VAR_DECL + if ((VAR_P (decl) || TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL) && (!TREE_ADDRESSABLE (decl) diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index 52ab840a0ed..4df5fe0ce4d 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -77,7 +77,7 @@ record_reference (tree *tp, int *walk_subtrees, void *data) ctx->varpool_node->create_reference (node, IPA_REF_ADDR); } - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { varpool_node *vnode = varpool_node::get_create (decl); ctx->varpool_node->create_reference (vnode, IPA_REF_ADDR); @@ -114,7 +114,7 @@ record_type_list (cgraph_node *node, tree list) if (TREE_CODE (type) == ADDR_EXPR) { type = TREE_OPERAND (type, 0); - if (TREE_CODE (type) == VAR_DECL) + if (VAR_P (type)) { varpool_node *vnode = varpool_node::get_create (type); node->create_reference (vnode, IPA_REF_ADDR); @@ -219,7 +219,7 @@ mark_address (gimple *stmt, tree addr, tree, void *data) node->mark_address_taken (); ((symtab_node *)data)->create_reference (node, IPA_REF_ADDR, stmt); } - else if (addr && TREE_CODE (addr) == VAR_DECL + else if (addr && VAR_P (addr) && (TREE_STATIC (addr) || DECL_EXTERNAL (addr))) { varpool_node *vnode = varpool_node::get_create (addr); @@ -244,8 +244,7 @@ mark_load (gimple *stmt, tree t, tree, void *data) node->mark_address_taken (); ((symtab_node *)data)->create_reference (node, IPA_REF_ADDR, stmt); } - else if (t && TREE_CODE (t) == VAR_DECL - && (TREE_STATIC (t) || DECL_EXTERNAL (t))) + else if (t && VAR_P (t) && (TREE_STATIC (t) || DECL_EXTERNAL (t))) { varpool_node *vnode = varpool_node::get_create (t); @@ -260,8 +259,7 @@ static bool mark_store (gimple *stmt, tree t, tree, void *data) { t = get_base_address (t); - if (t && TREE_CODE (t) == VAR_DECL - && (TREE_STATIC (t) || DECL_EXTERNAL (t))) + if (t && VAR_P (t) && (TREE_STATIC (t) || DECL_EXTERNAL (t))) { varpool_node *vnode = varpool_node::get_create (t); @@ -369,7 +367,7 @@ pass_build_cgraph_edges::execute (function *fun) /* Look for initializers of constant variables and private statics. */ FOR_EACH_LOCAL_DECL (fun, ix, decl) - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) && !DECL_EXTERNAL (decl)) && !DECL_HAS_VALUE_EXPR_P (decl) && TREE_TYPE (decl) != error_mark_node) diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index e38f0bf4e86..abcb35dea63 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -662,7 +662,7 @@ symbol_table::process_same_body_aliases (void) FOR_EACH_SYMBOL (node) if (node->cpp_implicit_alias && !node->analyzed) node->resolve_alias - (TREE_CODE (node->alias_target) == VAR_DECL + (VAR_P (node->alias_target) ? (symtab_node *)varpool_node::get_create (node->alias_target) : (symtab_node *)cgraph_node::get_create (node->alias_target)); cpp_implicit_aliases_done = true; @@ -950,7 +950,7 @@ check_global_declaration (symtab_node *snode) && (decl_file = DECL_SOURCE_FILE (decl)) != NULL && filename_cmp (main_input_filename, decl_file) == 0)))) - && TREE_CODE (decl) == VAR_DECL)) + && VAR_P (decl))) && ! DECL_IN_SYSTEM_HEADER (decl) && ! snode->referred_to_p (/*include_self=*/false) /* This TREE_USED check is needed in addition to referred_to_p @@ -967,7 +967,7 @@ check_global_declaration (symtab_node *snode) /* A volatile variable might be used in some non-obvious way. */ && (! VAR_P (decl) || ! TREE_THIS_VOLATILE (decl)) /* Global register variables must be declared to reserve them. */ - && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) + && ! (VAR_P (decl) && DECL_REGISTER (decl)) /* Global ctors and dtors are called by the runtime. */ && (TREE_CODE (decl) != FUNCTION_DECL || (!DECL_STATIC_CONSTRUCTOR (decl) @@ -1194,7 +1194,7 @@ analyze_functions (bool first_time) at looking at optimized away DECLs, since late_global_decl will subsequently be called from the contents of the now pruned symbol table. */ - if (TREE_CODE (node->decl) == VAR_DECL + if (VAR_P (node->decl) && !decl_function_context (node->decl)) { /* We are reclaiming totally unreachable code and variables @@ -1305,7 +1305,7 @@ handle_alias_pairs (void) cgraph_node::create_alias (p->decl, target_node->decl); alias_pairs->unordered_remove (i); } - else if (TREE_CODE (p->decl) == VAR_DECL + else if (VAR_P (p->decl) && target_node && is_a (target_node)) { varpool_node::create_alias (p->decl, target_node->decl); @@ -1559,7 +1559,7 @@ thunk_adjust (gimple_stmt_iterator * bsi, { tree ptrtmp; - if (TREE_CODE (ptr) == VAR_DECL) + if (VAR_P (ptr)) ptrtmp = ptr; else { @@ -1738,7 +1738,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk) { restmp = resdecl; - if (TREE_CODE (restmp) == VAR_DECL) + if (VAR_P (restmp)) add_local_decl (cfun, restmp); BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp; } diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 9aa156750aa..52307f3cd3e 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -1333,7 +1333,7 @@ dbxout_early_global_decl (tree decl ATTRIBUTE_UNUSED) static void dbxout_late_global_decl (tree decl) { - if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl)) + if (VAR_P (decl) && !DECL_EXTERNAL (decl)) { int saved_tree_used = TREE_USED (decl); TREE_USED (decl) = 1; @@ -1511,7 +1511,7 @@ dbxout_type_fields (tree type) && DECL_BIT_FIELD_TYPE (tem)) ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0); - if (TREE_CODE (tem) == VAR_DECL) + if (VAR_P (tem)) { if (TREE_STATIC (tem) && use_gnu_debug_info_extensions) { @@ -2610,7 +2610,7 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED) if (flag_debug_only_used_symbols && (!TREE_USED (decl) - && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl)))) + && (!VAR_P (decl) || !DECL_INITIAL (decl)))) DBXOUT_DECR_NESTING_AND_RETURN (0); /* If dbxout_init has not yet run, queue this symbol for later. */ @@ -2865,7 +2865,7 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED) /* PARM_DECLs go in their own separate chain and are output by dbxout_reg_parms and dbxout_parms, except for those that are disguised VAR_DECLs like Out parameters in Ada. */ - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); /* fall through */ @@ -3272,7 +3272,7 @@ dbxout_common_check (tree decl, int *value) ??? DECL_THREAD_LOCAL_P check prevents problems with improper .stabs for thread-local symbols. Can be handled via same mechanism as used in dwarf2out.c. */ - if (TREE_CODE (decl) != VAR_DECL + if (!VAR_P (decl) || !TREE_STATIC (decl) || !DECL_HAS_VALUE_EXPR_P (decl) || DECL_THREAD_LOCAL_P (decl) diff --git a/gcc/dse.c b/gcc/dse.c index 17312c5a587..9d222a947a1 100644 --- a/gcc/dse.c +++ b/gcc/dse.c @@ -911,7 +911,7 @@ can_escape (tree expr) base = get_base_address (expr); if (DECL_P (base) && !may_be_aliased (base) - && !(TREE_CODE (base) == VAR_DECL + && !(VAR_P (base) && !DECL_EXTERNAL (base) && !TREE_STATIC (base) && local_variable_can_escape (base))) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 23eaebcc370..4a3df339df2 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -5359,8 +5359,7 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label) struct var_loc_node *loc = NULL; HOST_WIDE_INT bitsize = -1, bitpos = -1; - if (TREE_CODE (decl) == VAR_DECL - && DECL_HAS_DEBUG_EXPR_P (decl)) + if (VAR_P (decl) && DECL_HAS_DEBUG_EXPR_P (decl)) { tree realdecl = DECL_DEBUG_EXPR (decl); if (handled_component_p (realdecl) @@ -12385,7 +12384,7 @@ tls_mem_loc_descriptor (rtx mem) base = get_base_address (MEM_EXPR (mem)); if (base == NULL - || TREE_CODE (base) != VAR_DECL + || !VAR_P (base) || !DECL_THREAD_LOCAL_P (base)) return NULL; @@ -14632,7 +14631,7 @@ static bool decl_by_reference_p (tree decl) { return ((TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL - || TREE_CODE (decl) == VAR_DECL) + || VAR_P (decl)) && DECL_BY_REFERENCE (decl)); } @@ -17261,10 +17260,9 @@ reference_to_unused (tree * tp, int * walk_subtrees, /* ??? The C++ FE emits debug information for using decls, so putting gcc_unreachable here falls over. See PR31899. For now be conservative. */ - else if (!symtab->global_info_ready - && (TREE_CODE (*tp) == VAR_DECL || TREE_CODE (*tp) == FUNCTION_DECL)) + else if (!symtab->global_info_ready && VAR_OR_FUNCTION_DECL_P (*tp)) return *tp; - else if (TREE_CODE (*tp) == VAR_DECL) + else if (VAR_P (*tp)) { varpool_node *node = varpool_node::get (*tp); if (!node || !node->definition) @@ -17472,7 +17470,7 @@ rtl_for_decl_location (tree decl) || (MEM_P (rtl) && CONSTANT_P (XEXP (rtl, 0))) || (REG_P (rtl) - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && TREE_STATIC (decl)))) { rtl = targetm.delegitimize_address (rtl); @@ -17554,7 +17552,7 @@ rtl_for_decl_location (tree decl) plus_constant (addr_mode, XEXP (rtl, 0), offset)); } } - else if (TREE_CODE (decl) == VAR_DECL + else if (VAR_P (decl) && rtl && MEM_P (rtl) && GET_MODE (rtl) != TYPE_MODE (TREE_TYPE (decl)) @@ -17579,7 +17577,7 @@ rtl_for_decl_location (tree decl) /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant, and will have been substituted directly into all expressions that use it. C does not have such a concept, but C++ and other languages do. */ - if (!rtl && TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl)) + if (!rtl && VAR_P (decl) && DECL_INITIAL (decl)) rtl = rtl_for_decl_init (DECL_INITIAL (decl), TREE_TYPE (decl)); if (rtl) @@ -17595,7 +17593,7 @@ rtl_for_decl_location (tree decl) in the current CU, resolve_addr will remove the expression referencing it. */ if (rtl == NULL_RTX - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && !DECL_EXTERNAL (decl) && TREE_STATIC (decl) && DECL_NAME (decl) @@ -17629,7 +17627,7 @@ fortran_common (tree decl, HOST_WIDE_INT *value) it does not have a value (the offset into the common area), or if it is thread local (as opposed to global) then it isn't common, and shouldn't be handled as such. */ - if (TREE_CODE (decl) != VAR_DECL + if (!VAR_P (decl) || !TREE_STATIC (decl) || !DECL_HAS_VALUE_EXPR_P (decl) || !is_fortran ()) @@ -17643,7 +17641,7 @@ fortran_common (tree decl, HOST_WIDE_INT *value) &unsignedp, &reversep, &volatilep); if (cvar == NULL_TREE - || TREE_CODE (cvar) != VAR_DECL + || !VAR_P (cvar) || DECL_ARTIFICIAL (cvar) || !TREE_PUBLIC (cvar)) return NULL_TREE; @@ -17695,7 +17693,7 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, bool cache_p) || get_AT (die, DW_AT_const_value)) return true; - gcc_assert (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL + gcc_assert (VAR_P (decl) || TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL); /* Try to get some constant RTL for this decl, and use that as the value of @@ -17958,10 +17956,8 @@ tree_add_const_value_attribute_for_decl (dw_die_ref var_die, tree decl) { if (!decl - || (TREE_CODE (decl) != VAR_DECL - && TREE_CODE (decl) != CONST_DECL) - || (TREE_CODE (decl) == VAR_DECL - && !TREE_STATIC (decl))) + || (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL) + || (VAR_P (decl) && !TREE_STATIC (decl))) return false; if (TREE_READONLY (decl) @@ -18303,7 +18299,7 @@ add_scalar_info (dw_die_ref die, enum dwarf_attribute attr, tree value, && TREE_CODE (TREE_OPERAND (value, 1)) == FIELD_DECL) decl = TREE_OPERAND (value, 1); - else if (TREE_CODE (value) == VAR_DECL + else if (VAR_P (value) || TREE_CODE (value) == PARM_DECL || TREE_CODE (value) == RESULT_DECL) decl = value; @@ -18839,9 +18835,9 @@ static void add_linkage_name (dw_die_ref die, tree decl) { if (debug_info_level > DINFO_LEVEL_NONE - && (TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL) + && VAR_OR_FUNCTION_DECL_P (decl) && TREE_PUBLIC (decl) - && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) + && !(VAR_P (decl) && DECL_REGISTER (decl)) && die->die_tag != DW_TAG_member) add_linkage_name_raw (die, decl); } @@ -20121,7 +20117,7 @@ set_block_abstract_flags (tree stmt, vec &abstract_vec) for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++) { local_decl = BLOCK_NONLOCALIZED_VAR (stmt, i); - if ((TREE_CODE (local_decl) == VAR_DECL && !TREE_STATIC (local_decl)) + if ((VAR_P (local_decl) && !TREE_STATIC (local_decl)) || TREE_CODE (local_decl) == PARM_DECL) set_decl_abstract_flags (local_decl, abstract_vec); } @@ -21205,7 +21201,7 @@ decl_will_get_specification_p (dw_die_ref old_die, tree decl, bool declaration) static inline bool local_function_static (tree decl) { - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); return TREE_STATIC (decl) && DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL; @@ -21456,7 +21452,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die) /* Local static vars are shared between all clones/inlines, so emit DW_AT_location on the abstract DIE if DECL_RTL is already set. */ - || (TREE_CODE (decl_or_origin) == VAR_DECL + || (VAR_P (decl_or_origin) && TREE_STATIC (decl_or_origin) && DECL_RTL_SET_P (decl_or_origin))) /* When abstract origin already has DW_AT_location attribute, no need @@ -23889,8 +23885,7 @@ dwarf2out_late_global_decl (tree decl) { /* Fill-in any location information we were unable to determine on the first pass. */ - if (TREE_CODE (decl) == VAR_DECL - && !POINTER_BOUNDS_P (decl)) + if (VAR_P (decl) && !POINTER_BOUNDS_P (decl)) { dw_die_ref die = lookup_decl_die (decl); @@ -26649,7 +26644,7 @@ optimize_one_addr_into_implicit_ptr (dw_loc_descr_ref loc) if (GET_CODE (rtl) == SYMBOL_REF && SYMBOL_REF_DECL (rtl)) { decl = SYMBOL_REF_DECL (rtl); - if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl)) + if (VAR_P (decl) && !DECL_EXTERNAL (decl)) { ref = lookup_decl_die (decl); if (ref && (get_AT (ref, DW_AT_location) @@ -26811,7 +26806,7 @@ resolve_addr_in_expr (dw_loc_descr_ref loc) static void optimize_location_into_implicit_ptr (dw_die_ref die, tree decl) { - if (TREE_CODE (decl) != VAR_DECL + if (!VAR_P (decl) || lookup_decl_die (decl) != die || DECL_EXTERNAL (decl) || !TREE_STATIC (decl) diff --git a/gcc/except.c b/gcc/except.c index bc6f30cc920..800ca2a27ba 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -2898,7 +2898,7 @@ output_ttype (tree type, int tt_format, int tt_format_size) if (TREE_CODE (type) == ADDR_EXPR) { type = TREE_OPERAND (type, 0); - if (TREE_CODE (type) == VAR_DECL) + if (VAR_P (type)) is_public = TREE_PUBLIC (type); } else diff --git a/gcc/expr.c b/gcc/expr.c index 2256ac9309a..e6d110dd027 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -5186,7 +5186,7 @@ expand_assignment (tree to, tree from, bool nontemporal) if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from, from) && COMPLETE_TYPE_P (TREE_TYPE (from)) && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) == INTEGER_CST - && ! (((TREE_CODE (to) == VAR_DECL + && ! (((VAR_P (to) || TREE_CODE (to) == PARM_DECL || TREE_CODE (to) == RESULT_DECL) && REG_P (DECL_RTL (to))) @@ -8421,7 +8421,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, if (TREE_CODE (treeop0) == PLUS_EXPR && TREE_CODE (TREE_OPERAND (treeop0, 1)) == INTEGER_CST - && TREE_CODE (treeop1) == VAR_DECL + && VAR_P (treeop1) && (DECL_RTL (treeop1) == frame_pointer_rtx || DECL_RTL (treeop1) == stack_pointer_rtx || DECL_RTL (treeop1) == arg_pointer_rtx)) @@ -10201,8 +10201,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, && modifier != EXPAND_MEMORY && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array) && TREE_CODE (index) == INTEGER_CST - && (TREE_CODE (array) == VAR_DECL - || TREE_CODE (array) == CONST_DECL) + && (VAR_P (array) || TREE_CODE (array) == CONST_DECL) && (init = ctor_for_folding (array)) != error_mark_node) { if (init == NULL_TREE) @@ -11112,8 +11111,7 @@ string_constant (tree arg, tree *ptr_offset) { array = TREE_OPERAND (TREE_OPERAND (arg, 0), 0); offset = TREE_OPERAND (TREE_OPERAND (arg, 0), 1); - if (TREE_CODE (array) != STRING_CST - && TREE_CODE (array) != VAR_DECL) + if (TREE_CODE (array) != STRING_CST && !VAR_P (array)) return 0; /* Check if the array has a nonzero lower bound. */ @@ -11137,8 +11135,7 @@ string_constant (tree arg, tree *ptr_offset) if (TREE_CODE (array) != ADDR_EXPR) return 0; array = TREE_OPERAND (array, 0); - if (TREE_CODE (array) != STRING_CST - && TREE_CODE (array) != VAR_DECL) + if (TREE_CODE (array) != STRING_CST && !VAR_P (array)) return 0; } else @@ -11177,8 +11174,7 @@ string_constant (tree arg, tree *ptr_offset) *ptr_offset = fold_convert (sizetype, offset); return array; } - else if (TREE_CODE (array) == VAR_DECL - || TREE_CODE (array) == CONST_DECL) + else if (VAR_P (array) || TREE_CODE (array) == CONST_DECL) { int length; tree init = ctor_for_folding (array); diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 65c75f63931..02aa484a727 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7942,7 +7942,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) if (TREE_CODE (op0) == ADDR_EXPR) { tree op00 = TREE_OPERAND (op0, 0); - if ((TREE_CODE (op00) == VAR_DECL + if ((VAR_P (op00) || TREE_CODE (op00) == PARM_DECL || TREE_CODE (op00) == RESULT_DECL) && !TREE_READONLY (op00)) diff --git a/gcc/function.c b/gcc/function.c index 94ed786dbc7..cdd2721cdf9 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -1826,8 +1826,7 @@ instantiate_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) if (TREE_CODE (t) == PARM_DECL && DECL_NAMELESS (t) && DECL_INCOMING_RTL (t)) instantiate_decl_rtl (DECL_INCOMING_RTL (t)); - if ((TREE_CODE (t) == VAR_DECL - || TREE_CODE (t) == RESULT_DECL) + if ((VAR_P (t) || TREE_CODE (t) == RESULT_DECL) && DECL_HAS_VALUE_EXPR_P (t)) { tree v = DECL_VALUE_EXPR (t); @@ -1850,7 +1849,7 @@ instantiate_decls_1 (tree let) { if (DECL_RTL_SET_P (t)) instantiate_decl_rtl (DECL_RTL (t)); - if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t)) + if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t)) { tree v = DECL_VALUE_EXPR (t); walk_tree (&v, instantiate_expr, NULL, NULL); @@ -4374,7 +4373,7 @@ setjmp_vars_warning (bitmap setjmp_crosses, tree block) for (decl = BLOCK_VARS (block); decl; decl = DECL_CHAIN (decl)) { - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && DECL_RTL_SET_P (decl) && REG_P (DECL_RTL (decl)) && regno_clobbered_at_setjmp (setjmp_crosses, REGNO (DECL_RTL (decl)))) @@ -6581,7 +6580,7 @@ match_asm_constraints_1 (rtx_insn *insn, rtx *p_sets, int noutputs) void add_local_decl (struct function *fun, tree d) { - gcc_assert (TREE_CODE (d) == VAR_DECL); + gcc_assert (VAR_P (d)); vec_safe_push (fun->local_decls, d); } diff --git a/gcc/gimple-expr.c b/gcc/gimple-expr.c index ed012ccfdc6..de5cce1f7cc 100644 --- a/gcc/gimple-expr.c +++ b/gcc/gimple-expr.c @@ -888,7 +888,7 @@ mark_addressable (tree x) if (TREE_CODE (x) == MEM_REF && TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR) x = TREE_OPERAND (TREE_OPERAND (x, 0), 0); - if (TREE_CODE (x) != VAR_DECL + if (!VAR_P (x) && TREE_CODE (x) != PARM_DECL && TREE_CODE (x) != RESULT_DECL) return; diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 59c4cb80a36..3aaa09c0bef 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -105,7 +105,7 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl) /* We are concerned only about static/external vars and functions. */ if ((!TREE_STATIC (decl) && !DECL_EXTERNAL (decl)) - || (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)) + || !VAR_OR_FUNCTION_DECL_P (decl)) return true; /* Static objects can be referred only if they was not optimized out yet. */ @@ -126,7 +126,7 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl) So we are concerned only when DECL comes from initializer of external var or var that has been optimized out. */ if (!from_decl - || TREE_CODE (from_decl) != VAR_DECL + || !VAR_P (from_decl) || (!DECL_EXTERNAL (from_decl) && (vnode = varpool_node::get (from_decl)) != NULL && vnode->definition) @@ -206,13 +206,12 @@ canonicalize_constructor_val (tree cval, tree from_decl) if (!base) return NULL_TREE; - if ((TREE_CODE (base) == VAR_DECL - || TREE_CODE (base) == FUNCTION_DECL) + if (VAR_OR_FUNCTION_DECL_P (base) && !can_refer_decl_in_current_unit_p (base, from_decl)) return NULL_TREE; if (TREE_TYPE (base) == error_mark_node) return NULL_TREE; - if (TREE_CODE (base) == VAR_DECL) + if (VAR_P (base)) TREE_ADDRESSABLE (base) = 1; else if (TREE_CODE (base) == FUNCTION_DECL) { @@ -6057,8 +6056,7 @@ gimple_get_virt_method_for_vtable (HOST_WIDE_INT token, *can_refer = true; /* First of all double check we have virtual table. */ - if (TREE_CODE (v) != VAR_DECL - || !DECL_VIRTUAL_P (v)) + if (!VAR_P (v) || !DECL_VIRTUAL_P (v)) { /* Pass down that we lost track of the target. */ if (can_refer) diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index 1bccf44e5d7..8e98762e6fd 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -885,7 +885,7 @@ record_vars_into (tree vars, tree fn) /* BIND_EXPRs contains also function/type/constant declarations we don't need to care about. */ - if (TREE_CODE (var) != VAR_DECL) + if (!VAR_P (var)) continue; /* Nothing to do in this case. */ diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c index bee3f9a4b3e..9d2fc8a30c0 100644 --- a/gcc/gimple-ssa-isolate-paths.c +++ b/gcc/gimple-ssa-isolate-paths.c @@ -268,8 +268,7 @@ find_implicit_erroneous_behavior (void) if (TREE_CODE (op) == ADDR_EXPR) { tree valbase = get_base_address (TREE_OPERAND (op, 0)); - if ((TREE_CODE (valbase) == VAR_DECL - && !is_global_var (valbase)) + if ((VAR_P (valbase) && !is_global_var (valbase)) || TREE_CODE (valbase) == PARM_DECL) { FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs) @@ -426,8 +425,7 @@ find_explicit_erroneous_behavior (void) if (val && TREE_CODE (val) == ADDR_EXPR) { tree valbase = get_base_address (TREE_OPERAND (val, 0)); - if ((TREE_CODE (valbase) == VAR_DECL - && !is_global_var (valbase)) + if ((VAR_P (valbase) && !is_global_var (valbase)) || TREE_CODE (valbase) == PARM_DECL) { /* We only need it for this particular case. */ diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c index 35124bd31fe..5441f69ca15 100644 --- a/gcc/gimple-streamer-out.c +++ b/gcc/gimple-streamer-out.c @@ -145,7 +145,7 @@ output_gimple_stmt (struct output_block *ob, gimple *stmt) basep = &TREE_OPERAND (*basep, 0); while (handled_component_p (*basep)) basep = &TREE_OPERAND (*basep, 0); - if (TREE_CODE (*basep) == VAR_DECL + if (VAR_P (*basep) && !auto_var_in_fn_p (*basep, current_function_decl) && !DECL_REGISTER (*basep)) { diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 2266333442a..0b1a0beccf5 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -665,7 +665,7 @@ force_constant_size (tree var) HOST_WIDE_INT max_size; - gcc_assert (TREE_CODE (var) == VAR_DECL); + gcc_assert (VAR_P (var)); max_size = max_int_size_in_bytes (TREE_TYPE (var)); @@ -1108,7 +1108,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p) /* Mark variables seen in this bind expr. */ for (t = BIND_EXPR_VARS (bind_expr); t ; t = DECL_CHAIN (t)) { - if (TREE_CODE (t) == VAR_DECL) + if (VAR_P (t)) { struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp; @@ -1138,7 +1138,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p) if ((TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE) && !TREE_THIS_VOLATILE (t) - && (TREE_CODE (t) == VAR_DECL && !DECL_HARD_REGISTER (t)) + && (VAR_P (t) && !DECL_HARD_REGISTER (t)) && !needs_to_live_in_memory (t)) DECL_GIMPLE_REG_P (t) = 1; } @@ -1190,7 +1190,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p) /* Add clobbers for all variables that go out of scope. */ for (t = BIND_EXPR_VARS (bind_expr); t ; t = DECL_CHAIN (t)) { - if (TREE_CODE (t) == VAR_DECL + if (VAR_P (t) && !is_global_var (t) && DECL_CONTEXT (t) == current_function_decl && !DECL_HARD_REGISTER (t) @@ -1450,7 +1450,7 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p) return GS_ERROR; if ((TREE_CODE (decl) == TYPE_DECL - || TREE_CODE (decl) == VAR_DECL) + || VAR_P (decl)) && !TYPE_SIZES_GIMPLIFIED (TREE_TYPE (decl))) { gimplify_type_sizes (TREE_TYPE (decl), seq_p); @@ -1469,7 +1469,7 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p) gimplify_type_sizes (TREE_TYPE (DECL_ORIGINAL_TYPE (decl)), seq_p); } - if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl)) + if (VAR_P (decl) && !DECL_EXTERNAL (decl)) { tree init = DECL_INITIAL (decl); @@ -2378,7 +2378,7 @@ gimplify_var_or_parm_decl (tree *expr_p) be really nice if the front end wouldn't leak these at all. Currently the only known culprit is C++ destructors, as seen in g++.old-deja/g++.jason/binding.C. */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && !DECL_SEEN_IN_BIND_EXPR_P (decl) && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl) && decl_function_context (decl) == current_function_decl) @@ -2398,7 +2398,7 @@ gimplify_var_or_parm_decl (tree *expr_p) /* For referenced nonlocal VLAs add a decl for debugging purposes to the current function. */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && TREE_CODE (DECL_SIZE_UNIT (decl)) != INTEGER_CST && nonlocal_vlas != NULL && TREE_CODE (value_expr) == INDIRECT_REF @@ -2533,7 +2533,7 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ; /* Expand DECL_VALUE_EXPR now. In some cases that may expose additional COMPONENT_REFs. */ - else if ((TREE_CODE (*p) == VAR_DECL || TREE_CODE (*p) == PARM_DECL) + else if ((VAR_P (*p) || TREE_CODE (*p) == PARM_DECL) && gimplify_var_or_parm_decl (p) == GS_OK) goto restart; else @@ -4447,7 +4447,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, if (valid_const_initializer && num_nonzero_elements > 1 && TREE_READONLY (object) - && TREE_CODE (object) == VAR_DECL + && VAR_P (object) && (flag_merge_constants >= 2 || !TREE_ADDRESSABLE (object))) { if (notify_temp_creation) @@ -5200,8 +5200,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, if (ret == GS_ERROR) return ret; gcc_assert (!want_value - && (TREE_CODE (*to_p) == VAR_DECL - || TREE_CODE (*to_p) == MEM_REF)); + && (VAR_P (*to_p) || TREE_CODE (*to_p) == MEM_REF)); gimplify_seq_add_stmt (pre_p, gimple_build_assign (*to_p, *from_p)); *expr_p = NULL; return GS_ALL_DONE; @@ -5349,7 +5348,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, temporaries (see for example is_gimple_reg_rhs) on the debug info, but make sure not to create DECL_DEBUG_EXPR links across functions. */ if (!gimplify_ctxp->into_ssa - && TREE_CODE (*from_p) == VAR_DECL + && VAR_P (*from_p) && DECL_IGNORED_P (*from_p) && DECL_P (*to_p) && !DECL_IGNORED_P (*to_p) @@ -5935,7 +5934,7 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) if (TREE_CODE (x) == MEM_REF && TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR) x = TREE_OPERAND (TREE_OPERAND (x, 0), 0); - if ((TREE_CODE (x) == VAR_DECL + if ((VAR_P (x) || TREE_CODE (x) == PARM_DECL || TREE_CODE (x) == RESULT_DECL) && !TREE_ADDRESSABLE (x) @@ -9055,7 +9054,7 @@ gimplify_oacc_declare (tree *expr_p, gimple_seq *pre_p) if (TREE_CODE (decl) == MEM_REF) continue; - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && !is_global_var (decl) && DECL_CONTEXT (decl) == current_function_decl) { @@ -12045,10 +12044,10 @@ gimplify_type_sizes (tree type, gimple_seq *list_p) && INTEGRAL_TYPE_P (TYPE_DOMAIN (type))) { t = TYPE_MIN_VALUE (TYPE_DOMAIN (type)); - if (t && TREE_CODE (t) == VAR_DECL && DECL_ARTIFICIAL (t)) + if (t && VAR_P (t) && DECL_ARTIFICIAL (t)) DECL_IGNORED_P (t) = 0; t = TYPE_MAX_VALUE (TYPE_DOMAIN (type)); - if (t && TREE_CODE (t) == VAR_DECL && DECL_ARTIFICIAL (t)) + if (t && VAR_P (t) && DECL_ARTIFICIAL (t)) DECL_IGNORED_P (t) = 0; } break; diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index 2c8ec1d9505..6f7083a15c9 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -883,12 +883,11 @@ get_symbol_for_decl (tree decl) gcc_assert (TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL - || TREE_CODE (decl) == VAR_DECL); + || VAR_P (decl)); dummy.m_decl = decl; - bool is_in_global_vars - = TREE_CODE (decl) == VAR_DECL && is_global_var (decl); + bool is_in_global_vars = VAR_P (decl) && is_global_var (decl); if (is_in_global_vars) slot = hsa_global_variable_symbols->find_slot (&dummy, INSERT); @@ -925,7 +924,7 @@ get_symbol_for_decl (tree decl) else { hsa_symbol *sym; - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); BrigAlignment8_t align = hsa_object_alignment (decl); if (is_in_global_vars) @@ -952,7 +951,7 @@ get_symbol_for_decl (tree decl) align = MAX ((BrigAlignment8_t) BRIG_ALIGNMENT_8, align); /* PARM_DECL and RESULT_DECL should be already in m_local_symbols. */ - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); sym = new hsa_symbol (BRIG_TYPE_NONE, BRIG_SEGMENT_PRIVATE, BRIG_LINKAGE_FUNCTION); diff --git a/gcc/hsa.c b/gcc/hsa.c index c9c4957e425..168cfe373c0 100644 --- a/gcc/hsa.c +++ b/gcc/hsa.c @@ -798,7 +798,7 @@ hsa_get_declaration_name (tree decl) tree name_tree; if (TREE_CODE (decl) == FUNCTION_DECL - || (TREE_CODE (decl) == VAR_DECL && is_global_var (decl))) + || (VAR_P (decl) && is_global_var (decl))) name_tree = DECL_ASSEMBLER_NAME (decl); else name_tree = DECL_NAME (decl); diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 48abbeb5d61..49e219557d5 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -877,9 +877,9 @@ compare_virtual_tables (varpool_node *prevailing, varpool_node *vtable) if (TREE_CODE (ref1->referred->decl) != TREE_CODE (ref2->referred->decl)) { - if (TREE_CODE (ref1->referred->decl) == VAR_DECL) + if (VAR_P (ref1->referred->decl)) end1 = true; - else if (TREE_CODE (ref2->referred->decl) == VAR_DECL) + else if (VAR_P (ref2->referred->decl)) end2 = true; } } @@ -2342,7 +2342,7 @@ referenced_from_vtable_p (struct cgraph_node *node) if ((ref->use == IPA_REF_ALIAS && referenced_from_vtable_p (dyn_cast (ref->referring))) || (ref->use == IPA_REF_ADDR - && TREE_CODE (ref->referring->decl) == VAR_DECL + && VAR_P (ref->referring->decl) && DECL_VIRTUAL_P (ref->referring->decl))) { found = true; diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index f7ef6aa94fd..8d9f22af055 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -575,7 +575,7 @@ decl_maybe_in_construction_p (tree base, tree outer_type, return true; } - if (!base || (TREE_CODE (base) == VAR_DECL && is_global_var (base))) + if (!base || (VAR_P (base) && is_global_var (base))) { if (TREE_CODE (TREE_TYPE (function)) != METHOD_TYPE || (!DECL_CXX_CONSTRUCTOR_P (function) diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index a981efd5e62..e2d3ead065c 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1729,7 +1729,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, gcc_assert (!jfunc->bits.known); if (is_gimple_ip_invariant (arg) - || (TREE_CODE (arg) == VAR_DECL + || (VAR_P (arg) && is_global_var (arg) && TREE_READONLY (arg))) ipa_set_jf_constant (jfunc, arg, cs); @@ -2861,7 +2861,7 @@ ipa_find_agg_cst_from_init (tree scalar, HOST_WIDE_INT offset, bool by_ref) scalar = TREE_OPERAND (scalar, 0); } - if (TREE_CODE (scalar) != VAR_DECL + if (!VAR_P (scalar) || !is_global_var (scalar) || !TREE_READONLY (scalar) || !DECL_INITIAL (scalar) diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index 0c25fcae59f..d3916d5ac2a 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -160,7 +160,7 @@ test_nonssa_use (gimple *, tree t, tree, void *data) return false; if (TREE_CODE (t) == PARM_DECL - || (TREE_CODE (t) == VAR_DECL + || (VAR_P (t) && auto_var_in_fn_p (t, current_function_decl)) || TREE_CODE (t) == RESULT_DECL /* Normal labels are part of CFG and will be handled gratefuly. @@ -656,7 +656,7 @@ consider_split (struct split_point *current, bitmap non_ssa_vars, = split_part_set_ssa_name_p (retval, current, return_bb); else if (TREE_CODE (retval) == PARM_DECL) current->split_part_set_retval = false; - else if (TREE_CODE (retval) == VAR_DECL + else if (VAR_P (retval) || TREE_CODE (retval) == RESULT_DECL) current->split_part_set_retval = bitmap_bit_p (non_ssa_vars, DECL_UID (retval)); @@ -848,11 +848,9 @@ mark_nonssa_use (gimple *, tree t, tree, void *data) return true; } - if ((TREE_CODE (t) == VAR_DECL - && auto_var_in_fn_p (t, current_function_decl)) + if ((VAR_P (t) && auto_var_in_fn_p (t, current_function_decl)) || TREE_CODE (t) == RESULT_DECL - || (TREE_CODE (t) == LABEL_DECL - && FORCED_LABEL (t))) + || (TREE_CODE (t) == LABEL_DECL && FORCED_LABEL (t))) bitmap_set_bit ((bitmap)data, DECL_UID (t)); /* For DECL_BY_REFERENCE, the return value is actually a pointer. We want diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index e4c3f7c5110..e8f579504a4 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -367,8 +367,7 @@ static tree update_vtable_references (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) { - if (TREE_CODE (*tp) == VAR_DECL - || TREE_CODE (*tp) == FUNCTION_DECL) + if (VAR_OR_FUNCTION_DECL_P (*tp)) { if (can_replace_by_local_alias_in_vtable (symtab_node::get (*tp))) *tp = symtab_node::get (*tp)->noninterposable_alias ()->decl; diff --git a/gcc/ipa.c b/gcc/ipa.c index b26dad5e2b4..e20e4953e8f 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -128,7 +128,7 @@ process_references (symtab_node *snode, /* We use variable constructors during late compilation for constant folding. Keep references alive so partitioning knows about potential references. */ - || (TREE_CODE (node->decl) == VAR_DECL + || (VAR_P (node->decl) && flag_wpa && ctor_for_folding (node->decl) != error_mark_node)))) diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 79a846cd432..69cdb944948 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -128,7 +128,7 @@ lhd_warn_unused_global_decl (const_tree decl) if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl)) return false; - if (TREE_CODE (decl) == VAR_DECL && TREE_READONLY (decl)) + if (VAR_P (decl) && TREE_READONLY (decl)) return false; if (DECL_IN_SYSTEM_HEADER (decl)) return false; @@ -152,7 +152,7 @@ lhd_set_decl_assembler_name (tree decl) VAR_DECLs for variables with static storage duration need a real DECL_ASSEMBLER_NAME. */ gcc_assert (TREE_CODE (decl) == FUNCTION_DECL - || (TREE_CODE (decl) == VAR_DECL + || (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)))); diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 986b1595023..2bb0c504277 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -131,7 +131,7 @@ tree_is_indexable (tree t) /* IMPORTED_DECL is put into BLOCK and thus it never can be shared. */ else if (TREE_CODE (t) == IMPORTED_DECL) return false; - else if (((TREE_CODE (t) == VAR_DECL && !TREE_STATIC (t)) + else if (((VAR_P (t) && !TREE_STATIC (t)) || TREE_CODE (t) == TYPE_DECL || TREE_CODE (t) == CONST_DECL || TREE_CODE (t) == NAMELIST_DECL) @@ -357,7 +357,7 @@ get_symbol_initial_value (lto_symtab_encoder_t encoder, tree expr) /* Handle DECL_INITIAL for symbols. */ tree initial = DECL_INITIAL (expr); - if (TREE_CODE (expr) == VAR_DECL + if (VAR_P (expr) && (TREE_STATIC (expr) || DECL_EXTERNAL (expr)) && !DECL_IN_CONSTANT_POOL (expr) && initial) @@ -766,11 +766,11 @@ DFS::DFS_write_tree_body (struct output_block *ob, leaks to this point. */ gcc_assert (DECL_ABSTRACT_ORIGIN (expr) != error_mark_node); - if ((TREE_CODE (expr) == VAR_DECL + if ((VAR_P (expr) || TREE_CODE (expr) == PARM_DECL) && DECL_HAS_VALUE_EXPR_P (expr)) DFS_follow_tree_edge (DECL_VALUE_EXPR (expr)); - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) DFS_follow_tree_edge (DECL_DEBUG_EXPR (expr)); } @@ -2509,12 +2509,10 @@ write_symbol (struct streamer_tree_cache_d *cache, if (!TREE_PUBLIC (t) || is_builtin_fn (t) || DECL_ABSTRACT_P (t) - || (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))) + || (VAR_P (t) && DECL_HARD_REGISTER (t))) return; - gcc_assert (TREE_CODE (t) != RESULT_DECL); - gcc_assert (TREE_CODE (t) == VAR_DECL - || TREE_CODE (t) == FUNCTION_DECL); + gcc_assert (VAR_OR_FUNCTION_DECL_P (t)); name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (t)); @@ -2545,8 +2543,7 @@ write_symbol (struct streamer_tree_cache_d *cache, kind = GCCPK_DEF; /* When something is defined, it should have node attached. */ - gcc_assert (alias || TREE_CODE (t) != VAR_DECL - || varpool_node::get (t)->definition); + gcc_assert (alias || !VAR_P (t) || varpool_node::get (t)->definition); gcc_assert (alias || TREE_CODE (t) != FUNCTION_DECL || (cgraph_node::get (t) && cgraph_node::get (t)->definition)); diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 422f2b20c37..202f0bd5f2a 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -7106,7 +7106,7 @@ expand_omp_regimplify_p (tree *tp, int *walk_subtrees, void *) tree t = *tp; /* Any variable with DECL_VALUE_EXPR needs to be regimplified. */ - if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t)) + if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t)) return t; if (TREE_CODE (t) == ADDR_EXPR) @@ -7287,9 +7287,7 @@ expand_omp_taskreg (struct omp_region *region) rather than in containing function's local_decls chain, which would mean cgraph missed finalizing them. Do it now. */ for (t = BLOCK_VARS (block); t; t = DECL_CHAIN (t)) - if (TREE_CODE (t) == VAR_DECL - && TREE_STATIC (t) - && !DECL_EXTERNAL (t)) + if (VAR_P (t) && TREE_STATIC (t) && !DECL_EXTERNAL (t)) varpool_node::finalize_decl (t); DECL_SAVED_TREE (child_fn) = NULL; /* We'll create a CFG for child_fn, so no gimple body is needed. */ @@ -13129,9 +13127,7 @@ expand_omp_target (struct omp_region *region) rather than in containing function's local_decls chain, which would mean cgraph missed finalizing them. Do it now. */ for (t = BLOCK_VARS (block); t; t = DECL_CHAIN (t)) - if (TREE_CODE (t) == VAR_DECL - && TREE_STATIC (t) - && !DECL_EXTERNAL (t)) + if (VAR_P (t) && TREE_STATIC (t) && !DECL_EXTERNAL (t)) varpool_node::finalize_decl (t); DECL_SAVED_TREE (child_fn) = NULL; /* We'll create a CFG for child_fn, so no gimple body is needed. */ @@ -16892,7 +16888,7 @@ lower_omp_regimplify_p (tree *tp, int *walk_subtrees, tree t = *tp; /* Any variable with DECL_VALUE_EXPR needs to be regimplified. */ - if (TREE_CODE (t) == VAR_DECL && data == NULL && DECL_HAS_VALUE_EXPR_P (t)) + if (VAR_P (t) && data == NULL && DECL_HAS_VALUE_EXPR_P (t)) return t; if (task_shared_vars @@ -17196,7 +17192,7 @@ grid_reg_assignment_to_local_var_p (gimple *stmt) if (!assign) return false; tree lhs = gimple_assign_lhs (assign); - if (TREE_CODE (lhs) != VAR_DECL + if (!VAR_P (lhs) || !is_gimple_reg_type (TREE_TYPE (lhs)) || is_global_var (lhs)) return false; @@ -17634,7 +17630,7 @@ grid_remap_prebody_decls (tree *tp, int *walk_subtrees, void *data) else *walk_subtrees = 1; - if (TREE_CODE (t) == VAR_DECL) + if (VAR_P (t)) { struct walk_stmt_info *wi = (struct walk_stmt_info *) data; hash_map *declmap = (hash_map *) wi->info; @@ -18449,7 +18445,7 @@ add_decls_addresses_to_decl_constructor (vec *v_decls, for (unsigned i = 0; i < len; i++) { tree it = (*v_decls)[i]; - bool is_var = TREE_CODE (it) == VAR_DECL; + bool is_var = VAR_P (it); bool is_link_var = is_var #ifdef ACCEL_COMPILER @@ -19920,7 +19916,7 @@ find_link_var_op (tree *tp, int *walk_subtrees, void *) { tree t = *tp; - if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t) + if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t) && lookup_attribute ("omp declare target link", DECL_ATTRIBUTES (t))) { *walk_subtrees = 0; diff --git a/gcc/passes.c b/gcc/passes.c index a210772eab8..881f2293dae 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -211,7 +211,7 @@ rest_of_decl_compilation (tree decl, if ((at_end || !DECL_DEFER_OUTPUT (decl) || DECL_INITIAL (decl)) - && (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl)) + && (!VAR_P (decl) || !DECL_HAS_VALUE_EXPR_P (decl)) && !DECL_EXTERNAL (decl)) { /* When reading LTO unit, we also read varpool, so do not @@ -250,7 +250,7 @@ rest_of_decl_compilation (tree decl, /* Let cgraph know about the existence of variables. */ if (in_lto_p && !at_end) ; - else if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl) + else if (VAR_P (decl) && !DECL_EXTERNAL (decl) && TREE_STATIC (decl)) varpool_node::get_create (decl); @@ -311,7 +311,7 @@ rest_of_decl_compilation (tree decl, called from varpool node removal fails to handle it properly. */ || (finalize - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && TREE_STATIC (decl) && !DECL_EXTERNAL (decl))) /* Avoid confusing the debug information machinery when there are errors. */ diff --git a/gcc/sdbout.c b/gcc/sdbout.c index 7eea772bed7..039d945d12a 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -906,7 +906,7 @@ sdbout_toplevel_data (tree decl) if (DECL_IGNORED_P (decl)) return; - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); gcc_assert (MEM_P (DECL_RTL (decl))); gcc_assert (DECL_INITIAL (decl)); @@ -1434,9 +1434,7 @@ sdbout_early_global_decl (tree decl ATTRIBUTE_UNUSED) static void sdbout_late_global_decl (tree decl) { - if (TREE_CODE (decl) == VAR_DECL - && !DECL_EXTERNAL (decl) - && DECL_RTL_SET_P (decl)) + if (VAR_P (decl) && !DECL_EXTERNAL (decl) && DECL_RTL_SET_P (decl)) { /* The COFF linker can move initialized global vars to the end. And that can screw up the symbol ordering. Defer those for diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 3cce25a0bf4..cd3e2d08d6f 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -321,7 +321,7 @@ delegitimize_mem_from_attrs (rtx x) if (decl && mode == GET_MODE (x) - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && (TREE_STATIC (decl) || DECL_THREAD_LOCAL_P (decl)) && DECL_RTL_SET_P (decl) diff --git a/gcc/stmt.c b/gcc/stmt.c index 1bae9e9cb6e..39fa5e19db3 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -458,7 +458,7 @@ decl_overlaps_hard_reg_set_p (tree *declp, int *walk_subtrees ATTRIBUTE_UNUSED, tree decl = *declp; const HARD_REG_SET *const regs = (const HARD_REG_SET *) data; - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { if (DECL_HARD_REGISTER (decl) && REG_P (DECL_RTL (decl)) diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 07eac874908..63a1454b629 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1137,7 +1137,7 @@ place_field (record_layout_info rli, tree field) really like a structure field. If it is a FUNCTION_DECL, it's a method. In both cases, all we do is lay out the decl, and we do it *after* the record is laid out. */ - if (TREE_CODE (field) == VAR_DECL) + if (VAR_P (field)) { vec_safe_push (rli->pending_statics, field); return; diff --git a/gcc/symtab.c b/gcc/symtab.c index ded6ecc17d5..73168a8db09 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -273,8 +273,7 @@ symbol_table::change_decl_assembler_name (tree decl, tree name) /* We can have user ASM names on things, like global register variables, that are not in the symbol table. */ - if ((TREE_CODE (decl) == VAR_DECL - && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) + if ((VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) || TREE_CODE (decl) == FUNCTION_DECL) node = symtab_node::get (decl); if (!DECL_ASSEMBLER_NAME_SET_P (decl)) @@ -602,8 +601,7 @@ symtab_node::maybe_create_reference (tree val, enum ipa_ref_use use_type, if (TREE_CODE (val) != ADDR_EXPR) return NULL; val = get_base_var (val); - if (val && (TREE_CODE (val) == FUNCTION_DECL - || TREE_CODE (val) == VAR_DECL)) + if (val && VAR_OR_FUNCTION_DECL_P (val)) { symtab_node *referred = symtab_node::get (val); gcc_checking_assert (referred); @@ -967,7 +965,7 @@ symtab_node::verify_base (void) } else if (is_a (this)) { - if (TREE_CODE (decl) != VAR_DECL) + if (!VAR_P (decl)) { error ("variable symbol is not variable"); error_found = true; @@ -1254,7 +1252,7 @@ symtab_node::make_decl_local (void) alias->make_decl_local (); } - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { DECL_COMMON (decl) = 0; /* ADDRESSABLE flag is not defined for public symbols. */ @@ -1303,7 +1301,7 @@ symtab_node::copy_visibility_from (symtab_node *n) alias->copy_visibility_from (n); } - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { DECL_COMMON (decl) = DECL_COMMON (n->decl); /* ADDRESSABLE flag is not defined for public symbols. */ @@ -2099,7 +2097,7 @@ symtab_node::can_increase_alignment_p (void) symtab_node *target = ultimate_alias_target (); /* For now support only variables. */ - if (TREE_CODE (decl) != VAR_DECL) + if (!VAR_P (decl)) return false; /* With -fno-toplevel-reorder we may have already output the constant. */ diff --git a/gcc/toplev.c b/gcc/toplev.c index 5f807632680..570f4cfee6c 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -350,7 +350,7 @@ wrapup_global_declaration_1 (tree decl) && DECL_DEFER_OUTPUT (decl) != 0) DECL_DEFER_OUTPUT (decl) = 0; - if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0) + if (VAR_P (decl) && DECL_SIZE (decl) == 0) lang_hooks.finish_incomplete_decl (decl); } @@ -361,7 +361,7 @@ bool wrapup_global_declaration_2 (tree decl) { if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl) - || (TREE_CODE (decl) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (decl))) + || (VAR_P (decl) && DECL_HAS_VALUE_EXPR_P (decl))) return false; /* Don't write out static consts, unless we still need them. @@ -389,7 +389,7 @@ wrapup_global_declaration_2 (tree decl) to force a constant to be written if and only if it is defined in a main file, as opposed to an include file. */ - if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)) + if (VAR_P (decl) && TREE_STATIC (decl)) { varpool_node *node; bool needed = true; diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 6fc67fb1a22..a82d3629c19 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -1545,7 +1545,7 @@ requires_barrier (basic_block entry_block, tree x, gimple *stmt) x = TREE_OPERAND (TMR_BASE (x), 0); if (TREE_CODE (x) == PARM_DECL) return false; - gcc_assert (TREE_CODE (x) == VAR_DECL); + gcc_assert (VAR_P (x)); /* FALLTHRU */ case PARM_DECL: diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 2ed450c4cab..dfa82aaef73 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2786,7 +2786,7 @@ verify_address (tree t, tree base) return t; } - if (!(TREE_CODE (base) == VAR_DECL + if (!(VAR_P (base) || TREE_CODE (base) == PARM_DECL || TREE_CODE (base) == RESULT_DECL)) return NULL_TREE; @@ -2902,7 +2902,7 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) if ((tem = verify_address (t, x))) return tem; - if (!(TREE_CODE (x) == VAR_DECL + if (!(VAR_P (x) || TREE_CODE (x) == PARM_DECL || TREE_CODE (x) == RESULT_DECL)) return NULL; @@ -4982,15 +4982,14 @@ verify_expr_location_1 (tree *tp, int *walk_subtrees, void *data) { hash_set *blocks = (hash_set *) data; - if (TREE_CODE (*tp) == VAR_DECL - && DECL_HAS_DEBUG_EXPR_P (*tp)) + if (VAR_P (*tp) && DECL_HAS_DEBUG_EXPR_P (*tp)) { tree t = DECL_DEBUG_EXPR (*tp); tree addr = walk_tree (&t, verify_expr_no_block, NULL, NULL); if (addr) return addr; } - if ((TREE_CODE (*tp) == VAR_DECL + if ((VAR_P (*tp) || TREE_CODE (*tp) == PARM_DECL || TREE_CODE (*tp) == RESULT_DECL) && DECL_HAS_VALUE_EXPR_P (*tp)) @@ -5989,13 +5988,11 @@ gimple_duplicate_bb (basic_block bb) { tree base = get_base_address (lhs); if (base - && (TREE_CODE (base) == VAR_DECL - || TREE_CODE (base) == RESULT_DECL) + && (VAR_P (base) || TREE_CODE (base) == RESULT_DECL) && DECL_IGNORED_P (base) && !TREE_STATIC (base) && !DECL_EXTERNAL (base) - && (TREE_CODE (base) != VAR_DECL - || !DECL_HAS_VALUE_EXPR_P (base))) + && (!VAR_P (base) || !DECL_HAS_VALUE_EXPR_P (base))) DECL_NONSHAREABLE (base) = 1; } @@ -6621,8 +6618,7 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data) statements, and in alias lists of other variables. It would be quite difficult to expunge it from all those places. ??? It might suffice to do this for addressable variables. */ - if ((TREE_CODE (t) == VAR_DECL - && !is_global_var (t)) + if ((VAR_P (t) && !is_global_var (t)) || TREE_CODE (t) == CONST_DECL) replace_by_duplicate_decl (tp, p->vars_map, p->to_context); } @@ -7008,12 +7004,12 @@ replace_block_vars_by_duplicates (tree block, hash_map *vars_map, for (tp = &BLOCK_VARS (block); *tp; tp = &DECL_CHAIN (*tp)) { t = *tp; - if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != CONST_DECL) + if (!VAR_P (t) && TREE_CODE (t) != CONST_DECL) continue; replace_by_duplicate_decl (&t, vars_map, to_context); if (t != *tp) { - if (TREE_CODE (*tp) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*tp)) + if (VAR_P (*tp) && DECL_HAS_VALUE_EXPR_P (*tp)) { tree x = DECL_VALUE_EXPR (*tp); struct replace_decls_d rd = { vars_map, to_context }; @@ -9035,7 +9031,7 @@ execute_fixup_cfg (void) { tree lhs = get_base_address (gimple_get_lhs (stmt)); - if (TREE_CODE (lhs) == VAR_DECL + if (VAR_P (lhs) && (TREE_STATIC (lhs) || DECL_EXTERNAL (lhs)) && varpool_node::get (lhs)->writeonly) { @@ -9053,7 +9049,7 @@ execute_fixup_cfg (void) { tree lhs = get_base_address (gimple_get_lhs (stmt)); - if (TREE_CODE (lhs) == VAR_DECL + if (VAR_P (lhs) && (TREE_STATIC (lhs) || DECL_EXTERNAL (lhs)) && varpool_node::get (lhs)->writeonly) { diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c index 6cf086c754c..780b5acb7b7 100644 --- a/gcc/tree-chkp-opt.c +++ b/gcc/tree-chkp-opt.c @@ -610,7 +610,7 @@ chkp_get_check_result (struct check_info *ci, tree bounds) chkp_collect_value (DECL_INITIAL (bnd_var), bound_val); if (ci->type == CHECK_UPPER_BOUND) { - if (TREE_CODE (var) == VAR_DECL) + if (VAR_P (var)) { if (DECL_SIZE (var) && !chkp_variable_size_type (TREE_TYPE (var))) diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index f39c292242e..27696828716 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -1002,7 +1002,7 @@ chkp_register_var_initializer (tree var) || DECL_INITIAL (var) == error_mark_node) return false; - gcc_assert (TREE_CODE (var) == VAR_DECL); + gcc_assert (VAR_P (var)); gcc_assert (DECL_INITIAL (var)); if (TREE_STATIC (var) @@ -2936,7 +2936,7 @@ chkp_make_static_bounds (tree obj) chkp_static_var_bounds map. It allows to avoid duplicating bound vars for decls sharing assembler name. */ - if (TREE_CODE (obj) == VAR_DECL) + if (VAR_P (obj)) { tree name = DECL_ASSEMBLER_NAME (obj); slot = chkp_static_var_bounds->get (name); @@ -2952,7 +2952,7 @@ chkp_make_static_bounds (tree obj) } /* Build decl for bounds var. */ - if (TREE_CODE (obj) == VAR_DECL) + if (VAR_P (obj)) { if (DECL_IGNORED_P (obj)) { @@ -3014,7 +3014,7 @@ chkp_make_static_bounds (tree obj) if (!chkp_static_var_bounds) chkp_static_var_bounds = new hash_map; - if (TREE_CODE (obj) == VAR_DECL) + if (VAR_P (obj)) { tree name = DECL_ASSEMBLER_NAME (obj); chkp_static_var_bounds->put (name, bnd_var); @@ -3117,7 +3117,7 @@ chkp_get_bounds_for_decl_addr (tree decl) { tree bounds; - gcc_assert (TREE_CODE (decl) == VAR_DECL + gcc_assert (VAR_P (decl) || TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL); @@ -3144,7 +3144,7 @@ chkp_get_bounds_for_decl_addr (tree decl) return chkp_get_zero_bounds (); if (flag_chkp_use_static_bounds - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)) @@ -3164,7 +3164,7 @@ chkp_get_bounds_for_decl_addr (tree decl) || DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)))) { - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); bounds = chkp_generate_extern_var_bounds (decl); } else @@ -3399,7 +3399,7 @@ chkp_parse_array_and_component_ref (tree node, tree *ptr, } else { - gcc_assert (TREE_CODE (var) == VAR_DECL + gcc_assert (VAR_P (var) || TREE_CODE (var) == PARM_DECL || TREE_CODE (var) == RESULT_DECL || TREE_CODE (var) == STRING_CST @@ -3562,7 +3562,7 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter) case MEM_REF: case VAR_DECL: if (BOUNDED_P (ptr_src)) - if (TREE_CODE (ptr) == VAR_DECL && DECL_REGISTER (ptr)) + if (VAR_P (ptr) && DECL_REGISTER (ptr)) bounds = chkp_get_zero_bounds (); else { @@ -3581,7 +3581,7 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter) || TREE_CODE (addr) == TARGET_MEM_REF) { if (BOUNDED_P (ptr_src)) - if (TREE_CODE (ptr) == VAR_DECL && DECL_REGISTER (ptr)) + if (VAR_P (ptr) && DECL_REGISTER (ptr)) bounds = chkp_get_zero_bounds (); else { diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index e7e47b1bc52..cefac2c5ae3 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -942,7 +942,7 @@ chrec_contains_symbols (const_tree chrec) return false; if (TREE_CODE (chrec) == SSA_NAME - || TREE_CODE (chrec) == VAR_DECL + || VAR_P (chrec) || TREE_CODE (chrec) == PARM_DECL || TREE_CODE (chrec) == FUNCTION_DECL || TREE_CODE (chrec) == LABEL_DECL diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 9a3b072ae2f..0396febc730 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -302,7 +302,7 @@ ssa_default_def (struct function *fn, tree var) { struct tree_decl_minimal ind; struct tree_ssa_name in; - gcc_assert (TREE_CODE (var) == VAR_DECL + gcc_assert (VAR_P (var) || TREE_CODE (var) == PARM_DECL || TREE_CODE (var) == RESULT_DECL); in.var = (tree)&ind; @@ -319,7 +319,7 @@ set_ssa_default_def (struct function *fn, tree var, tree def) struct tree_decl_minimal ind; struct tree_ssa_name in; - gcc_assert (TREE_CODE (var) == VAR_DECL + gcc_assert (VAR_P (var) || TREE_CODE (var) == PARM_DECL || TREE_CODE (var) == RESULT_DECL); in.var = (tree)&ind; @@ -612,8 +612,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, if (DECL_P (exp)) { - if (flag_unconstrained_commons - && TREE_CODE (exp) == VAR_DECL && DECL_COMMON (exp)) + if (flag_unconstrained_commons && VAR_P (exp) && DECL_COMMON (exp)) { tree sz_tree = TYPE_SIZE (TREE_TYPE (exp)); /* If size is unknown, or we have read to the end, assume there diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c index 234d0fd0bc9..8c9990fee6f 100644 --- a/gcc/tree-diagnostic.c +++ b/gcc/tree-diagnostic.c @@ -266,7 +266,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec, case 'D': t = va_arg (*text->args_ptr, tree); - if (TREE_CODE (t) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (t)) + if (VAR_P (t) && DECL_HAS_DEBUG_EXPR_P (t)) t = DECL_DEBUG_EXPR (t); break; diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c index ed60e6d3cd5..df47181f431 100644 --- a/gcc/tree-dump.c +++ b/gcc/tree-dump.c @@ -536,8 +536,7 @@ dequeue_and_dump (dump_info_p di) if (DECL_FIELD_OFFSET (t)) dump_child ("bpos", bit_position (t)); } - else if (TREE_CODE (t) == VAR_DECL - || TREE_CODE (t) == PARM_DECL) + else if (VAR_P (t) || TREE_CODE (t) == PARM_DECL) { dump_int (di, "used", TREE_USED (t)); if (DECL_REGISTER (t)) diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 8a06e29d932..de5e5757080 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -163,7 +163,7 @@ insert_debug_decl_map (copy_body_data *id, tree key, tree value) return; gcc_assert (TREE_CODE (key) == PARM_DECL); - gcc_assert (TREE_CODE (value) == VAR_DECL); + gcc_assert (VAR_P (value)); if (!id->debug_map) id->debug_map = new hash_map; @@ -228,7 +228,7 @@ remap_ssa_name (tree name, copy_body_data *id) var = SSA_NAME_VAR (name); if (!var || (!SSA_NAME_IS_DEFAULT_DEF (name) - && TREE_CODE (var) == VAR_DECL + && VAR_P (var) && !VAR_DECL_IS_VIRTUAL_OPERAND (var) && DECL_ARTIFICIAL (var) && DECL_IGNORED_P (var) @@ -264,7 +264,7 @@ remap_ssa_name (tree name, copy_body_data *id) Replace the SSA name representing RESULT_DECL by variable during inlining: this saves us from need to introduce PHI node in a case return value is just partly initialized. */ - if ((TREE_CODE (new_tree) == VAR_DECL || TREE_CODE (new_tree) == PARM_DECL) + if ((VAR_P (new_tree) || TREE_CODE (new_tree) == PARM_DECL) && (!SSA_NAME_VAR (name) || TREE_CODE (SSA_NAME_VAR (name)) != RESULT_DECL || !id->transform_return_to_modify)) @@ -607,8 +607,7 @@ can_be_nonlocal (tree decl, copy_body_data *id) /* Local static vars must be non-local or we get multiple declaration problems. */ - if (TREE_CODE (decl) == VAR_DECL - && !auto_var_in_fn_p (decl, id->src_fn)) + if (VAR_P (decl) && !auto_var_in_fn_p (decl, id->src_fn)) return true; return false; @@ -630,9 +629,7 @@ remap_decls (tree decls, vec **nonlocalized_list, { /* We need to add this variable to the local decls as otherwise nothing else will do so. */ - if (TREE_CODE (old_var) == VAR_DECL - && ! DECL_EXTERNAL (old_var) - && cfun) + if (VAR_P (old_var) && ! DECL_EXTERNAL (old_var) && cfun) add_local_decl (cfun, old_var); if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE) && !DECL_IGNORED_P (old_var) @@ -664,8 +661,7 @@ remap_decls (tree decls, vec **nonlocalized_list, new_decls = new_var; /* Also copy value-expressions. */ - if (TREE_CODE (new_var) == VAR_DECL - && DECL_HAS_VALUE_EXPR_P (new_var)) + if (VAR_P (new_var) && DECL_HAS_VALUE_EXPR_P (new_var)) { tree tem = DECL_VALUE_EXPR (new_var); bool old_regimplify = id->regimplify; @@ -2876,12 +2872,10 @@ copy_debug_stmt (gdebug *stmt, copy_body_data *id) if (TREE_CODE (t) == PARM_DECL && id->debug_map && (n = id->debug_map->get (t))) { - gcc_assert (TREE_CODE (*n) == VAR_DECL); + gcc_assert (VAR_P (*n)); t = *n; } - else if (TREE_CODE (t) == VAR_DECL - && !is_global_var (t) - && !id->decl_map->get (t)) + else if (VAR_P (t) && !is_global_var (t) && !id->decl_map->get (t)) /* T is a non-localized variable. */; else walk_tree (&t, remap_gimple_op_r, &wi, NULL); @@ -3277,8 +3271,7 @@ initialize_inlined_parameters (copy_body_data *id, gimple *stmt, for (p = parms, i = 0; p; p = DECL_CHAIN (p), i++) { tree *varp = id->decl_map->get (p); - if (varp - && TREE_CODE (*varp) == VAR_DECL) + if (varp && VAR_P (*varp)) { tree def = (gimple_in_ssa_p (cfun) && is_gimple_reg (p) ? ssa_default_def (id->src_cfun, p) : NULL); @@ -4297,7 +4290,7 @@ add_local_variables (struct function *callee, struct function *caller, tree new_var = remap_decl (var, id); /* Remap debug-expressions. */ - if (TREE_CODE (new_var) == VAR_DECL + if (VAR_P (new_var) && DECL_HAS_DEBUG_EXPR_P (var) && new_var != var) { @@ -4325,7 +4318,7 @@ reset_debug_binding (copy_body_data *id, tree srcvar, gimple_seq *bindings) if (!remappedvarp) return; - if (TREE_CODE (*remappedvarp) != VAR_DECL) + if (!VAR_P (*remappedvarp)) return; if (*remappedvarp == id->retvar || *remappedvarp == id->retbnd) @@ -5202,8 +5195,7 @@ replace_locals_op (tree *tp, int *walk_subtrees, void *data) SSA_NAME_DEF_STMT (*tp) = gsi_stmt (wi->gsi); } /* Only a local declaration (variable or label). */ - else if ((TREE_CODE (expr) == VAR_DECL - && !TREE_STATIC (expr)) + else if ((VAR_P (expr) && !TREE_STATIC (expr)) || TREE_CODE (expr) == LABEL_DECL) { /* Lookup the declaration. */ diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index a4ff60876c3..e5b59a7a29f 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -1339,8 +1339,7 @@ rewrite_stmt (gimple_stmt_iterator *si) { /* If we rewrite a DECL into SSA form then drop its clobber stmts and replace uses with a new default def. */ - gcc_checking_assert (TREE_CODE (var) == VAR_DECL - && !gimple_vdef (stmt)); + gcc_checking_assert (VAR_P (var) && !gimple_vdef (stmt)); gsi_replace (si, gimple_build_nop (), true); register_new_def (get_or_create_ssa_default_def (cfun, var), var); break; @@ -1821,7 +1820,7 @@ maybe_register_def (def_operand_p def_p, gimple *stmt, { if (gimple_clobber_p (stmt) && is_gimple_reg (sym)) { - gcc_checking_assert (TREE_CODE (sym) == VAR_DECL); + gcc_checking_assert (VAR_P (sym)); /* Replace clobber stmts with a default def. This new use of a default definition may make it look like SSA_NAMEs have conflicting lifetimes, so we need special code to let them @@ -2393,7 +2392,7 @@ pass_build_ssa::execute (function *fun) continue; tree decl = SSA_NAME_VAR (name); if (decl - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && !VAR_DECL_IS_VIRTUAL_OPERAND (decl) && DECL_IGNORED_P (decl)) SET_SSA_NAME_VAR_OR_IDENTIFIER (name, DECL_NAME (decl)); diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 62cb01fbba9..465ae310b17 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -856,7 +856,7 @@ get_nonlocal_debug_decl (struct nesting_info *info, tree decl) DECL_SEEN_IN_BIND_EXPR_P (new_decl) = 1; if ((TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL - || TREE_CODE (decl) == VAR_DECL) + || VAR_P (decl)) && DECL_BY_REFERENCE (decl)) DECL_BY_REFERENCE (new_decl) = 1; @@ -1076,7 +1076,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) case OMP_CLAUSE_IS_DEVICE_PTR: do_decl_clause: decl = OMP_CLAUSE_DECL (clause); - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) break; if (decl_function_context (decl) != info->context) @@ -1175,7 +1175,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) } /* Like do_decl_clause, but don't add any suppression. */ decl = OMP_CLAUSE_DECL (clause); - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) break; if (decl_function_context (decl) != info->context) @@ -1308,11 +1308,11 @@ note_nonlocal_vla_type (struct nesting_info *info, tree type) if (domain) { t = TYPE_MIN_VALUE (domain); - if (t && (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL) + if (t && (VAR_P (t) || TREE_CODE (t) == PARM_DECL) && decl_function_context (t) != info->context) get_nonlocal_debug_decl (info, t); t = TYPE_MAX_VALUE (domain); - if (t && (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL) + if (t && (VAR_P (t) || TREE_CODE (t) == PARM_DECL) && decl_function_context (t) != info->context) get_nonlocal_debug_decl (info, t); } @@ -1328,7 +1328,7 @@ note_nonlocal_block_vlas (struct nesting_info *info, tree block) tree var; for (var = BLOCK_VARS (block); var; var = DECL_CHAIN (var)) - if (TREE_CODE (var) == VAR_DECL + if (VAR_P (var) && variably_modified_type_p (TREE_TYPE (var), NULL) && DECL_HAS_VALUE_EXPR_P (var) && decl_function_context (var) != info->context) @@ -1492,7 +1492,7 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (decls), i, decl) { - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) continue; if (decl_function_context (decl) != info->context) @@ -1554,7 +1554,7 @@ get_local_debug_decl (struct nesting_info *info, tree decl, tree field) DECL_SEEN_IN_BIND_EXPR_P (new_decl) = 1; if ((TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL - || TREE_CODE (decl) == VAR_DECL) + || VAR_P (decl)) && DECL_BY_REFERENCE (decl)) DECL_BY_REFERENCE (new_decl) = 1; @@ -1774,7 +1774,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) case OMP_CLAUSE_IS_DEVICE_PTR: do_decl_clause: decl = OMP_CLAUSE_DECL (clause); - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) break; if (decl_function_context (decl) == info->context @@ -1878,7 +1878,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) } /* Like do_decl_clause, but don't add any suppression. */ decl = OMP_CLAUSE_DECL (clause); - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) break; if (decl_function_context (decl) == info->context @@ -2144,7 +2144,7 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (decls), i, decl) { - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) continue; if (decl_function_context (decl) == info->context @@ -2685,7 +2685,7 @@ nesting_copy_decl (tree decl, copy_body_data *id) return new_decl; } - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) || TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL) return decl; @@ -2728,7 +2728,7 @@ remap_vla_decls (tree block, struct nesting_info *root) remap_vla_decls (subblock, root); for (var = BLOCK_VARS (block); var; var = DECL_CHAIN (var)) - if (TREE_CODE (var) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (var)) + if (VAR_P (var) && DECL_HAS_VALUE_EXPR_P (var)) { val = DECL_VALUE_EXPR (var); type = TREE_TYPE (var); @@ -2752,7 +2752,7 @@ remap_vla_decls (tree block, struct nesting_info *root) id.root = root; for (; var; var = DECL_CHAIN (var)) - if (TREE_CODE (var) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (var)) + if (VAR_P (var) && DECL_HAS_VALUE_EXPR_P (var)) { struct nesting_info *i; tree newt, context; diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c index 0f270ee7694..90d90af9d77 100644 --- a/gcc/tree-nrv.c +++ b/gcc/tree-nrv.c @@ -202,7 +202,7 @@ pass_nrv::execute (function *fun) /* The returned value must be a local automatic variable of the same type and alignment as the function's result. */ - if (TREE_CODE (found) != VAR_DECL + if (!VAR_P (found) || TREE_THIS_VOLATILE (found) || !auto_var_in_fn_p (found, current_function_decl) || TREE_ADDRESSABLE (found) diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 3449f266bea..ebbf606ff8b 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -3284,7 +3284,7 @@ print_declaration (pretty_printer *pp, tree t, int spc, int flags) dump_generic_node (pp, t, spc, flags, false); } - if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t)) + if (VAR_P (t) && DECL_HARD_REGISTER (t)) { pp_string (pp, " __asm__ "); pp_left_paren (pp); @@ -3307,7 +3307,7 @@ print_declaration (pretty_printer *pp, tree t, int spc, int flags) } } - if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t)) + if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t)) { pp_string (pp, " [value-expr: "); dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false); diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 5565743af0a..d4ccd91f851 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -687,7 +687,7 @@ sra_deinitialize (void) static bool constant_decl_p (tree decl) { - return TREE_CODE (decl) == VAR_DECL && DECL_IN_CONSTANT_POOL (decl); + return VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl); } /* Remove DECL from candidates for SRA and write REASON to the dump file if @@ -1965,7 +1965,7 @@ find_var_candidates (void) FOR_EACH_LOCAL_DECL (cfun, i, var) { - if (TREE_CODE (var) != VAR_DECL) + if (!VAR_P (var)) continue; ret |= maybe_add_sra_candidate (var); @@ -2653,8 +2653,7 @@ analyze_all_variable_accesses (void) { tree var = candidate (i); - if (TREE_CODE (var) == VAR_DECL - && scalarizable_type_p (TREE_TYPE (var))) + if (VAR_P (var) && scalarizable_type_p (TREE_TYPE (var))) { if (tree_to_uhwi (TYPE_SIZE (TREE_TYPE (var))) <= max_scalarization_size) diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c index 30f0c325ae2..a53ade0600d 100644 --- a/gcc/tree-ssa-address.c +++ b/gcc/tree-ssa-address.c @@ -400,9 +400,8 @@ create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr, static bool fixed_address_object_p (tree obj) { - return (TREE_CODE (obj) == VAR_DECL - && (TREE_STATIC (obj) - || DECL_EXTERNAL (obj)) + return (VAR_P (obj) + && (TREE_STATIC (obj) || DECL_EXTERNAL (obj)) && ! DECL_DLLIMPORT_P (obj)); } @@ -893,7 +892,7 @@ copy_ref_info (tree new_ref, tree old_ref) else mark_ptr_info_alignment_unknown (new_pi); } - else if (TREE_CODE (base) == VAR_DECL + else if (VAR_P (base) || TREE_CODE (base) == PARM_DECL || TREE_CODE (base) == RESULT_DECL) { diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 30de4612598..01bef17cbfb 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -167,7 +167,7 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl) && TREE_CODE (ptr) != ADDR_EXPR && TREE_CODE (ptr) != POINTER_PLUS_EXPR) || !POINTER_TYPE_P (TREE_TYPE (ptr)) - || (TREE_CODE (decl) != VAR_DECL + || (!VAR_P (decl) && TREE_CODE (decl) != PARM_DECL && TREE_CODE (decl) != RESULT_DECL)) return true; @@ -338,7 +338,7 @@ ptrs_compare_unequal (tree ptr1, tree ptr2) tree tem = get_base_address (TREE_OPERAND (ptr1, 0)); if (! tem) return false; - if (TREE_CODE (tem) == VAR_DECL + if (VAR_P (tem) || TREE_CODE (tem) == PARM_DECL || TREE_CODE (tem) == RESULT_DECL) obj1 = tem; @@ -350,7 +350,7 @@ ptrs_compare_unequal (tree ptr1, tree ptr2) tree tem = get_base_address (TREE_OPERAND (ptr2, 0)); if (! tem) return false; - if (TREE_CODE (tem) == VAR_DECL + if (VAR_P (tem) || TREE_CODE (tem) == PARM_DECL || TREE_CODE (tem) == RESULT_DECL) obj2 = tem; @@ -1819,9 +1819,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref) /* Check if base is a global static variable that is not read by the function. */ - if (callee != NULL_TREE - && TREE_CODE (base) == VAR_DECL - && TREE_STATIC (base)) + if (callee != NULL_TREE && VAR_P (base) && TREE_STATIC (base)) { struct cgraph_node *node = cgraph_node::get (callee); bitmap not_read; @@ -2208,9 +2206,7 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref) /* Check if base is a global static variable that is not written by the function. */ - if (callee != NULL_TREE - && TREE_CODE (base) == VAR_DECL - && TREE_STATIC (base)) + if (callee != NULL_TREE && VAR_P (base) && TREE_STATIC (base)) { struct cgraph_node *node = cgraph_node::get (callee); bitmap not_written; diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 954fc67ee0d..7b9814e1aa7 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1093,7 +1093,7 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb) && is_gimple_val (gimple_assign_rhs1 (stmt))) { tree lhs = gimple_assign_lhs (stmt); - if ((TREE_CODE (lhs) == VAR_DECL || TREE_CODE (lhs) == PARM_DECL) + if ((VAR_P (lhs) || TREE_CODE (lhs) == PARM_DECL) && !DECL_IGNORED_P (lhs) && is_gimple_reg_type (TREE_TYPE (lhs)) && !is_global_var (lhs) diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c index 72ee4e3cef1..b9eef201ddd 100644 --- a/gcc/tree-ssa-live.c +++ b/gcc/tree-ssa-live.c @@ -329,7 +329,7 @@ mark_all_vars_used_1 (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) /* Only need to mark VAR_DECLS; parameters and return results are not eliminated as unused. */ - if (TREE_CODE (t) == VAR_DECL) + if (VAR_P (t)) { /* When a global var becomes used for the first time also walk its initializer (non global ones don't have any). */ @@ -425,7 +425,7 @@ remove_unused_scope_block_p (tree scope, bool in_ctor_dtor_block) SET_DEST overlaps with others, and if the value expr changes by virtual register instantiation, we may get end up with different results. */ - else if (TREE_CODE (*t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*t)) + else if (VAR_P (*t) && DECL_HAS_VALUE_EXPR_P (*t)) unused = false; /* Remove everything we don't generate debug info for. */ @@ -791,7 +791,7 @@ remove_unused_locals (void) tree base = get_base_address (lhs); /* Remove clobbers referencing unused vars, or clobbers with MEM_REF lhs referencing uninitialized pointers. */ - if ((TREE_CODE (base) == VAR_DECL && !is_used_p (base)) + if ((VAR_P (base) && !is_used_p (base)) || (TREE_CODE (lhs) == MEM_REF && TREE_CODE (TREE_OPERAND (lhs, 0)) == SSA_NAME && SSA_NAME_IS_DEFAULT_DEF (TREE_OPERAND (lhs, 0)) @@ -825,7 +825,7 @@ remove_unused_locals (void) for (srcidx = 0, dstidx = 0; srcidx < num; srcidx++) { var = (*cfun->local_decls)[srcidx]; - if (TREE_CODE (var) == VAR_DECL) + if (VAR_P (var)) { if (!is_used_p (var)) { @@ -842,9 +842,7 @@ remove_unused_locals (void) continue; } } - if (TREE_CODE (var) == VAR_DECL - && DECL_HARD_REGISTER (var) - && !is_global_var (var)) + if (VAR_P (var) && DECL_HARD_REGISTER (var) && !is_global_var (var)) cfun->has_local_explicit_reg_vars = true; if (srcidx != dstidx) diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 7f78734ea22..93626fd028f 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4383,7 +4383,7 @@ force_expr_to_var_cost (tree expr, bool speed) { tree obj = TREE_OPERAND (expr, 0); - if (TREE_CODE (obj) == VAR_DECL + if (VAR_P (obj) || TREE_CODE (obj) == PARM_DECL || TREE_CODE (obj) == RESULT_DECL) return comp_cost (symbol_cost [speed], 0); @@ -4530,7 +4530,7 @@ split_address_cost (struct ivopts_data *data, if (toffset != 0 || bitpos % BITS_PER_UNIT != 0 || reversep - || TREE_CODE (core) != VAR_DECL) + || !VAR_P (core)) { *symbol_present = false; *var_present = true; diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index a74f0834dfa..2a4ab2f4dc6 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -385,8 +385,7 @@ new_var_info (tree t, const char *name, bool add_id) ret->is_global_var = (is_global_var (t) /* We have to treat even local register variables as escape points. */ - || (TREE_CODE (t) == VAR_DECL - && DECL_HARD_REGISTER (t))); + || (VAR_P (t) && DECL_HARD_REGISTER (t))); ret->solution = BITMAP_ALLOC (&pta_obstack); ret->oldsolution = NULL; ret->next = 0; @@ -2929,8 +2928,7 @@ get_constraint_for_ssa_var (tree t, vec *results, bool address_p) } /* For global variables resort to the alias target. */ - if (TREE_CODE (t) == VAR_DECL - && (TREE_STATIC (t) || DECL_EXTERNAL (t))) + if (VAR_P (t) && (TREE_STATIC (t) || DECL_EXTERNAL (t))) { varpool_node *node = varpool_node::get (t); if (node && node->alias && node->analyzed) @@ -6043,7 +6041,7 @@ create_variable_info_for (tree decl, const char *name, bool add_id) insert_vi_for_tree (decl, vi); - if (TREE_CODE (decl) != VAR_DECL) + if (!VAR_P (decl)) return id; /* Create initial constraints for globals. */ @@ -6319,7 +6317,7 @@ set_uids_in_ptset (bitmap into, bitmap from, struct pt_solution *pt, if (vi->is_restrict_var) pt->vars_contains_restrict = true; - if (TREE_CODE (vi->decl) == VAR_DECL + if (VAR_P (vi->decl) || TREE_CODE (vi->decl) == PARM_DECL || TREE_CODE (vi->decl) == RESULT_DECL) { @@ -7290,7 +7288,7 @@ visit_loadstore (gimple *, tree base, tree ref, void *data) /* For plain decl accesses see whether they are accesses to globals and rewrite them to MEM_REFs with { clique, 0 }. */ - if (TREE_CODE (base) == VAR_DECL + if (VAR_P (base) && is_global_var (base) /* ??? We can't rewrite a plain decl with the walk_stmt_load_store ops callback. */ @@ -7299,7 +7297,7 @@ visit_loadstore (gimple *, tree base, tree ref, void *data) tree *basep = &ref; while (handled_component_p (*basep)) basep = &TREE_OPERAND (*basep, 0); - gcc_assert (TREE_CODE (*basep) == VAR_DECL); + gcc_assert (VAR_P (*basep)); tree ptr = build_fold_addr_expr (*basep); tree zero = build_int_cst (TREE_TYPE (ptr), 0); *basep = build2 (MEM_REF, TREE_TYPE (*basep), ptr, zero); diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index d5f03442c3d..13448548e0e 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -244,7 +244,7 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized) tree base = get_base_address (rhs); /* Do not warn if it can be initialized outside this function. */ - if (TREE_CODE (base) != VAR_DECL + if (!VAR_P (base) || DECL_HARD_REGISTER (base) || is_global_var (base)) continue; diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 261d9b0c90b..135952bc339 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -246,8 +246,7 @@ target_for_debug_bind (tree var) return NULL_TREE; } - if ((TREE_CODE (var) != VAR_DECL - || VAR_DECL_IS_VIRTUAL_OPERAND (var)) + if ((!VAR_P (var) || VAR_DECL_IS_VIRTUAL_OPERAND (var)) && TREE_CODE (var) != PARM_DECL) return NULL_TREE; @@ -974,7 +973,7 @@ verify_phi_args (gphi *phi, basic_block bb, basic_block *definition_block) tree base = TREE_OPERAND (op, 0); while (handled_component_p (base)) base = TREE_OPERAND (base, 0); - if ((TREE_CODE (base) == VAR_DECL + if ((VAR_P (base) || TREE_CODE (base) == PARM_DECL || TREE_CODE (base) == RESULT_DECL) && !TREE_ADDRESSABLE (base)) @@ -1246,7 +1245,7 @@ ssa_undefined_value_p (tree t, bool partial) else if (TREE_CODE (var) == RESULT_DECL && DECL_BY_REFERENCE (var)) return false; /* Hard register variables get their initial value from the ether. */ - else if (TREE_CODE (var) == VAR_DECL && DECL_HARD_REGISTER (var)) + else if (VAR_P (var) && DECL_HARD_REGISTER (var)) return false; /* The value is undefined iff its definition statement is empty. */ @@ -1538,7 +1537,7 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs, && (TREE_CODE (TREE_TYPE (var)) == COMPLEX_TYPE || TREE_CODE (TREE_TYPE (var)) == VECTOR_TYPE) && !TREE_THIS_VOLATILE (var) - && (TREE_CODE (var) != VAR_DECL || !DECL_HARD_REGISTER (var))) + && (!VAR_P (var) || !DECL_HARD_REGISTER (var))) { DECL_GIMPLE_REG_P (var) = 1; bitmap_set_bit (suitable_for_renaming, DECL_UID (var)); diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 91a8f97ebea..64ab13a2048 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -260,7 +260,7 @@ make_ssa_name_fn (struct function *fn, tree var, gimple *stmt) tree t; use_operand_p imm; - gcc_assert (TREE_CODE (var) == VAR_DECL + gcc_assert (VAR_P (var) || TREE_CODE (var) == PARM_DECL || TREE_CODE (var) == RESULT_DECL || (TYPE_P (var) && is_gimple_reg_type (var))); diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index 0c5e4309206..ba7ee8cdd7a 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -273,7 +273,7 @@ find_va_list_reference (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, if (bitmap_bit_p (va_list_vars, SSA_NAME_VERSION (var))) return var; } - else if (TREE_CODE (var) == VAR_DECL) + else if (VAR_P (var)) { if (bitmap_bit_p (va_list_vars, DECL_UID (var) + num_ssa_names)) return var; @@ -358,7 +358,7 @@ va_list_counter_struct_op (struct stdarg_info *si, tree ap, tree var, return false; base = get_base_address (ap); - if (TREE_CODE (base) != VAR_DECL + if (!VAR_P (base) || !bitmap_bit_p (si->va_list_vars, DECL_UID (base) + num_ssa_names)) return false; @@ -377,7 +377,7 @@ va_list_counter_struct_op (struct stdarg_info *si, tree ap, tree var, static bool va_list_ptr_read (struct stdarg_info *si, tree ap, tree tem) { - if (TREE_CODE (ap) != VAR_DECL + if (!VAR_P (ap) || !bitmap_bit_p (si->va_list_vars, DECL_UID (ap) + num_ssa_names)) return false; @@ -427,7 +427,7 @@ va_list_ptr_write (struct stdarg_info *si, tree ap, tree tem2) { unsigned HOST_WIDE_INT increment; - if (TREE_CODE (ap) != VAR_DECL + if (!VAR_P (ap) || !bitmap_bit_p (si->va_list_vars, DECL_UID (ap) + num_ssa_names)) return false; @@ -622,7 +622,7 @@ check_all_va_list_escapes (struct stdarg_info *si) SSA_NAME_VERSION (lhs))) continue; - if (TREE_CODE (lhs) == VAR_DECL + if (VAR_P (lhs) && bitmap_bit_p (si->va_list_vars, DECL_UID (lhs) + num_ssa_names)) continue; @@ -731,7 +731,7 @@ optimize_va_list_gpr_fpr_size (function *fun) } if (TYPE_MAIN_VARIANT (TREE_TYPE (ap)) != TYPE_MAIN_VARIANT (targetm.fn_abi_va_list (fun->decl)) - || TREE_CODE (ap) != VAR_DECL) + || !VAR_P (ap)) { va_list_escapes = true; break; diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index 671ce31d301..e5cc5a05045 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -251,7 +251,7 @@ unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) expr->decl_common.off_align = bp_unpack_value (bp, 8); } - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) { DECL_HAS_DEBUG_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_NONLOCAL_FRAME (expr) = (unsigned) bp_unpack_value (bp, 1); @@ -259,11 +259,10 @@ unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) if (TREE_CODE (expr) == RESULT_DECL || TREE_CODE (expr) == PARM_DECL - || TREE_CODE (expr) == VAR_DECL) + || VAR_P (expr)) { DECL_BY_REFERENCE (expr) = (unsigned) bp_unpack_value (bp, 1); - if (TREE_CODE (expr) == VAR_DECL - || TREE_CODE (expr) == PARM_DECL) + if (VAR_P (expr) || TREE_CODE (expr) == PARM_DECL) DECL_HAS_VALUE_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1); } } @@ -293,7 +292,7 @@ unpack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr) DECL_VISIBILITY (expr) = (enum symbol_visibility) bp_unpack_value (bp, 2); DECL_VISIBILITY_SPECIFIED (expr) = (unsigned) bp_unpack_value (bp, 1); - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) { DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_IN_CONSTANT_POOL (expr) = (unsigned) bp_unpack_value (bp, 1); @@ -712,12 +711,11 @@ lto_input_ts_decl_common_tree_pointers (struct lto_input_block *ib, for early inlining so drop it on the floor instead of ICEing in dwarf2out.c. */ - if ((TREE_CODE (expr) == VAR_DECL - || TREE_CODE (expr) == PARM_DECL) + if ((VAR_P (expr) || TREE_CODE (expr) == PARM_DECL) && DECL_HAS_VALUE_EXPR_P (expr)) SET_DECL_VALUE_EXPR (expr, stream_read_tree (ib, data_in)); - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) { tree dexpr = stream_read_tree (ib, data_in); if (dexpr) diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c index 887448e5808..cedeabc334b 100644 --- a/gcc/tree-streamer-out.c +++ b/gcc/tree-streamer-out.c @@ -214,7 +214,7 @@ pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) bp_pack_value (bp, expr->decl_common.off_align, 8); } - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) { bp_pack_value (bp, DECL_HAS_DEBUG_EXPR_P (expr), 1); bp_pack_value (bp, DECL_NONLOCAL_FRAME (expr), 1); @@ -222,11 +222,10 @@ pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) if (TREE_CODE (expr) == RESULT_DECL || TREE_CODE (expr) == PARM_DECL - || TREE_CODE (expr) == VAR_DECL) + || VAR_P (expr)) { bp_pack_value (bp, DECL_BY_REFERENCE (expr), 1); - if (TREE_CODE (expr) == VAR_DECL - || TREE_CODE (expr) == PARM_DECL) + if (VAR_P (expr) || TREE_CODE (expr) == PARM_DECL) bp_pack_value (bp, DECL_HAS_VALUE_EXPR_P (expr), 1); } } @@ -256,7 +255,7 @@ pack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr) bp_pack_value (bp, DECL_VISIBILITY (expr), 2); bp_pack_value (bp, DECL_VISIBILITY_SPECIFIED (expr), 1); - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) { bp_pack_value (bp, DECL_HARD_REGISTER (expr), 1); /* DECL_IN_TEXT_SECTION is set during final asm output only. */ @@ -589,12 +588,11 @@ write_ts_decl_common_tree_pointers (struct output_block *ob, tree expr, for early inlining so drop it on the floor instead of ICEing in dwarf2out.c. */ - if ((TREE_CODE (expr) == VAR_DECL - || TREE_CODE (expr) == PARM_DECL) + if ((VAR_P (expr) || TREE_CODE (expr) == PARM_DECL) && DECL_HAS_VALUE_EXPR_P (expr)) stream_write_tree (ob, DECL_VALUE_EXPR (expr), ref_p); - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) stream_write_tree (ob, DECL_DEBUG_EXPR (expr), ref_p); } diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 7c5f1010b9c..6cf26d9c367 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -5977,7 +5977,7 @@ vect_record_grouped_load_vectors (gimple *stmt, vec result_chain) bool vect_can_force_dr_alignment_p (const_tree decl, unsigned int alignment) { - if (TREE_CODE (decl) != VAR_DECL) + if (!VAR_P (decl)) return false; if (decl_in_symtab_p (decl) diff --git a/gcc/tree.c b/gcc/tree.c index 33e6f979b55..949d2ebe7ef 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -716,7 +716,7 @@ set_decl_section_name (tree node, const char *value) if (!snode) return; } - else if (TREE_CODE (node) == VAR_DECL) + else if (VAR_P (node)) snode = varpool_node::get_create (node); else snode = cgraph_node::get_create (node); @@ -1156,19 +1156,19 @@ copy_node_stat (tree node MEM_STAT_DECL) if (DECL_PT_UID_SET_P (node)) SET_DECL_PT_UID (t, DECL_PT_UID (node)); } - if ((TREE_CODE (node) == PARM_DECL || TREE_CODE (node) == VAR_DECL) + if ((TREE_CODE (node) == PARM_DECL || VAR_P (node)) && DECL_HAS_VALUE_EXPR_P (node)) { SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node)); DECL_HAS_VALUE_EXPR_P (t) = 1; } /* DECL_DEBUG_EXPR is copied explicitely by callers. */ - if (TREE_CODE (node) == VAR_DECL) + if (VAR_P (node)) { DECL_HAS_DEBUG_EXPR_P (t) = 0; t->decl_with_vis.symtab_node = NULL; } - if (TREE_CODE (node) == VAR_DECL && DECL_HAS_INIT_PRIORITY_P (node)) + if (VAR_P (node) && DECL_HAS_INIT_PRIORITY_P (node)) { SET_DECL_INIT_PRIORITY (t, DECL_INIT_PRIORITY (node)); DECL_HAS_INIT_PRIORITY_P (t) = 1; @@ -5330,8 +5330,7 @@ need_assembler_name_p (tree decl) && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)) return !DECL_ASSEMBLER_NAME_SET_P (decl); /* Only FUNCTION_DECLs and VAR_DECLs are considered. */ - if (TREE_CODE (decl) != FUNCTION_DECL - && TREE_CODE (decl) != VAR_DECL) + if (!VAR_OR_FUNCTION_DECL_P (decl)) return false; /* If DECL already has its assembler name set, it does not need a @@ -5346,7 +5345,7 @@ need_assembler_name_p (tree decl) /* For VAR_DECLs, only static, public and external symbols need an assembler name. */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && !TREE_STATIC (decl) && !TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl)) @@ -5460,7 +5459,7 @@ free_lang_data_in_decl (tree decl) if (DECL_VINDEX (decl) && !tree_fits_shwi_p (DECL_VINDEX (decl))) DECL_VINDEX (decl) = NULL_TREE; } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) { if ((DECL_EXTERNAL (decl) && (!TREE_STATIC (decl) || !TREE_READONLY (decl))) @@ -5632,7 +5631,7 @@ find_decls_types_r (tree *tp, int *ws, void *data) fld_worklist_push (DECL_FCONTEXT (t), fld); } - if ((TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL) + if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL) && DECL_HAS_VALUE_EXPR_P (t)) fld_worklist_push (DECL_VALUE_EXPR (t), fld); @@ -6329,14 +6328,13 @@ merge_dllimport_decl_attributes (tree old, tree new_tree) decl may already have had TREE_CONSTANT computed. We still remove the attribute so that assembler code refers to '&foo rather than '_imp__foo'. */ - if (TREE_CODE (old) == VAR_DECL && TREE_ADDRESSABLE (old)) + if (VAR_P (old) && TREE_ADDRESSABLE (old)) DECL_DLLIMPORT_P (new_tree) = 1; } /* Let an inline definition silently override the external reference, but otherwise warn about attribute inconsistency. */ - else if (TREE_CODE (new_tree) == VAR_DECL - || !DECL_DECLARED_INLINE_P (new_tree)) + else if (VAR_P (new_tree) || !DECL_DECLARED_INLINE_P (new_tree)) warning (OPT_Wattributes, "%q+D redeclared without dllimport attribute: " "previous dllimport ignored", new_tree); } @@ -6387,9 +6385,7 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags, } } - if (TREE_CODE (node) != FUNCTION_DECL - && TREE_CODE (node) != VAR_DECL - && TREE_CODE (node) != TYPE_DECL) + if (!VAR_OR_FUNCTION_DECL_P (node) && TREE_CODE (node) != TYPE_DECL) { *no_add_attrs = true; warning (OPT_Wattributes, "%qE attribute ignored", @@ -6432,7 +6428,7 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags, *no_add_attrs = true; } - else if (TREE_CODE (node) == VAR_DECL) + else if (VAR_P (node)) { if (DECL_INITIAL (node)) { @@ -6460,9 +6456,7 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags, DECL_EXTERNAL (node) = 0; /* Report error if symbol is not accessible at global scope. */ - if (!TREE_PUBLIC (node) - && (TREE_CODE (node) == VAR_DECL - || TREE_CODE (node) == FUNCTION_DECL)) + if (!TREE_PUBLIC (node) && VAR_OR_FUNCTION_DECL_P (node)) { error ("external linkage required for symbol %q+D because of " "%qE attribute", node, name); @@ -6822,7 +6816,7 @@ decl_init_priority_insert (tree decl, priority_type priority) if (!snode) return; } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) snode = varpool_node::get_create (decl); else snode = cgraph_node::get_create (decl); @@ -9196,7 +9190,7 @@ bool auto_var_in_fn_p (const_tree var, const_tree fn) { return (DECL_P (var) && DECL_CONTEXT (var) == fn - && ((((TREE_CODE (var) == VAR_DECL && ! DECL_EXTERNAL (var)) + && ((((VAR_P (var) && ! DECL_EXTERNAL (var)) || TREE_CODE (var) == PARM_DECL) && ! TREE_STATIC (var)) || TREE_CODE (var) == LABEL_DECL @@ -13139,7 +13133,7 @@ array_at_struct_end_p (tree ref) && (!size || (DECL_SIZE (ref) != NULL && operand_equal_p (DECL_SIZE (ref), size, 0))) && !(flag_unconstrained_commons - && TREE_CODE (ref) == VAR_DECL && DECL_COMMON (ref))) + && VAR_P (ref) && DECL_COMMON (ref))) return false; return true; @@ -13971,7 +13965,7 @@ verify_type (const_tree t) ; else if (TREE_CODE (fld) == CONST_DECL) ; - else if (TREE_CODE (fld) == VAR_DECL) + else if (VAR_P (fld)) ; else if (TREE_CODE (fld) == TEMPLATE_DECL) ; diff --git a/gcc/tsan.c b/gcc/tsan.c index cc194749665..317bf6d2dac 100644 --- a/gcc/tsan.c +++ b/gcc/tsan.c @@ -128,9 +128,7 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write) return false; } - if (TREE_READONLY (base) - || (TREE_CODE (base) == VAR_DECL - && DECL_HARD_REGISTER (base))) + if (TREE_READONLY (base) || (VAR_P (base) && DECL_HARD_REGISTER (base))) return false; stmt = gsi_stmt (gsi); diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 8818de4f372..5fe6f3d0e2a 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1369,7 +1369,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi) &unsignedp, &reversep, &volatilep); tree utype = build_nonstandard_integer_type (modebitsize, 1); - if ((TREE_CODE (base) == VAR_DECL && DECL_HARD_REGISTER (base)) + if ((VAR_P (base) && DECL_HARD_REGISTER (base)) || (bitpos % modebitsize) != 0 || bitsize != modebitsize || GET_MODE_BITSIZE (TYPE_MODE (utype)) != modebitsize diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 07b3e079aaa..e405f0d81b3 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -1810,8 +1810,7 @@ vars_copy (variable_table_type *dst, variable_table_type *src) static inline tree var_debug_decl (tree decl) { - if (decl && TREE_CODE (decl) == VAR_DECL - && DECL_HAS_DEBUG_EXPR_P (decl)) + if (decl && VAR_P (decl) && DECL_HAS_DEBUG_EXPR_P (decl)) { tree debugdecl = DECL_DEBUG_EXPR (decl); if (DECL_P (debugdecl)) @@ -5145,7 +5144,7 @@ track_expr_p (tree expr, bool need_rtl) return DECL_RTL_SET_P (expr); /* If EXPR is not a parameter or a variable do not track it. */ - if (TREE_CODE (expr) != VAR_DECL && TREE_CODE (expr) != PARM_DECL) + if (!VAR_P (expr) && TREE_CODE (expr) != PARM_DECL) return 0; /* It also must have a name... */ @@ -5161,7 +5160,7 @@ track_expr_p (tree expr, bool need_rtl) don't need to track this expression if the ultimate declaration is ignored. */ realdecl = expr; - if (TREE_CODE (realdecl) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (realdecl)) + if (VAR_P (realdecl) && DECL_HAS_DEBUG_EXPR_P (realdecl)) { realdecl = DECL_DEBUG_EXPR (realdecl); if (!DECL_P (realdecl)) diff --git a/gcc/varasm.c b/gcc/varasm.c index 93aba78e4b5..a03687210c0 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -170,8 +170,7 @@ static GTY(()) section *unnamed_sections; /* Return a nonzero value if DECL has a section attribute. */ #define IN_NAMED_SECTION(DECL) \ - ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \ - && DECL_SECTION_NAME (DECL) != NULL) + (VAR_OR_FUNCTION_DECL_P (DECL) && DECL_SECTION_NAME (DECL) != NULL) struct section_hasher : ggc_ptr_hash
{ @@ -1188,7 +1187,7 @@ get_block_for_decl (tree decl) { section *sect; - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { /* The object must be defined in this translation unit. */ if (DECL_EXTERNAL (decl)) @@ -1209,7 +1208,7 @@ get_block_for_decl (tree decl) /* Find out which section should contain DECL. We cannot put it into an object block if it requires a standalone definition. */ - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) align_variable (decl, 0); sect = get_variable_section (decl, true); if (SECTION_STYLE (sect) == SECTION_NOSWITCH) @@ -1238,7 +1237,7 @@ use_blocks_for_decl_p (tree decl) struct symtab_node *snode; /* Only data DECLs can be placed into object blocks. */ - if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != CONST_DECL) + if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL) return false; /* Detect decls created by dw2_force_const_mem. Such decls are @@ -1250,7 +1249,7 @@ use_blocks_for_decl_p (tree decl) /* If this decl is an alias, then we don't want to emit a definition. */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (snode = symtab_node::get (decl)) != NULL && snode->alias) return false; @@ -1304,7 +1303,7 @@ make_decl_rtl (tree decl) && TREE_CODE (decl) != RESULT_DECL); /* A weak alias has TREE_PUBLIC set but not the other bits. */ - gcc_assert (TREE_CODE (decl) != VAR_DECL + gcc_assert (!VAR_P (decl) || TREE_STATIC (decl) || TREE_PUBLIC (decl) || DECL_EXTERNAL (decl) @@ -1348,7 +1347,7 @@ make_decl_rtl (tree decl) /* If this variable belongs to the global constant pool, retrieve the pre-computed RTL or recompute it in LTO mode. */ - if (TREE_CODE (decl) == VAR_DECL && DECL_IN_CONSTANT_POOL (decl)) + if (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl)) { SET_DECL_RTL (decl, output_constant_def (DECL_INITIAL (decl), 1)); return; @@ -1457,7 +1456,7 @@ make_decl_rtl (tree decl) visibility pass is doing the same work. But notice_global_symbol is called early and it needs to make DECL_RTL to get the name. we take care of recomputing the DECL_RTL after visibility is changed. */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)) && DECL_SECTION_NAME (decl) != NULL && DECL_INITIAL (decl) == NULL_TREE @@ -1465,7 +1464,7 @@ make_decl_rtl (tree decl) DECL_COMMON (decl) = 0; /* Variables can't be both common and weak. */ - if (TREE_CODE (decl) == VAR_DECL && DECL_WEAK (decl)) + if (VAR_P (decl) && DECL_WEAK (decl)) DECL_COMMON (decl) = 0; if (use_object_blocks_p () && use_blocks_for_decl_p (decl)) @@ -1639,9 +1638,9 @@ notice_global_symbol (tree decl) || !TREE_PUBLIC (decl) || DECL_EXTERNAL (decl) || !DECL_NAME (decl) - || (TREE_CODE (decl) == VAR_DECL && DECL_HARD_REGISTER (decl)) + || (VAR_P (decl) && DECL_HARD_REGISTER (decl)) || (TREE_CODE (decl) != FUNCTION_DECL - && (TREE_CODE (decl) != VAR_DECL + && (!VAR_P (decl) || (DECL_COMMON (decl) && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))))) @@ -2111,7 +2110,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, bool asan_protected = false; /* This function is supposed to handle VARIABLES. Ensure we have one. */ - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); /* Emulated TLS had better not get this far. */ gcc_checking_assert (targetm.have_tls || !DECL_THREAD_LOCAL_P (decl)); @@ -2487,7 +2486,7 @@ mark_decl_referenced (tree decl) && !node->definition) node->mark_force_output (); } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) { varpool_node *node = varpool_node::get_create (decl); /* C++ frontend use mark_decl_references to force COMDAT variables @@ -3272,8 +3271,7 @@ build_constant_desc (tree exp) if (use_object_blocks_p ()) { int align = (TREE_CODE (decl) == CONST_DECL - || (TREE_CODE (decl) == VAR_DECL - && DECL_IN_CONSTANT_POOL (decl)) + || (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl)) ? DECL_ALIGN (decl) : symtab_node::get (decl)->definition_alignment ()); section *sect = get_constant_section (exp, align); @@ -3430,8 +3428,7 @@ output_constant_def_contents (rtx symbol) else { int align = (TREE_CODE (decl) == CONST_DECL - || (TREE_CODE (decl) == VAR_DECL - && DECL_IN_CONSTANT_POOL (decl)) + || (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl)) ? DECL_ALIGN (decl) : symtab_node::get (decl)->definition_alignment ()); switch_to_section (get_constant_section (exp, align)); @@ -5619,7 +5616,7 @@ do_assemble_alias (tree decl, tree target) /* Emulated TLS had better not get this var. */ gcc_assert (!(!targetm.have_tls - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && DECL_THREAD_LOCAL_P (decl))); if (TREE_ASM_WRITTEN (decl)) @@ -6022,12 +6019,11 @@ void make_decl_one_only (tree decl, tree comdat_group) { struct symtab_node *symbol; - gcc_assert (TREE_CODE (decl) == VAR_DECL - || TREE_CODE (decl) == FUNCTION_DECL); + gcc_assert (VAR_OR_FUNCTION_DECL_P (decl)); TREE_PUBLIC (decl) = 1; - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) symbol = varpool_node::get_create (decl); else symbol = cgraph_node::get_create (decl); @@ -6039,7 +6035,7 @@ make_decl_one_only (tree decl, tree comdat_group) #endif symbol->set_comdat_group (comdat_group); } - else if (TREE_CODE (decl) == VAR_DECL + else if (VAR_P (decl) && (DECL_INITIAL (decl) == 0 || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node))) DECL_COMMON (decl) = 1; @@ -6190,7 +6186,7 @@ default_section_type_flags (tree decl, const char *name, int reloc) if (strcmp (name, ".vtable_map_vars") == 0) flags |= SECTION_LINKONCE; - if (decl && TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) + if (decl && VAR_P (decl) && DECL_THREAD_LOCAL_P (decl)) flags |= SECTION_TLS | SECTION_WRITE; if (strcmp (name, ".bss") == 0 @@ -6412,7 +6408,7 @@ categorize_decl_for_section (const_tree decl, int reloc) else return SECCAT_RODATA_MERGE_STR; } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) { if (bss_initializer_p (decl)) ret = SECCAT_BSS; @@ -6456,7 +6452,7 @@ categorize_decl_for_section (const_tree decl, int reloc) ret = SECCAT_RODATA; /* There are no read-only thread-local sections. */ - if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) + if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl)) { /* Note that this would be *just* SECCAT_BSS, except that there's no concept of a read-only thread-local-data section. */ @@ -6732,7 +6728,7 @@ default_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED) flags |= SYMBOL_FLAG_FUNCTION; if (targetm.binds_local_p (decl)) flags |= SYMBOL_FLAG_LOCAL; - if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) + if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl)) flags |= DECL_TLS_MODEL (decl) << SYMBOL_FLAG_TLS_SHIFT; else if (targetm.in_small_data_p (decl)) flags |= SYMBOL_FLAG_SMALL; diff --git a/gcc/varpool.c b/gcc/varpool.c index e5f991eb759..78969d28c1c 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -142,7 +142,7 @@ varpool_node * varpool_node::get_create (tree decl) { varpool_node *node = varpool_node::get (decl); - gcc_checking_assert (TREE_CODE (decl) == VAR_DECL); + gcc_checking_assert (VAR_P (decl)); if (node) return node; @@ -395,8 +395,7 @@ ctor_for_folding (tree decl) varpool_node *node, *real_node; tree real_decl; - if (TREE_CODE (decl) != VAR_DECL - && TREE_CODE (decl) != CONST_DECL) + if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL) return error_mark_node; /* Static constant bounds are created to be @@ -420,7 +419,7 @@ ctor_for_folding (tree decl) return error_mark_node; } - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); real_node = node = varpool_node::get (decl); if (node) @@ -579,7 +578,7 @@ varpool_node::assemble_decl (void) return false; gcc_checking_assert (!TREE_ASM_WRITTEN (decl) - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && !DECL_HAS_VALUE_EXPR_P (decl)); if (!in_other_partition @@ -713,7 +712,7 @@ varpool_node::finalize_named_section_flags (void) && !alias && !in_other_partition && !DECL_EXTERNAL (decl) - && TREE_CODE (decl) == VAR_DECL + && VAR_P (decl) && !DECL_HAS_VALUE_EXPR_P (decl) && get_section ()) get_variable_section (decl, false); @@ -768,8 +767,8 @@ varpool_node::create_alias (tree alias, tree decl) { varpool_node *alias_node; - gcc_assert (TREE_CODE (decl) == VAR_DECL); - gcc_assert (TREE_CODE (alias) == VAR_DECL); + gcc_assert (VAR_P (decl)); + gcc_assert (VAR_P (alias)); alias_node = varpool_node::get_create (alias); alias_node->alias = true; alias_node->definition = true; diff --git a/gcc/vtable-verify.c b/gcc/vtable-verify.c index b076af4061e..cd3841e5336 100644 --- a/gcc/vtable-verify.c +++ b/gcc/vtable-verify.c @@ -718,7 +718,7 @@ verify_bb_vtables (basic_block bb) vtable_map_node->is_used = true; vtbl_var_decl = vtable_map_node->vtbl_map_decl; - if (TREE_CODE (vtbl_decl) == VAR_DECL) + if (VAR_P (vtbl_decl)) vtable_name = IDENTIFIER_POINTER (DECL_NAME (vtbl_decl)); /* Call different routines if we are interested in -- 2.30.2