]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/hsa-regalloc.c
c++: Handle multiple aggregate overloads [PR95319].
[thirdparty/gcc.git] / gcc / hsa-regalloc.c
index f8e83ecfffe1935f7f486158ad1b256fcb7c7732..7614efea209f70b35c5751ce99573336e6d3f3d8 100644 (file)
@@ -1,5 +1,5 @@
 /* HSAIL IL Register allocation and out-of-SSA.
-   Copyright (C) 2013-2016 Free Software Foundation, Inc.
+   Copyright (C) 2013-2020 Free Software Foundation, Inc.
    Contributed by Michael Matz <matz@suse.de>
 
 This file is part of GCC.
@@ -26,22 +26,24 @@ along with GCC; see the file COPYING3.  If not see
 #include "vec.h"
 #include "tree.h"
 #include "dominance.h"
-#include "cfg.h"
-#include "cfganal.h"
+#include "basic-block.h"
 #include "function.h"
+#include "cfganal.h"
+#include "cfg.h"
 #include "bitmap.h"
 #include "dumpfile.h"
 #include "cgraph.h"
 #include "print-tree.h"
 #include "cfghooks.h"
+#include "alloc-pool.h"
 #include "symbol-summary.h"
-#include "hsa.h"
+#include "hsa-common.h"
 
 
 /* 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++)
@@ -54,7 +56,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
@@ -88,10 +90,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;
@@ -247,7 +257,7 @@ dump_hsa_cfun_regalloc (FILE *f)
 
   FOR_ALL_BB_FN (bb, cfun)
   {
-    hsa_bb *hbb = (struct hsa_bb *) bb->aux;
+    hsa_bb *hbb = (class hsa_bb *) bb->aux;
     bitmap_print (dump_file, hbb->m_livein, "m_livein  ", "\n");
     dump_hsa_bb (f, hbb);
     bitmap_print (dump_file, hbb->m_liveout, "m_liveout ", "\n");
@@ -580,10 +590,9 @@ linear_scan_regalloc (struct m_reg_class_desc *classes)
   /* Sort all intervals by increasing start point.  */
   gcc_assert (ind2reg.length () == (size_t) hsa_cfun->m_reg_count);
 
-#ifdef ENABLE_CHECKING
-  for (unsigned i = 0; i < ind2reg.length (); i++)
-    gcc_assert (ind2reg[i]);
-#endif
+  if (flag_checking)
+    for (unsigned i = 0; i < ind2reg.length (); i++)
+      gcc_assert (ind2reg[i]);
 
   ind2reg.qsort (cmp_begin);
   for (i = 0; i < 4; i++)
@@ -606,7 +615,7 @@ linear_scan_regalloc (struct m_reg_class_desc *classes)
        spill_at_interval (reg, active);
 
       /* Some interesting dumping as we go.  */
-      if (dump_file)
+      if (dump_file && (dump_flags & TDF_DETAILS))
        {
          fprintf (dump_file, "  reg%d: [%5d, %5d)->",
                   reg->m_order, reg->m_lr_begin, reg->m_lr_end);
@@ -638,7 +647,7 @@ linear_scan_regalloc (struct m_reg_class_desc *classes)
   BITMAP_FREE (work);
   free (bbs);
 
-  if (dump_file)
+  if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "------- After liveness: -------\n");
       dump_hsa_cfun_regalloc (dump_file);
@@ -701,9 +710,10 @@ regalloc (void)
 void
 hsa_regalloc (void)
 {
+  hsa_cfun->update_dominance ();
   naive_outof_ssa ();
 
-  if (dump_file)
+  if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "------- After out-of-SSA: -------\n");
       dump_hsa_cfun (dump_file);
@@ -711,7 +721,7 @@ hsa_regalloc (void)
 
   regalloc ();
 
-  if (dump_file)
+  if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "------- After register allocation: -------\n");
       dump_hsa_cfun (dump_file);