+2017-07-31 Uros Bizjak <ubizjak@gmail.com>
+
+ PR target/25967
+ * config/i386/i386.c (ix86_allocate_stack_slots_for_args):
+ New function.
+ (TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS): Define.
+
2017-07-31 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* config.gcc: Add z14.
}
static bool
+ix86_allocate_stack_slots_for_args (void)
+{
+ /* Naked functions should not allocate stack slots for arguments. */
+ return !ix86_function_naked (current_function_decl);
+}
+
+static bool
ix86_warn_func_return (tree decl)
{
/* Naked functions are implemented entirely in assembly, including the
#define TARGET_SETUP_INCOMING_VARARGS ix86_setup_incoming_varargs
#undef TARGET_MUST_PASS_IN_STACK
#define TARGET_MUST_PASS_IN_STACK ix86_must_pass_in_stack
+#undef TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS
+#define TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS ix86_allocate_stack_slots_for_args
#undef TARGET_FUNCTION_ARG_ADVANCE
#define TARGET_FUNCTION_ARG_ADVANCE ix86_function_arg_advance
#undef TARGET_FUNCTION_ARG
+2017-07-31 Uros Bizjak <ubizjak@gmail.com>
+
+ PR target/25967
+ * gcc.target/i386/naked-3.c (dg-options): Use -O0.
+ (naked): Add attribute regparm(1) for x86_32 targets.
+ Add integer argument. Remove global "data" variable.
+ (main): Pass integer argument to naked function.
+ * gcc.target/i386/naked-4.c: New test.
+
2017-07-31 Jan Hubicka <hubicka@ucw.cz>
Martin Liska <mliska@suse.cz>
/* { dg-do run { target *-*-linux* *-*-gnu* } } */
-/* { dg-options "-O2" } */
+/* { dg-options "-O0" } */
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
-int data;
-
/* Verify that naked function traps at the end. */
void
__attribute__((naked, noinline, noclone))
-naked (void)
+#ifdef __i386__
+__attribute__((regparm(1)))
+#endif
+naked (int data)
{
if (data == 0x12345678)
return;
s.sa_flags = 0;
sigaction (SIGILL, &s, NULL);
- data = 0x12345678;
- naked ();
+ naked (0x12345678);
abort ();
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+/* { dg-additional-options "-mregparm=3" { target ia32 } } */
+
+/* Verify that __attribute__((naked)) produces a naked function
+ that does not allocate stack slots for args. */
+extern void bar (int);
+
+int
+__attribute__((naked))
+foo (int a, int b, int c)
+{
+ bar (c);
+ asm volatile ("ret" :: "a" (b));
+}
+
+/* { dg-final { scan-assembler-not "%\[re\]bp" } } */