From patchwork Tue Sep 6 00:24:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 75450 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp291159qgf; Mon, 5 Sep 2016 17:24:43 -0700 (PDT) X-Received: by 10.66.150.202 with SMTP id uk10mr67523121pab.10.1473121483634; Mon, 05 Sep 2016 17:24:43 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d129si25655253pfa.184.2016.09.05.17.24.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Sep 2016 17:24:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-435292-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-435292-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-435292-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=rz1Dj3OcOARmcGP hZh36jLzcR7MWg9r3424p/YNGFNFYIZvJqTiy5LkOw/b/wsHLkdux/Y9gLKzGOvV Qqwa1RD+lUBde+9ctz0HxLwgv7ALFqaJVcgKxs0h3O0B3LU6q/QwfU9t17B5oh8u MMOJWzXsAXYjaL+YO+ICGGi9ra4M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=yRHOXJvALhmhlPJjsDiLG Dtmi1Q=; b=d6P1hohvSVXb69YcNaqM0j5AwCfy2IYju29MtZa4GfVp35Rr6XGxN QIRJNfHubLrKY7y2wdAggawYnRvVNHTT39Yfuq3UduXRt9B0Pt6Xw8NrHJH4lAJ9 3db30CpkOTrP26WxpLAcv77OI/kssFz2sQGj7JQjNrEbtrdzT+ZOMA= Received: (qmail 7414 invoked by alias); 6 Sep 2016 00:24:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7401 invoked by uid 89); 6 Sep 2016 00:24:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: Yes, score=6.8 required=5.0 tests=AWL, BAYES_99, BAYES_999, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=20160906, 2016-09-06, skill, 4719 X-HELO: mail-qk0-f176.google.com Received: from mail-qk0-f176.google.com (HELO mail-qk0-f176.google.com) (209.85.220.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Sep 2016 00:24:21 +0000 Received: by mail-qk0-f176.google.com with SMTP id z190so203196504qkc.0 for ; Mon, 05 Sep 2016 17:24:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2nsKbAYVcEuYMrAddXSSrDoB46LYUsEkMCCmJQiooUE=; b=A57y/mWBZAlT8xtvxetHbMxMEXeW/6ii1Ed90Wzqdhu0UGTzVnfVyZVaHbGsEbS8VE OauSUo33ehqqsJXX3CpG7y27wLX6QpfcgLZdhvwJoHm2ONsETqmzrEPwocIEa0jqygN0 XADeOaM/JXdIQ4ywb4P/KUOfoNVAEtyhRL9Db8fDlwssiDFsmi6tgjZmFnAvo7B1ErIa 8/oL4FbAePX/CwP4mZ0dGsMIkL7vXZWGsRYz6xy6sQylvcPo7FWNPkqR6c/dAa7cgsqX TS3fhIyuoc/csXMXHWX84CwNxQ18JI8Tw/vJcslgCxgsPU/jqXwxqFO/fMV5Mzy05QF/ 8gdA== X-Gm-Message-State: AE9vXwOicJTECUqyQd5luwtgZvId7KkjzGdg3oNjp4KL9KuHdTFFRSWhSYIW9DV1JF98wzMmt4lt/O7kvX7nFrq5 X-Received: by 10.55.102.15 with SMTP id a15mr480979qkc.90.1473121459219; Mon, 05 Sep 2016 17:24:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.57.97 with HTTP; Mon, 5 Sep 2016 17:24:18 -0700 (PDT) In-Reply-To: References: From: Kugan Vivekanandarajah Date: Tue, 6 Sep 2016 10:24:18 +1000 Message-ID: Subject: Re: [RFC][SSA] Iterator to visit SSA To: Richard Biener Cc: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes Hi Richard, On 5 September 2016 at 17:57, Richard Biener wrote: > On Mon, Sep 5, 2016 at 7:26 AM, Kugan Vivekanandarajah > wrote: >> Hi All, >> >> While looking at gcc source, I noticed that we are iterating over SSA >> variable from 0 to num_ssa_names in some cases and 1 to num_ssa_names >> in others. It seems that variable 0 is always NULL TREE. > > Yeah, that's artificial because we don't assign SSA name version 0 (for some > unknown reason). > >> But it can >> confuse people who are looking for the first time. Therefore It might >> be good to follow some consistent usage here. >> >> It might be also good to gave a FOR_EACH_SSAVAR iterator as we do in >> other case. Here is attempt to do this based on what is done in other >> places. Bootstrapped and regression tested on X86_64-linux-gnu with no >> new regressions. is this OK? > > First of all some bikeshedding - FOR_EACH_SSA_NAME would be better > as SSAVAR might be confused with iterating over SSA_NAME_VAR. > > Then, if you add an iterator why leave the name == NULL handling to consumers? > That looks odd. > > Then, SSA names are just in a vector thus why not re-use the vector iterator? > > That is, > > #define FOR_EACH_SSA_NAME (name) \ > for (unsigned i = 1; SSANAMES (cfun).iterate (i, &name); ++i) > > would be equivalent to your patch? > > Please also don't add new iterators that implicitely use 'cfun' but always use > one that passes it as explicit arg. I think defining FOR_EACH_SSA_NAME with vector iterator is better. But we will not be able to skill NULL ssa_names with that. I also added index variable to the macro so that there want be any conflicts if the index variable "i" (or whatever) is also defined in the loop. Bootstrapped and regression tested on x86_64-linux-gnu with no new regressions. Is this OK for trunk? Thanks, Kugan gcc/ChangeLog: 2016-09-06 Kugan Vivekanandarajah * tree-ssanames.h (FOR_EACH_SSA_NAME): New. * cfgexpand.c (update_alias_info_with_stack_vars): Use FOR_EACH_SSA_NAME to iterate over SSA variables. (pass_expand::execute): Likewise. * omp-simd-clone.c (ipa_simd_modify_function_body): Likewise. * tree-cfg.c (dump_function_to_file): Likewise. * tree-into-ssa.c (pass_build_ssa::execute): Likewise. (update_ssa): Likewise. * tree-ssa-alias.c (dump_alias_info): Likewise. * tree-ssa-ccp.c (ccp_finalize): Likewise. * tree-ssa-coalesce.c (build_ssa_conflict_graph): Likewise. (create_outofssa_var_map): Likewise. (coalesce_ssa_name): Likewise. * tree-ssa-operands.c (dump_immediate_uses): Likewise. * tree-ssa-pre.c (compute_avail): Likewise. * tree-ssa-sccvn.c (init_scc_vn): Likewise. (scc_vn_restore_ssa_info): Likewise. (free_scc_vn): Likwise. (run_scc_vn): Likewise. * tree-ssa-structalias.c (compute_points_to_sets): Likewise. * tree-ssa-ter.c (new_temp_expr_table): Likewise. * tree-ssa-copy.c (fini_copy_prop): Likewise. * tree-ssa.c (verify_ssa): Likewise. > > Thanks, > Richard. > > >> Thanks, >> Kugan >> >> >> gcc/ChangeLog: >> >> 2016-09-05 Kugan Vivekanandarajah >> >> * tree-ssanames.h (ssa_iterator::ssa_iterator): New. >> (ssa_iterator::get): Likewise. >> (ssa_iterator::next): Likewise. >> (FOR_EACH_SSAVAR): Likewise. >> * cfgexpand.c (update_alias_info_with_stack_vars): Use >> FOR_EACH_SSAVAR to iterate over SSA variables. >> (pass_expand::execute): Likewise. >> * omp-simd-clone.c (ipa_simd_modify_function_body): Likewise. >> * tree-cfg.c (dump_function_to_file): Likewise. >> * tree-into-ssa.c (pass_build_ssa::execute): Likewise. >> (update_ssa): Likewise. >> * tree-ssa-alias.c (dump_alias_info): Likewise. >> * tree-ssa-ccp.c (ccp_finalize): Likewise. >> * tree-ssa-coalesce.c (build_ssa_conflict_graph): Likewise. >> (create_outofssa_var_map): Likewise. >> (coalesce_ssa_name): Likewise. >> * tree-ssa-operands.c (dump_immediate_uses): Likewise. >> * tree-ssa-pre.c (compute_avail): Likewise. >> * tree-ssa-sccvn.c (init_scc_vn): Likewise. >> (scc_vn_restore_ssa_info): Likewise. >> (free_scc_vn): Likwise. >> (run_scc_vn): Likewise. >> * tree-ssa-structalias.c (compute_points_to_sets): Likewise. >> * tree-ssa-ter.c (new_temp_expr_table): Likewise. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 130a16b..6f94335 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -815,12 +815,12 @@ update_alias_info_with_stack_vars (void) if (decls_to_partitions) { unsigned i; + tree name; hash_set visited; bitmap temp = BITMAP_ALLOC (&stack_var_bitmap_obstack); - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); struct ptr_info_def *pi; if (name @@ -6163,6 +6163,7 @@ pass_expand::execute (function *fun) edge e; rtx_insn *var_seq, *var_ret_seq; unsigned i; + tree name; timevar_push (TV_OUT_OF_SSA); rewrite_out_of_ssa (&SA); @@ -6270,10 +6271,8 @@ pass_expand::execute (function *fun) /* Now propagate the RTL assignment of each partition to the underlying var of each SSA_NAME. */ - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); - if (!name /* We might have generated new SSA names in update_alias_info_with_stack_vars. They will have a NULL @@ -6288,9 +6287,8 @@ pass_expand::execute (function *fun) /* Clean up RTL of variables that straddle across multiple partitions, and check that the rtl of any PARM_DECLs that are not cleaned up is that of their default defs. */ - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); int part; if (!name diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index 467d872..210dea5 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -888,6 +888,7 @@ ipa_simd_modify_function_body (struct cgraph_node *node, { basic_block bb; unsigned int i, j, l; + tree name; /* Re-use the adjustments array, but this time use it to replace every function argument use to an offset into the corresponding @@ -911,9 +912,8 @@ ipa_simd_modify_function_body (struct cgraph_node *node, } l = adjustments.length (); - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); if (name && SSA_NAME_VAR (name) && TREE_CODE (SSA_NAME_VAR (name)) == PARM_DECL) diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 57c8410..a786965 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -7539,6 +7539,7 @@ dump_function_to_file (tree fndecl, FILE *file, int flags) if (fun && fun->decl == fndecl && (fun->curr_properties & PROP_gimple_lcf)) { unsigned ix; + tree name; ignore_topmost_bind = true; fprintf (file, "{\n"); @@ -7582,9 +7583,8 @@ dump_function_to_file (tree fndecl, FILE *file, int flags) any_var = true; } if (gimple_in_ssa_p (cfun)) - for (ix = 1; ix < num_ssa_names; ++ix) + FOR_EACH_SSA_NAME (ix, name) { - tree name = ssa_name (ix); if (name && !SSA_NAME_VAR (name)) { fprintf (file, " "); diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index ceafa68..042934f 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -2342,6 +2342,7 @@ pass_build_ssa::execute (function *fun) bitmap_head *dfs; basic_block bb; unsigned i; + tree decl, name; /* Initialize operand data structures. */ init_ssa_operands (fun); @@ -2385,9 +2386,8 @@ pass_build_ssa::execute (function *fun) /* Try to get rid of all gimplifier generated temporaries by making its SSA names anonymous. This way we can garbage collect them all after removing unused locals which we do in our TODO. */ - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name) { - tree decl, name = ssa_name (i); if (!name || SSA_NAME_IS_DEFAULT_DEF (name)) continue; @@ -3165,7 +3165,7 @@ update_ssa (unsigned update_flags) unsigned i = 0; bool insert_phi_p; sbitmap_iterator sbi; - tree sym; + tree sym, name; /* Only one update flag should be set. */ gcc_assert (update_flags == TODO_update_ssa @@ -3284,9 +3284,8 @@ update_ssa (unsigned update_flags) prepare_block_for_update (start_bb, insert_phi_p); if (flag_checking) - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); if (!name || virtual_operand_p (name)) continue; diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 8051a66..d3bf719 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -450,6 +450,7 @@ void dump_alias_info (FILE *file) { unsigned i; + tree ptr; const char *funcname = lang_hooks.decl_printable_name (current_function_decl, 2); tree var; @@ -471,9 +472,8 @@ dump_alias_info (FILE *file) fprintf (file, "\n\nFlow-insensitive points-to information\n\n"); - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, ptr) { - tree ptr = ssa_name (i); struct ptr_info_def *pi; if (ptr == NULL_TREE diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 9871304..702fbfb 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -898,15 +898,15 @@ ccp_finalize (bool nonzero_p) { bool something_changed; unsigned i; + tree name; do_dbg_cnt (); /* Derive alignment and misalignment information from partially constant pointers in the lattice or nonzero bits from partially constant integers. */ - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); ccp_prop_value_t *val; unsigned int tem, align; diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 34c3fa1..90bd7c6 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -955,10 +955,10 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo) if (bb == entry) { unsigned i; - for (i = 1; i < num_ssa_names; i++) - { - tree var = ssa_name (i); + tree var; + FOR_EACH_SSA_NAME (i, var) + { if (!var || !SSA_NAME_IS_DEFAULT_DEF (var) || !SSA_NAME_VAR (var) @@ -1261,9 +1261,8 @@ create_outofssa_var_map (coalesce_list *cl, bitmap used_in_copy) /* Now process result decls and live on entry variables for entry into the coalesce list. */ first = NULL_TREE; - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, var) { - var = ssa_name (i); if (var != NULL_TREE && !virtual_operand_p (var)) { coalesce_with_default (var, cl, used_in_copy); @@ -1806,6 +1805,7 @@ coalesce_ssa_name (void) bitmap used_in_copies = BITMAP_ALLOC (NULL); var_map map; unsigned int i; + tree a; cl = create_coalesce_list (); map = create_outofssa_var_map (cl, used_in_copies); @@ -1817,10 +1817,8 @@ coalesce_ssa_name (void) { hash_table ssa_name_hash (10); - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, a) { - tree a = ssa_name (i); - if (a && SSA_NAME_VAR (a) && !DECL_IGNORED_P (SSA_NAME_VAR (a)) diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index 3d17926..01c09c8 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -503,12 +503,12 @@ static bool fini_copy_prop (void) { unsigned i; + tree var; /* Set the final copy-of value for each variable by traversing the copy-of chains. */ - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, var) { - tree var = ssa_name (i); if (!var || !copy_of[i].value || copy_of[i].value == var) diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index eccea2f..7a22dea 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -1247,9 +1247,8 @@ dump_immediate_uses (FILE *file) unsigned int x; fprintf (file, "Immediate_uses: \n\n"); - for (x = 1; x < num_ssa_names; x++) + FOR_EACH_SSA_NAME (x, var) { - var = ssa_name (x); if (!var) continue; dump_immediate_uses_for (file, var); diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index fdb1c2c..47f7908 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3670,12 +3670,12 @@ compute_avail (void) basic_block *worklist; size_t sp = 0; unsigned i; + tree name; /* We pretend that default definitions are defined in the entry block. This includes function arguments and the static chain decl. */ - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); pre_expr e; if (!name || !SSA_NAME_IS_DEFAULT_DEF (name) diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 21b3d56..0323d7f 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -4291,6 +4291,7 @@ static void init_scc_vn (void) { size_t i; + tree name; int j; int *rpo_numbers_temp; @@ -4339,9 +4340,8 @@ init_scc_vn (void) /* Create the VN_INFO structures, and initialize value numbers to TOP or VARYING for parameters. */ - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); if (!name) continue; @@ -4402,9 +4402,11 @@ init_scc_vn (void) void scc_vn_restore_ssa_info (void) { - for (unsigned i = 0; i < num_ssa_names; i++) + unsigned i; + tree name; + + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); if (name && has_VN_INFO (name)) { @@ -4428,6 +4430,7 @@ void free_scc_vn (void) { size_t i; + tree name; delete constant_to_value_id; constant_to_value_id = NULL; @@ -4436,9 +4439,8 @@ free_scc_vn (void) shared_lookup_references.release (); XDELETEVEC (rpo_numbers); - for (i = 0; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); if (name && has_VN_INFO (name) && VN_INFO (name)->needs_insertion) @@ -4757,6 +4759,7 @@ bool run_scc_vn (vn_lookup_kind default_vn_walk_kind_) { size_t i; + tree name; default_vn_walk_kind = default_vn_walk_kind_; @@ -4797,9 +4800,8 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_) /* Initialize the value ids and prune out remaining VN_TOPs from dead code. */ - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); vn_ssa_aux_t info; if (!name) continue; @@ -4814,9 +4816,8 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_) } /* Propagate. */ - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); vn_ssa_aux_t info; if (!name) continue; @@ -4832,9 +4833,8 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Value numbers:\n"); - for (i = 0; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); if (name && VN_INFO (name)->visited && SSA_VAL (name) != name) diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index fd96c3a..3b13387 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -7029,6 +7029,7 @@ compute_points_to_sets (void) { basic_block bb; unsigned i; + tree ptr; varinfo_t vi; timevar_push (TV_TREE_PTA); @@ -7077,9 +7078,8 @@ compute_points_to_sets (void) cfun->gimple_df->escaped.escaped = 0; /* Compute the points-to sets for pointer SSA_NAMEs. */ - for (i = 0; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, ptr) { - tree ptr = ssa_name (i); if (ptr && POINTER_TYPE_P (TREE_TYPE (ptr))) find_what_p_points_to (cfun->decl, ptr); diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c index 2a772b2..0efa407 100644 --- a/gcc/tree-ssa-ter.c +++ b/gcc/tree-ssa-ter.c @@ -186,6 +186,7 @@ static temp_expr_table * new_temp_expr_table (var_map map) { unsigned x; + tree name; temp_expr_table *t = XNEW (struct temp_expr_table); t->map = map; @@ -201,10 +202,9 @@ new_temp_expr_table (var_map map) t->replaceable_expressions = NULL; t->num_in_part = XCNEWVEC (int, num_var_partitions (map)); - for (x = 1; x < num_ssa_names; x++) + FOR_EACH_SSA_NAME (x, name) { int p; - tree name = ssa_name (x); if (!name) continue; p = var_to_partition (map, name); diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index aae383d..3389e2e 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1010,6 +1010,7 @@ verify_ssa (bool check_modified_stmt, bool check_ssa_operands) basic_block *definition_block = XCNEWVEC (basic_block, num_ssa_names); ssa_op_iter iter; tree op; + tree name; enum dom_state orig_dom_state = dom_info_state (CDI_DOMINATORS); bitmap names_defined_in_bb = BITMAP_ALLOC (NULL); @@ -1018,9 +1019,8 @@ verify_ssa (bool check_modified_stmt, bool check_ssa_operands) timevar_push (TV_TREE_SSA_VERIFY); /* Keep track of SSA names present in the IL. */ - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name) { - tree name = ssa_name (i); if (name) { gimple *stmt; diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index 8e66ce6..8e9ce00 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -62,6 +62,9 @@ struct GTY ((variable_size)) range_info_def { #define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names)) #define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)]) +#define FOR_EACH_SSA_NAME(i, VAR) \ + for (i = 1; SSANAMES (cfun)->iterate (i, &VAR); ++i) + /* Sets the value range to SSA. */ extern void set_range_info (tree, enum value_range_type, const wide_int_ref &, const wide_int_ref &);