diff mbox

[hsa] Do not ICE when regallocating function with zero pseudoregisters

Message ID 20150225160008.GF20953@virgil.suse
State New
Headers show

Commit Message

Martin Jambor Feb. 25, 2015, 4 p.m. UTC
Hi,

the new HSA register allocator ICEs when it tries to resize a vector
to zero length, which is something that our vectors do not take well,
when it processes a simple function which just returns a constant and
does not actually use any registers.

Fixed thusly, committed to the hsa branch after rudimentary testing.

Thanks,

Martin


2015-02-25  Martin Jambor  <mjambor@suse.cz>

	* hsa-regalloc.c (regalloc): Bail out if there are no registers.
diff mbox

Patch

diff --git a/gcc/hsa-regalloc.c b/gcc/hsa-regalloc.c
index 94c88dc..8f0b4bb 100644
--- a/gcc/hsa-regalloc.c
+++ b/gcc/hsa-regalloc.c
@@ -745,6 +745,10 @@  regalloc (void)
   basic_block bb;
   reg_class_desc classes[4];
 
+  /* If there are no registers used in the function, exit right away. */
+  if (hsa_cfun.reg_count == 0)
+    return;
+
   memset (classes, 0, sizeof (classes));
   classes[0].next_avail = 0;
   classes[0].max_num = 7;