diff options
author | Martin Jambor <mjambor@suse.cz> | 2017-09-11 11:09:26 +0200 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2017-09-11 11:09:26 +0200 |
commit | 635c99aaf7250ef13dbd7a6f02141cb735bdcc2f (patch) | |
tree | b534647fe8cf86ea3c75931fae8433de321d57e3 /gcc/hsa-regalloc.c | |
parent | 15bac1919aab8a4fcbd0150e30f1bc53ae2b271f (diff) | |
download | gcc-635c99aaf7250ef13dbd7a6f02141cb735bdcc2f.zip gcc-635c99aaf7250ef13dbd7a6f02141cb735bdcc2f.tar.gz gcc-635c99aaf7250ef13dbd7a6f02141cb735bdcc2f.tar.bz2 |
Make HSA resilient to side-effects of split_edge
2017-09-11 Martin Jambor <mjambor@suse.cz>
PR hsa/82119
* hsa-gen.c (gen_hsa_phi_from_gimple_phi): Process ADDR_EXPRs in
arguments in advance.
* hsa-regalloc.c (naive_process_phi): New parameter predecessors,
use it to find predecessor edges.
(naive_outof_ssa): Collect vector of predecessors.
From-SVN: r251964
Diffstat (limited to 'gcc/hsa-regalloc.c')
-rw-r--r-- | gcc/hsa-regalloc.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/hsa-regalloc.c b/gcc/hsa-regalloc.c index 2a17254..7fc3a8a 100644 --- a/gcc/hsa-regalloc.c +++ b/gcc/hsa-regalloc.c @@ -42,7 +42,7 @@ along with GCC; see the file COPYING3. If not see /* Process a PHI node PHI of basic block BB as a part of naive out-f-ssa. */ static void -naive_process_phi (hsa_insn_phi *phi) +naive_process_phi (hsa_insn_phi *phi, const vec<edge> &predecessors) { unsigned count = phi->operand_count (); for (unsigned i = 0; i < count; i++) @@ -55,7 +55,7 @@ naive_process_phi (hsa_insn_phi *phi) if (!op) break; - e = EDGE_PRED (phi->m_bb, i); + e = predecessors[i]; if (single_succ_p (e->src)) hbb = hsa_bb_for_bb (e->src); else @@ -89,10 +89,18 @@ naive_outof_ssa (void) hsa_bb *hbb = hsa_bb_for_bb (bb); hsa_insn_phi *phi; + /* naive_process_phi can call split_edge on an incoming edge which order if + the incoming edges to the basic block and thus make it inconsistent with + the ordering of PHI arguments, so we collect them in advance. */ + auto_vec<edge, 8> predecessors; + unsigned pred_count = EDGE_COUNT (bb->preds); + for (unsigned i = 0; i < pred_count; i++) + predecessors.safe_push (EDGE_PRED (bb, i)); + for (phi = hbb->m_first_phi; phi; phi = phi->m_next ? as_a <hsa_insn_phi *> (phi->m_next) : NULL) - naive_process_phi (phi); + naive_process_phi (phi, predecessors); /* Zap PHI nodes, they will be deallocated when everything else will. */ hbb->m_first_phi = NULL; |