diff mbox

[Cilkplus] Patch to fix a bug in 32 bit Metadata

Message ID BF230D13CA30DD48930C31D4099330000484C2@FMSMSX102.amr.corp.intel.com
State New
Headers show

Commit Message

Iyer, Balaji V Feb. 15, 2012, 10:18 p.m. UTC
Hello Everyone,
     This patch is for the Cilkplus branch affecting the C and C++ compilers. This patch will fix a problem in metadata dwarf code generation part when we are trying to catch the register number when a spill occurs.

Thanks,

Balaji V. Iyer.
diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c
old mode 100644
new mode 100755
diff mbox

Patch

diff --git a/gcc/ChangeLog.cilk b/gcc/ChangeLog.cilk
index d50f02c..ebabff6 100644
--- a/gcc/ChangeLog.cilk
+++ b/gcc/ChangeLog.cilk
@@ -1,3 +1,9 @@ 
+2012-02-15  Balaji V. Iyer  <balaji.v.iyer@intel.com>
+
+	* cilk.c (cilk_fix_stack_reg): New function.
+	(expand_buitin_cilk_metadata): Added a check for memory type rtx and do
+	a call to the cilk_fix_reg_stack function.
+	
 2012-02-14  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
 	* c-array-notation.c (contains_array_notation_exprs): Added a check
diff --git a/gcc/cilk.c b/gcc/cilk.c
index cc4ddcd..cd06f22 100644
--- a/gcc/cilk.c
+++ b/gcc/cilk.c
@@ -1032,6 +1032,32 @@  cilk_output_metadata (void)
   return;
 }
 
+/* This function will go through an RTL of type MEM and then check to see if
+ * the register is PSEUDO, if so then we replace it with stack_pointer_rtx.
+ * This is mainly used to find the DWARF codes for parameters that are pushed
+ * in the stack.
+ */
+static rtx
+cilk_fix_stack_reg (rtx mem_rtx)
+{
+  if (!mem_rtx || !MEM_P (mem_rtx))
+    return mem_rtx;
+
+  if (REG_P (XEXP (mem_rtx, 0)))
+    {
+      if (REGNO (XEXP (mem_rtx, 0)) >= FIRST_PSEUDO_REGISTER)
+	XEXP (mem_rtx, 0) = stack_pointer_rtx;
+    }
+  else if (GET_CODE (XEXP (mem_rtx, 0)) == PLUS)
+    {
+      rtx tmp_rtx = XEXP (mem_rtx, 0);
+      if (REG_P (XEXP (tmp_rtx, 0)))
+	if (REGNO (XEXP (tmp_rtx, 0)) >= FIRST_PSEUDO_REGISTER)
+	  XEXP (XEXP (mem_rtx, 0), 0) = stack_pointer_rtx;
+    }
+  return mem_rtx;
+}
+
 rtx
 expand_builtin_cilk_metadata (const char *annotation ATTRIBUTE_UNUSED,
 			      tree exp ATTRIBUTE_UNUSED)
@@ -1062,7 +1088,14 @@  expand_builtin_cilk_metadata (const char *annotation ATTRIBUTE_UNUSED,
 	  reg_rtx = XEXP (ii_rtx, 0);
 	  if (reg_rtx)
 	    if (GET_CODE (reg_rtx) == USE)
-	      metadata_info.reg_rtx = XEXP (reg_rtx, 0);
+	      {
+		reg_rtx = XEXP (reg_rtx, 0);
+		if (REG_P (reg_rtx))
+		  metadata_info.reg_rtx = reg_rtx;
+		else if (MEM_P (reg_rtx)) /* this means we are using stack */
+		  metadata_info.reg_rtx = cilk_fix_stack_reg (reg_rtx);
+	      }
+	  
 	}
 
       loc_ref = loc_descriptor (metadata_info.reg_rtx, VOIDmode,