[calls.c] PR rtl-optimization/67226: Take into account pretend_args_size when checkin...
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Thu, 26 Nov 2015 09:58:28 +0000 (09:58 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Thu, 26 Nov 2015 09:58:28 +0000 (09:58 +0000)
2015-11-26  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
            Bernd Schmidt  <bschmidt@redhat.com>

PR rtl-optimization/67226
* calls.c (store_one_arg): Take into account
crtl->args.pretend_args_size when checking for overlap between
arg->value and argblock + arg->locate.offset during sibcall
optimization.

* gcc.c-torture/execute/pr67226.c: New test.

Co-Authored-By: Bernd Schmidt <bernds@redhat.com>
From-SVN: r230929

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr67226.c [new file with mode: 0644]

index 56dd588c52e8002a22b7e036711ee2aa659e1ca4..58b789b81d9fc39481f55f98e9ad7300d1775f57 100644 (file)
@@ -1,3 +1,12 @@
+2015-11-26  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+            Bernd Schmidt  <bschmidt@redhat.com>
+
+       PR rtl-optimization/67226
+       * calls.c (store_one_arg): Take into account
+       crtl->args.pretend_args_size when checking for overlap between
+       arg->value and argblock + arg->locate.offset during sibcall
+       optimization.
+
 2015-11-26  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * config/aarch64/aarch64.md (cbranch<mode>4): Use
index b56556a9d0a21b7e8ee3a99354d355c4b55feee4..6cbe01970c1f260c8b3115ecbaac69bfa4ead19f 100644 (file)
@@ -4939,6 +4939,13 @@ store_one_arg (struct arg_data *arg, rtx argblock, int flags,
              if (XEXP (x, 0) != crtl->args.internal_arg_pointer)
                i = INTVAL (XEXP (XEXP (x, 0), 1));
 
+             /* arg.locate doesn't contain the pretend_args_size offset,
+                it's part of argblock.  Ensure we don't count it in I.  */
+             if (STACK_GROWS_DOWNWARD)
+               i -= crtl->args.pretend_args_size;
+             else
+               i += crtl->args.pretend_args_size;
+
              /* expand_call should ensure this.  */
              gcc_assert (!arg->locate.offset.var
                          && arg->locate.size.var == 0
index 2e9f9623db8ff9b1fc44c68b4eb9c41235ec8398..a1466e398aabcb79b08c86cfbd7929b8479e1bc4 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-26  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR rtl-optimization/67226
+       * gcc.c-torture/execute/pr67226.c: New test.
+
 2015-11-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/68508
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr67226.c b/gcc/testsuite/gcc.c-torture/execute/pr67226.c
new file mode 100644 (file)
index 0000000..c533496
--- /dev/null
@@ -0,0 +1,42 @@
+struct assembly_operand
+{
+  int type, value, symtype, symflags, marker;
+};
+
+struct assembly_operand to_input, from_input;
+
+void __attribute__ ((__noinline__, __noclone__))
+assemblez_1 (int internal_number, struct assembly_operand o1)
+{
+  if (o1.type != from_input.type)
+    __builtin_abort ();
+}
+
+void __attribute__ ((__noinline__, __noclone__))
+t0 (struct assembly_operand to, struct assembly_operand from)
+{
+  if (to.value == 0)
+    assemblez_1 (32, from);
+  else
+    __builtin_abort ();
+}
+
+int
+main (void)
+{
+  to_input.value = 0;
+  to_input.type = 1;
+  to_input.symtype = 2;
+  to_input.symflags = 3;
+  to_input.marker = 4;
+
+  from_input.value = 5;
+  from_input.type = 6;
+  from_input.symtype = 7;
+  from_input.symflags = 8;
+  from_input.marker = 9;
+
+  t0 (to_input, from_input);
+
+  return 0;
+}