From ea6e17d5c008e7df184e00e50be3bf078e002634 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 25 Jul 2016 12:35:08 +0000 Subject: [PATCH] cgraph.c (cgraph_node::verify_node): Compare against builtin by using DECL_BUILT_IN_CLASS and DECL_FUNCTION_CODE. 2016-07-25 Richard Biener * cgraph.c (cgraph_node::verify_node): Compare against builtin by using DECL_BUILT_IN_CLASS and DECL_FUNCTION_CODE. * tree-chkp.c (chkp_gimple_call_builtin_p): Likewise. * tree-streamer.h (streamer_handle_as_builtin_p): Remove. (streamer_get_builtin_tree): Likewise. (streamer_write_builtin): Likewise. * lto-streamer.h (LTO_builtin_decl): Remove. * lto-streamer-in.c (lto_read_tree_1): Remove assert. (lto_input_scc): Remove LTO_builtin_decl handling. (lto_input_tree_1): Liekwise. * lto-streamer-out.c (lto_output_tree_1): Remove special handling of builtins. (DFS::DFS): Likewise. * tree-streamer-in.c (streamer_get_builtin_tree): Remove. * tree-streamer-out.c (pack_ts_function_decl_value_fields): Remove assert. (streamer_write_builtin): Remove. lto/ * lto.c (compare_tree_sccs_1): Remove streamer_handle_as_builtin_p uses. (unify_scc): Likewise. (lto_read_decls): Likewise. From-SVN: r238709 --- gcc/ChangeLog | 20 ++++++++++++++ gcc/cgraph.c | 5 ++-- gcc/lto-streamer-in.c | 11 -------- gcc/lto-streamer-out.c | 25 +++++------------ gcc/lto-streamer.h | 3 --- gcc/lto/ChangeLog | 6 +++++ gcc/lto/lto.c | 12 ++------- gcc/tree-chkp.c | 5 ++-- gcc/tree-streamer-in.c | 59 ----------------------------------------- gcc/tree-streamer-out.c | 39 --------------------------- gcc/tree-streamer.h | 13 --------- 11 files changed, 41 insertions(+), 157 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e8952cbba74..b55a00c9b3b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2016-07-25 Richard Biener + + * cgraph.c (cgraph_node::verify_node): Compare against builtin + by using DECL_BUILT_IN_CLASS and DECL_FUNCTION_CODE. + * tree-chkp.c (chkp_gimple_call_builtin_p): Likewise. + * tree-streamer.h (streamer_handle_as_builtin_p): Remove. + (streamer_get_builtin_tree): Likewise. + (streamer_write_builtin): Likewise. + * lto-streamer.h (LTO_builtin_decl): Remove. + * lto-streamer-in.c (lto_read_tree_1): Remove assert. + (lto_input_scc): Remove LTO_builtin_decl handling. + (lto_input_tree_1): Liekwise. + * lto-streamer-out.c (lto_output_tree_1): Remove special + handling of builtins. + (DFS::DFS): Likewise. + * tree-streamer-in.c (streamer_get_builtin_tree): Remove. + * tree-streamer-out.c (pack_ts_function_decl_value_fields): Remove + assert. + (streamer_write_builtin): Remove. + 2016-07-25 Martin Liska * lto-cgraph.c (input_symtab): Don't call get_working_sets diff --git a/gcc/cgraph.c b/gcc/cgraph.c index e256dd05d35..9bc5b6b7c51 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3136,8 +3136,9 @@ cgraph_node::verify_node (void) && !e->speculative /* Optimized out calls are redirected to __builtin_unreachable. */ && (e->frequency - || e->callee->decl - != builtin_decl_implicit (BUILT_IN_UNREACHABLE)) + || ! e->callee->decl + || DECL_BUILT_IN_CLASS (e->callee->decl) != BUILT_IN_NORMAL + || DECL_FUNCTION_CODE (e->callee->decl) != BUILT_IN_UNREACHABLE) && (e->frequency != compute_call_stmt_bb_frequency (e->caller->decl, gimple_bb (e->call_stmt)))) diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 00db94eac6b..1d56d21fcfd 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -1302,10 +1302,6 @@ lto_read_tree_1 (struct lto_input_block *ib, struct data_in *data_in, tree expr) && TREE_CODE (expr) != TRANSLATION_UNIT_DECL) DECL_INITIAL (expr) = stream_read_tree (ib, data_in); - /* We should never try to instantiate an MD or NORMAL builtin here. */ - if (TREE_CODE (expr) == FUNCTION_DECL) - gcc_assert (!streamer_handle_as_builtin_p (expr)); - #ifdef LTO_STREAMER_DEBUG /* Remove the mapping to RESULT's original address set by streamer_alloc_tree. */ @@ -1368,7 +1364,6 @@ lto_input_scc (struct lto_input_block *ib, struct data_in *data_in, if (tag == LTO_null || (tag >= LTO_field_decl_ref && tag <= LTO_global_decl_ref) || tag == LTO_tree_pickle_reference - || tag == LTO_builtin_decl || tag == LTO_integer_cst || tag == LTO_tree_scc) gcc_unreachable (); @@ -1420,12 +1415,6 @@ lto_input_tree_1 (struct lto_input_block *ib, struct data_in *data_in, the reader cache. */ result = streamer_get_pickled_tree (ib, data_in); } - else if (tag == LTO_builtin_decl) - { - /* If we are going to read a built-in function, all we need is - the code and class. */ - result = streamer_get_builtin_tree (ib, data_in); - } else if (tag == LTO_integer_cst) { /* For shared integer constants in singletons we can use the diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index e243337d8e9..aa6b5892ea5 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -445,17 +445,8 @@ lto_output_tree_1 (struct output_block *ob, tree expr, hashval_t hash, bool exists_p = streamer_tree_cache_insert (ob->writer_cache, expr, hash, &ix); gcc_assert (!exists_p); - if (streamer_handle_as_builtin_p (expr)) - { - /* MD and NORMAL builtins do not need to be written out - completely as they are always instantiated by the - compiler on startup. The only builtins that need to - be written out are BUILT_IN_FRONTEND. For all other - builtins, we simply write the class and code. */ - streamer_write_builtin (ob, expr); - } - else if (TREE_CODE (expr) == INTEGER_CST - && !TREE_OVERFLOW (expr)) + if (TREE_CODE (expr) == INTEGER_CST + && !TREE_OVERFLOW (expr)) { /* Shared INTEGER_CST nodes are special because they need their original type to be materialized by the reader (to implement @@ -559,10 +550,8 @@ DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p, cstate->low = cstate->dfsnum; w.cstate = cstate; - if (streamer_handle_as_builtin_p (expr)) - ; - else if (TREE_CODE (expr) == INTEGER_CST - && !TREE_OVERFLOW (expr)) + if (TREE_CODE (expr) == INTEGER_CST + && !TREE_OVERFLOW (expr)) DFS_write_tree (ob, cstate, TREE_TYPE (expr), ref_p, ref_p); else { @@ -675,8 +664,6 @@ DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p, "in LTO streams", get_tree_code_name (TREE_CODE (t))); - gcc_checking_assert (!streamer_handle_as_builtin_p (t)); - /* Write the header, containing everything needed to materialize EXPR on the reading side. */ streamer_write_tree_header (ob, t); @@ -2074,7 +2061,9 @@ output_function (struct cgraph_node *node) streamer_write_chain (ob, DECL_ARGUMENTS (function), true); /* Output DECL_INITIAL for the function, which contains the tree of - lexical scopes. */ + lexical scopes. + ??? This only streams the outermost block because we do not + recurse into BLOCK_SUBBLOCKS but re-build those on stream-in. */ stream_write_tree (ob, DECL_INITIAL (function), true); /* We also stream abstract functions where we stream only stuff needed for diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 92efdb8e008..ecc1e5d58e5 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -162,9 +162,6 @@ enum LTO_tags /* EH region holding the previous statement. */ LTO_eh_region, - /* An MD or NORMAL builtin. Only the code and class are streamed out. */ - LTO_builtin_decl, - /* Shared INTEGER_CST node. */ LTO_integer_cst, diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 49699096606..86cc8b13459 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +2016-07-25 Richard Biener + + * lto.c (compare_tree_sccs_1): Remove streamer_handle_as_builtin_p uses. + (unify_scc): Likewise. + (lto_read_decls): Likewise. + 2016-06-28 Jakub Jelinek * Make-lang.in: Don't cat ../stage_current if it does not exist. diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index af735cb1793..73d1e26be71 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -1061,12 +1061,6 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map) TREE_FIXED_CST_PTR (t1), TREE_FIXED_CST_PTR (t2))) return false; - - /* We want to compare locations up to the point where it makes - a difference for streaming - thus whether the decl is builtin or not. */ - if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL)) - compare_values (streamer_handle_as_builtin_p); - if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) { compare_values (DECL_MODE); @@ -1602,8 +1596,7 @@ unify_scc (struct data_in *data_in, unsigned from, streamer. The others should be singletons, too, and we should not merge them in any way. */ gcc_assert (code != TRANSLATION_UNIT_DECL - && code != IDENTIFIER_NODE - && !streamer_handle_as_builtin_p (t)); + && code != IDENTIFIER_NODE); } /* Fixup the streamer cache with the prevailing nodes according @@ -1710,8 +1703,7 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, if (len == 1 && (TREE_CODE (first) == IDENTIFIER_NODE || TREE_CODE (first) == INTEGER_CST - || TREE_CODE (first) == TRANSLATION_UNIT_DECL - || streamer_handle_as_builtin_p (first))) + || TREE_CODE (first) == TRANSLATION_UNIT_DECL)) continue; /* Try to unify the SCC with already existing ones. */ diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 4ca2d34607c..44d6d702607 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -431,9 +431,10 @@ chkp_gimple_call_builtin_p (gimple *call, enum built_in_function code) { tree fndecl; - if (is_gimple_call (call) + if (gimple_call_builtin_p (call, BUILT_IN_MD) && (fndecl = targetm.builtin_chkp_function (code)) - && gimple_call_fndecl (call) == fndecl) + && (DECL_FUNCTION_CODE (gimple_call_fndecl (call)) + == DECL_FUNCTION_CODE (fndecl))) return true; return false; } diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index 2ad2f9212fa..671ce31d301 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -1113,62 +1113,3 @@ streamer_get_pickled_tree (struct lto_input_block *ib, struct data_in *data_in) return result; } - - -/* Read a code and class from input block IB and return the - corresponding builtin. DATA_IN is as in stream_read_tree. */ - -tree -streamer_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in) -{ - enum built_in_class fclass; - enum built_in_function fcode; - const char *asmname; - tree result; - - fclass = streamer_read_enum (ib, built_in_class, BUILT_IN_LAST); - gcc_assert (fclass == BUILT_IN_NORMAL || fclass == BUILT_IN_MD); - - fcode = (enum built_in_function) streamer_read_uhwi (ib); - - if (fclass == BUILT_IN_NORMAL) - { - if (fcode >= END_BUILTINS) - fatal_error (input_location, - "machine independent builtin code out of range"); - result = builtin_decl_explicit (fcode); - if (!result) - { - if (fcode > BEGIN_CHKP_BUILTINS && fcode < END_CHKP_BUILTINS) - { - fcode = (enum built_in_function) - (fcode - BEGIN_CHKP_BUILTINS - 1); - result = builtin_decl_explicit (fcode); - result = chkp_maybe_clone_builtin_fndecl (result); - } - else if (fcode > BEGIN_SANITIZER_BUILTINS - && fcode < END_SANITIZER_BUILTINS) - { - initialize_sanitizer_builtins (); - result = builtin_decl_explicit (fcode); - } - } - gcc_assert (result); - } - else if (fclass == BUILT_IN_MD) - { - result = targetm.builtin_decl (fcode, true); - if (!result || result == error_mark_node) - fatal_error (input_location, "target specific builtin not available"); - } - else - gcc_unreachable (); - - asmname = streamer_read_string (data_in, ib); - if (asmname) - set_builtin_user_assembler_name (result, asmname); - - streamer_tree_cache_append (data_in->reader_cache, result, 0); - - return result; -} diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c index a70666b2fd4..887448e5808 100644 --- a/gcc/tree-streamer-out.c +++ b/gcc/tree-streamer-out.c @@ -278,10 +278,6 @@ pack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr) static void pack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr) { - /* For normal/md builtins we only write the class and code, so they - should never be handled here. */ - gcc_assert (!streamer_handle_as_builtin_p (expr)); - bp_pack_enum (bp, built_in_class, BUILT_IN_LAST, DECL_BUILT_IN_CLASS (expr)); bp_pack_value (bp, DECL_STATIC_CONSTRUCTOR (expr), 1); @@ -487,41 +483,6 @@ streamer_write_tree_bitfields (struct output_block *ob, tree expr) } -/* Write the code and class of builtin EXPR to output block OB. IX is - the index into the streamer cache where EXPR is stored.*/ - -void -streamer_write_builtin (struct output_block *ob, tree expr) -{ - gcc_assert (streamer_handle_as_builtin_p (expr)); - - if (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD - && !targetm.builtin_decl) - sorry ("tree bytecode streams do not support machine specific builtin " - "functions on this target"); - - streamer_write_record_start (ob, LTO_builtin_decl); - streamer_write_enum (ob->main_stream, built_in_class, BUILT_IN_LAST, - DECL_BUILT_IN_CLASS (expr)); - streamer_write_uhwi (ob, DECL_FUNCTION_CODE (expr)); - - if (DECL_ASSEMBLER_NAME_SET_P (expr)) - { - /* When the assembler name of a builtin gets a user name, - the new name is always prefixed with '*' by - set_builtin_user_assembler_name. So, to prevent the - reader side from adding a second '*', we omit it here. */ - const char *str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (expr)); - if (strlen (str) > 1 && str[0] == '*') - streamer_write_string (ob, ob->main_stream, &str[1], true); - else - streamer_write_string (ob, ob->main_stream, NULL, true); - } - else - streamer_write_string (ob, ob->main_stream, NULL, true); -} - - /* Emit the chain of tree nodes starting at T. OB is the output block to write to. REF_P is true if chain elements should be emitted as references. */ diff --git a/gcc/tree-streamer.h b/gcc/tree-streamer.h index 41a76a28eb5..1daf259d335 100644 --- a/gcc/tree-streamer.h +++ b/gcc/tree-streamer.h @@ -57,17 +57,6 @@ struct streamer_tree_cache_d unsigned next_idx; }; -/* Return true if tree node EXPR should be streamed as a builtin. For - these nodes, we just emit the class and function code. */ -static inline bool -streamer_handle_as_builtin_p (tree expr) -{ - return (TREE_CODE (expr) == FUNCTION_DECL - && DECL_IS_BUILTIN (expr) - && (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_NORMAL - || DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD)); -} - /* In tree-streamer-in.c. */ tree streamer_read_string_cst (struct data_in *, struct lto_input_block *); tree streamer_read_chain (struct lto_input_block *, struct data_in *); @@ -75,7 +64,6 @@ tree streamer_alloc_tree (struct lto_input_block *, struct data_in *, enum LTO_tags); void streamer_read_tree_body (struct lto_input_block *, struct data_in *, tree); tree streamer_get_pickled_tree (struct lto_input_block *, struct data_in *); -tree streamer_get_builtin_tree (struct lto_input_block *, struct data_in *); void streamer_read_tree_bitfields (struct lto_input_block *, struct data_in *, tree); @@ -87,7 +75,6 @@ void streamer_write_tree_header (struct output_block *, tree); void streamer_write_tree_bitfields (struct output_block *, tree); void streamer_write_tree_body (struct output_block *, tree, bool); void streamer_write_integer_cst (struct output_block *, tree, bool); -void streamer_write_builtin (struct output_block *, tree); /* In tree-streamer.c. */ extern unsigned char streamer_mode_table[1 << 8]; -- 2.30.2