public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][calls.c][4.9/5 backport] PR rtl-optimization/67226: Take into account pretend_args_size when checking stack offsets for sibcall optimisation
@ 2015-11-26 11:12 Kyrill Tkachov
  0 siblings, 0 replies; only message in thread
From: Kyrill Tkachov @ 2015-11-26 11:12 UTC (permalink / raw)
  To: GCC Patches; +Cc: Bernd Schmidt

[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]

Hi all,

This is a backport to GCC 4.9 and 5 of the patch at https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03082.html
The only difference with the trunk version is that we perform #ifdef checks on STACK_GROWS_DOWNWARD because
on these branches we have not moved away from conditional compilation of those bits.

Bernd approved the backports at https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03090.html
so I'll be committing this to the branches.

Bootstrapped and tested on arm, aarch64, x86_64.
Confirmed that the testcase fails on all the branches before this patch and passes with it.

Thanks,
Kyrill

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  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR rtl-optimization/67226
     * gcc.c-torture/execute/pr67226.c: New test.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: calls-pretend-back.patch --]
[-- Type: text/x-patch; name=calls-pretend-back.patch, Size: 1807 bytes --]

diff --git a/gcc/calls.c b/gcc/calls.c
index 0987dd0..ee8ea5f 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -4959,6 +4959,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.  */
+#ifdef STACK_GROWS_DOWNWARD
+		i -= crtl->args.pretend_args_size;
+#else
+		i += crtl->args.pretend_args_size;
+#endif
 	      /* expand_call should ensure this.  */
 	      gcc_assert (!arg->locate.offset.var
 			  && arg->locate.size.var == 0
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr67226.c b/gcc/testsuite/gcc.c-torture/execute/pr67226.c
new file mode 100644
index 0000000..c533496
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr67226.c
@@ -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;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-26 11:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-26 11:12 [PATCH][calls.c][4.9/5 backport] PR rtl-optimization/67226: Take into account pretend_args_size when checking stack offsets for sibcall optimisation Kyrill Tkachov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).