Patchwork : Fix negative value in TEST_BIT from mem_overlaps_already_clobbered_arg_p()

login
register
mail settings
Submitter mickael guene
Date March 12, 2012, 11:43 a.m.
Message ID <4F5DE176.8020803@st.com>
Download mbox | patch
Permalink /patch/146061/
State New
Headers show

Comments

mickael guene - March 12, 2012, 11:43 a.m.
Hi all,

  After applying patch from http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00228.html we can
have a negative value in call to TEST_BIT() macro in mem_overlaps_already_clobbered_arg_p() function
for stored_args_map bitmap table.
  This can lead to reject a valid tail call optimization.

  This patch will ensure that i+k is positive before calling TEST_BIT() macro.

2012-03-12  Mickael Guene  <mickael.guene@st.com>

	* calls.c (mem_overlaps_already_clobbered_arg_p): Don't call TEST_BIT for
	negative value.

Regards

Mickael

Patch

--- a/gcc/calls.c	2012-03-12 10:44:27.000000000 +0100
+++ b/gcc/calls.c	2012-03-12 10:46:16.000000000 +0100
@@ -1822,7 +1822,8 @@ 
       unsigned HOST_WIDE_INT k;
 
       for (k = 0; k < size; k++)
-	if (i + k < stored_args_map->n_bits
+	if (i + k >= 0
+	    && i + k < stored_args_map->n_bits
 	    && TEST_BIT (stored_args_map, i + k))
 	  return true;
     }