diff options
author | Yvan Roux <yvan.roux@linaro.org> | 2015-10-10 18:53:41 +0200 |
---|---|---|
committer | Linaro Code Review <review@review.linaro.org> | 2015-10-12 08:48:51 +0000 |
commit | a5a9ab990348d72df64a5ef0651ef338e465e142 (patch) | |
tree | fee4bbaed720d7bf0bc44f0da49ebbdaa6048ea7 | |
parent | b9bfe3c276686f9a1d0e827722c6c578ddbee8a8 (diff) |
gcc/
Backport from trunk r225106.
2015-06-28 Chung-Lin Tang <cltang@codesourcery.com>
Sandra Loosemore <sandra@codesourcery.com>
* regrename.h (regrename_do_replace): Change to return bool.
* regrename.c (rename_chains): Check return value of
regname_do_replace.
(regrename_do_replace): Re-validate the modified insns and
return bool status.
* config/aarch64/cortex-a57-fma-steering.c (rename_single_chain):
Update to match rename_chains changes.
* config/c6x/c6x.c (try_rename_operands): Assert that
regrename_do_replace returns true.
Change-Id: Ib5cb97828c0963e7c9a2283f1569e76584c2cdd8
-rw-r--r-- | gcc/config/aarch64/cortex-a57-fma-steering.c | 18 | ||||
-rw-r--r-- | gcc/config/c6x/c6x.c | 4 | ||||
-rw-r--r-- | gcc/regrename.c | 40 | ||||
-rw-r--r-- | gcc/regrename.h | 2 |
4 files changed, 45 insertions, 19 deletions
diff --git a/gcc/config/aarch64/cortex-a57-fma-steering.c b/gcc/config/aarch64/cortex-a57-fma-steering.c index a86dd5a0904..42490eda155 100644 --- a/gcc/config/aarch64/cortex-a57-fma-steering.c +++ b/gcc/config/aarch64/cortex-a57-fma-steering.c @@ -291,11 +291,19 @@ rename_single_chain (du_head_p head, HARD_REG_SET *unavailable) return false; } - if (dump_file) - fprintf (dump_file, ", renamed as %s\n", reg_names[best_new_reg]); - - regrename_do_replace (head, best_new_reg); - df_set_regs_ever_live (best_new_reg, true); + if (regrename_do_replace (head, best_new_reg)) + { + if (dump_file) + fprintf (dump_file, ", renamed as %s\n", reg_names[best_new_reg]); + df_set_regs_ever_live (best_new_reg, true); + } + else + { + if (dump_file) + fprintf (dump_file, ", renaming as %s failed\n", + reg_names[best_new_reg]); + return false; + } return true; } diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index 03f6b3f3f29..b56aec4c04d 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -3532,7 +3532,7 @@ try_rename_operands (rtx_insn *head, rtx_insn *tail, unit_req_table reqs, best_reg = find_rename_reg (this_head, super_class, &unavailable, old_reg, true); - regrename_do_replace (this_head, best_reg); + gcc_assert (regrename_do_replace (this_head, best_reg)); count_unit_reqs (new_reqs, head, PREV_INSN (tail)); merge_unit_reqs (new_reqs); @@ -3545,7 +3545,7 @@ try_rename_operands (rtx_insn *head, rtx_insn *tail, unit_req_table reqs, unit_req_imbalance (reqs), unit_req_imbalance (new_reqs)); } if (unit_req_imbalance (new_reqs) > unit_req_imbalance (reqs)) - regrename_do_replace (this_head, old_reg); + gcc_assert (regrename_do_replace (this_head, old_reg)); else memcpy (reqs, new_reqs, sizeof (unit_req_table)); diff --git a/gcc/regrename.c b/gcc/regrename.c index f995ffa4cb7..3d85b651583 100644 --- a/gcc/regrename.c +++ b/gcc/regrename.c @@ -505,12 +505,20 @@ rename_chains (void) continue; } - if (dump_file) - fprintf (dump_file, ", renamed as %s\n", reg_names[best_new_reg]); - - regrename_do_replace (this_head, best_new_reg); - tick[best_new_reg] = ++this_tick; - df_set_regs_ever_live (best_new_reg, true); + if (regrename_do_replace (this_head, best_new_reg)) + { + if (dump_file) + fprintf (dump_file, ", renamed as %s\n", reg_names[best_new_reg]); + tick[best_new_reg] = ++this_tick; + df_set_regs_ever_live (best_new_reg, true); + } + else + { + if (dump_file) + fprintf (dump_file, ", renaming as %s failed\n", + reg_names[best_new_reg]); + tick[reg] = ++this_tick; + } } } @@ -936,7 +944,13 @@ regrename_analyze (bitmap bb_mask) bb->aux = NULL; } -void +/* Attempt to replace all uses of the register in the chain beginning with + HEAD with REG. Returns true on success and false if the replacement is + rejected because the insns would not validate. The latter can happen + e.g. if a match_parallel predicate enforces restrictions on register + numbering in its subpatterns. */ + +bool regrename_do_replace (struct du_head *head, int reg) { struct du_chain *chain; @@ -950,22 +964,26 @@ regrename_do_replace (struct du_head *head, int reg) int reg_ptr = REG_POINTER (*chain->loc); if (DEBUG_INSN_P (chain->insn) && REGNO (*chain->loc) != base_regno) - INSN_VAR_LOCATION_LOC (chain->insn) = gen_rtx_UNKNOWN_VAR_LOC (); + validate_change (chain->insn, &(INSN_VAR_LOCATION_LOC (chain->insn)), + gen_rtx_UNKNOWN_VAR_LOC (), true); else { - *chain->loc = gen_raw_REG (GET_MODE (*chain->loc), reg); + validate_change (chain->insn, chain->loc, + gen_raw_REG (GET_MODE (*chain->loc), reg), true); if (regno >= FIRST_PSEUDO_REGISTER) ORIGINAL_REGNO (*chain->loc) = regno; REG_ATTRS (*chain->loc) = attr; REG_POINTER (*chain->loc) = reg_ptr; } - - df_insn_rescan (chain->insn); } + if (!apply_change_group ()) + return false; + mode = GET_MODE (*head->first->loc); head->regno = reg; head->nregs = hard_regno_nregs[reg][mode]; + return true; } diff --git a/gcc/regrename.h b/gcc/regrename.h index 8dc9f71a730..bbe156dbc4e 100644 --- a/gcc/regrename.h +++ b/gcc/regrename.h @@ -91,6 +91,6 @@ extern void regrename_analyze (bitmap); extern du_head_p regrename_chain_from_id (unsigned int); extern int find_rename_reg (du_head_p, enum reg_class, HARD_REG_SET *, int, bool); -extern void regrename_do_replace (du_head_p, int); +extern bool regrename_do_replace (du_head_p, int); #endif |