This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, PR 54409] Remapping inlining predicates fix


Hi,

this patch fixes PR 54409.  The condition for dealing with offset maps
when remapping predicates which I have added recently was wrong,
fortunately a subsequent assert caught this.  We cannot shift stuff by
an offset when it is passed by value.

Conversely, the condition was unnecessarily restrictive, we can still
happily use non-aggregate and by-value conditions when offset map is
negative, that only means that by-ref stuff is not guaranteed to
survive.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin



2012-08-30  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/54409
	* ipa-inline-analysis.c (remap_predicate): Fix the offset_map
	checking condition.

	* gcc/testsuite/gcc.dg/torture/pr54409.c: New test.


Index: src/gcc/ipa-inline-analysis.c
===================================================================
--- src.orig/gcc/ipa-inline-analysis.c
+++ src/gcc/ipa-inline-analysis.c
@@ -2811,8 +2811,11 @@ remap_predicate (struct inline_summary *
 		 if (!operand_map
 		     || (int)VEC_length (int, operand_map) <= c->operand_num
 		     || VEC_index (int, operand_map, c->operand_num) == -1
-		     || (!c->agg_contents
-			 && VEC_index (int, offset_map, c->operand_num) != 0)
+		     /* TODO: For non-aggregate conditions, adding an offset is
+			basically an arithmetic jump function processing which
+			we should support in future.  */
+		     || ((!c->agg_contents || !c->by_ref)
+			 && VEC_index (int, offset_map, c->operand_num) > 0)
 		     || (c->agg_contents && c->by_ref
 			 && VEC_index (int, offset_map, c->operand_num) < 0))
 		   cond_predicate = true_predicate ();
Index: src/gcc/testsuite/gcc.dg/torture/pr54409.c
===================================================================
--- /dev/null
+++ src/gcc/testsuite/gcc.dg/torture/pr54409.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+
+int b;
+
+struct S
+{
+  char *p;
+  struct {
+  } s;
+  int a;
+};
+
+static _Bool
+fn2 (int *p1)
+{
+  if (b)
+    {
+      struct S *c = (struct S *) &p1;
+      return c->a;
+    }
+}
+
+_Bool
+fn3 (struct S *p1)
+{
+  if (fn2 ((int *) &p1->s))
+    return 0;
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]