Patchwork Fix PR 49309, ICE with mudflap

login
register
mail settings
Submitter Andrew Pinski
Date July 13, 2011, 8:37 p.m.
Message ID <CA+=Sn1=QgL2o7BxMQccHNa3v4ksNRn4t=CZ5pCByZZP3Jk+trA@mail.gmail.com>
Download mbox | patch
Permalink /patch/104594/
State New
Headers show

Comments

Andrew Pinski - July 13, 2011, 8:37 p.m.
Hi,
  The problem here is that the type of the POINTER_PLUS_EXPR is
incorrect and also the non folded version leaks to the IR.  This patch
fixes those two problems and fixes the ICE.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

2011-07-13  Andrew Pinski  <pinskia@gmail.com>

	PR tree-opt/49309
	* tree-mudflap.c (mf_xform_derefs_1 <case MEM_REF>):
	Use fold_build2_loc instead of build2.
	Use the correct type for the new tree.

2011-07-13  Andrew Pinski  <pinskia@gmail.com>

	PR tree-opt/49309
	* g++.dg/torture/pr49309.C: New testcase.
Richard Guenther - July 14, 2011, 9:29 a.m.
On Wed, Jul 13, 2011 at 10:37 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> Hi,
>  The problem here is that the type of the POINTER_PLUS_EXPR is
> incorrect and also the non folded version leaks to the IR.  This patch
> fixes those two problems and fixes the ICE.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Ok.

Thanks,
Richard.

> Thanks,
> Andrew Pinski
>
> 2011-07-13  Andrew Pinski  <pinskia@gmail.com>
>
>        PR tree-opt/49309
>        * tree-mudflap.c (mf_xform_derefs_1 <case MEM_REF>):
>        Use fold_build2_loc instead of build2.
>        Use the correct type for the new tree.
>
> 2011-07-13  Andrew Pinski  <pinskia@gmail.com>
>
>        PR tree-opt/49309
>        * g++.dg/torture/pr49309.C: New testcase.
>

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 176249)
+++ ChangeLog	(working copy)
@@ -1,3 +1,10 @@ 
+2011-07-13  Andrew Pinski  <pinskia@gmail.com>
+
+	PR tree-opt/49309
+	* tree-mudflap.c (mf_xform_derefs_1 <case MEM_REF>):
+	Use fold_build2_loc instead of build2.
+	Use the correct type for the new tree.
+
 2011-07-13  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
 	* config/spu/spu.c (spu_init_libfuncs): Install __clrsbdi2.
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(revision 176249)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@ 
+2011-07-13  Andrew Pinski  <pinskia@gmail.com>
+
+	PR tree-opt/49309
+	* g++.dg/torture/pr49309.C: New testcase.
+
 2011-07-13  Janne Blomqvist  <jb@gcc.gnu.org>
 
 	PR libfortran/49296
Index: testsuite/g++.dg/torture/pr49309.C
===================================================================
--- testsuite/g++.dg/torture/pr49309.C	(revision 0)
+++ testsuite/g++.dg/torture/pr49309.C	(revision 0)
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fmudflap"  } */
+struct A
+{
+  int i;
+
+  A();
+  A(const A&);
+};
+
+inline void foo(A a) { a = A(); }
+
+void bar() { foo(A()); }
+
Index: tree-mudflap.c
===================================================================
--- tree-mudflap.c	(revision 176218)
+++ tree-mudflap.c	(working copy)
@@ -869,7 +869,7 @@  mf_xform_derefs_1 (gimple_stmt_iterator
       break;
 
     case MEM_REF:
-      addr = build2 (POINTER_PLUS_EXPR, TREE_TYPE (TREE_OPERAND (t, 1)),
+      addr = fold_build2_loc (location, POINTER_PLUS_EXPR, TREE_TYPE (TREE_OPERAND (t, 0)),
 		     TREE_OPERAND (t, 0),
 		     fold_convert (sizetype, TREE_OPERAND (t, 1)));
       base = addr;