Mercurial > hg > CbC > CbC_gcc
diff gcc/tree-into-ssa.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line diff
--- a/gcc/tree-into-ssa.c Thu Oct 25 07:37:49 2018 +0900 +++ b/gcc/tree-into-ssa.c Thu Feb 13 11:34:05 2020 +0900 @@ -1,5 +1,5 @@ /* Rewrite a program in Normal form into SSA. - Copyright (C) 2001-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2020 Free Software Foundation, Inc. Contributed by Diego Novillo <dnovillo@redhat.com> This file is part of GCC. @@ -940,14 +940,18 @@ if (!blocks_with_phis_to_rewrite) return; - bitmap_set_bit (blocks_with_phis_to_rewrite, idx); - - n = (unsigned) last_basic_block_for_fn (cfun) + 1; - if (phis_to_rewrite.length () < n) - phis_to_rewrite.safe_grow_cleared (n); - - phis = phis_to_rewrite[idx]; - phis.reserve (10); + if (bitmap_set_bit (blocks_with_phis_to_rewrite, idx)) + { + n = (unsigned) last_basic_block_for_fn (cfun) + 1; + if (phis_to_rewrite.length () < n) + phis_to_rewrite.safe_grow_cleared (n); + + phis = phis_to_rewrite[idx]; + gcc_assert (!phis.exists ()); + phis.create (10); + } + else + phis = phis_to_rewrite[idx]; phis.safe_push (phi); phis_to_rewrite[idx] = phis; @@ -1436,20 +1440,12 @@ for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi)) { - tree currdef, res, argvar; + tree currdef, res; location_t loc; phi = gsi.phi (); res = gimple_phi_result (phi); - /* If we have pre-existing PHI (via the GIMPLE FE) its args may - be different vars than existing vars and they may be constants - as well. Note the following supports partial SSA for PHI args. */ - argvar = gimple_phi_arg_def (phi, e->dest_idx); - if (argvar && ! DECL_P (argvar)) - continue; - if (!argvar) - argvar = SSA_NAME_VAR (res); - currdef = get_reaching_def (argvar); + currdef = get_reaching_def (SSA_NAME_VAR (res)); /* Virtual operand PHI args do not need a location. */ if (virtual_operand_p (res)) loc = UNKNOWN_LOCATION; @@ -2119,7 +2115,7 @@ /* Update the argument if there is a reaching def. */ if (reaching_def) { - source_location locus; + location_t locus; int arg_i = PHI_ARG_INDEX_FROM_USE (arg_p); SET_USE (arg_p, reaching_def); @@ -2433,6 +2429,12 @@ bitmap_head *dfs; basic_block bb; + /* Increase the set of variables we can rewrite into SSA form + by clearing TREE_ADDRESSABLE and setting DECL_GIMPLE_REG_P + and transform the IL to support this. */ + if (optimize) + execute_update_addresses_taken (); + /* Initialize operand data structures. */ init_ssa_operands (fun); @@ -2591,11 +2593,9 @@ } } - -/* Do a dominator walk starting at BB processing statements that - reference symbols in SSA operands. This is very similar to - mark_def_sites, but the scan handles statements whose operands may - already be SSA names. +/* Processing statements in BB that reference symbols in SSA operands. + This is very similar to mark_def_sites, but the scan handles + statements whose operands may already be SSA names. If INSERT_PHI_P is true, mark those uses as live in the corresponding block. This is later used by the PHI placement @@ -2608,9 +2608,8 @@ that. */ static void -prepare_block_for_update (basic_block bb, bool insert_phi_p) +prepare_block_for_update_1 (basic_block bb, bool insert_phi_p) { - basic_block son; edge e; edge_iterator ei; @@ -2692,13 +2691,51 @@ } } - /* Now visit all the blocks dominated by BB. */ - for (son = first_dom_son (CDI_DOMINATORS, bb); - son; - son = next_dom_son (CDI_DOMINATORS, son)) - prepare_block_for_update (son, insert_phi_p); } +/* Do a dominator walk starting at BB processing statements that + reference symbols in SSA operands. This is very similar to + mark_def_sites, but the scan handles statements whose operands may + already be SSA names. + + If INSERT_PHI_P is true, mark those uses as live in the + corresponding block. This is later used by the PHI placement + algorithm to make PHI pruning decisions. + + FIXME. Most of this would be unnecessary if we could associate a + symbol to all the SSA names that reference it. But that + sounds like it would be expensive to maintain. Still, it + would be interesting to see if it makes better sense to do + that. */ +static void +prepare_block_for_update (basic_block bb, bool insert_phi_p) +{ + size_t sp = 0; + basic_block *worklist; + + /* Allocate the worklist. */ + worklist = XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun)); + /* Add the BB to the worklist. */ + worklist[sp++] = bb; + + while (sp) + { + basic_block bb; + basic_block son; + + /* Pick a block from the worklist. */ + bb = worklist[--sp]; + + prepare_block_for_update_1 (bb, insert_phi_p); + + /* Now add all the blocks dominated by BB to the worklist. */ + for (son = first_dom_son (CDI_DOMINATORS, bb); + son; + son = next_dom_son (CDI_DOMINATORS, son)) + worklist[sp++] = son; + } + free (worklist); +} /* Helper for prepare_names_to_update. Mark all the use sites for NAME as interesting. BLOCKS and INSERT_PHI_P are as in @@ -2939,11 +2976,7 @@ if (blocks_with_phis_to_rewrite) EXECUTE_IF_SET_IN_BITMAP (blocks_with_phis_to_rewrite, 0, i, bi) - { - vec<gphi *> phis = phis_to_rewrite[i]; - phis.release (); - phis_to_rewrite[i].create (0); - } + phis_to_rewrite[i].release (); BITMAP_FREE (blocks_with_phis_to_rewrite); BITMAP_FREE (blocks_to_update); @@ -3312,7 +3345,7 @@ if (SSA_NAME_IN_FREE_LIST (use)) { - error ("statement uses released SSA name:"); + error ("statement uses released SSA name"); debug_gimple_stmt (stmt); fprintf (stderr, "The use of "); print_generic_expr (stderr, use);