Commit a97cf8f9 by Uros Bizjak Committed by Uros Bizjak

re PR target/25967 (Add attribute naked for x86)

	PR target/25967
	* config/i386/i386.c (ix86_allocate_stack_slots_for_args):
	New function.
	(TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS): Define.

testsuite/ChangeLog:

	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.

From-SVN: r250742
parent 9c04bba3
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> 2017-07-31 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* config.gcc: Add z14. * config.gcc: Add z14.
......
...@@ -31676,6 +31676,13 @@ ix86_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) ...@@ -31676,6 +31676,13 @@ ix86_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
} }
static bool 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) ix86_warn_func_return (tree decl)
{ {
/* Naked functions are implemented entirely in assembly, including the /* Naked functions are implemented entirely in assembly, including the
...@@ -52727,6 +52734,8 @@ ix86_run_selftests (void) ...@@ -52727,6 +52734,8 @@ ix86_run_selftests (void)
#define TARGET_SETUP_INCOMING_VARARGS ix86_setup_incoming_varargs #define TARGET_SETUP_INCOMING_VARARGS ix86_setup_incoming_varargs
#undef TARGET_MUST_PASS_IN_STACK #undef TARGET_MUST_PASS_IN_STACK
#define TARGET_MUST_PASS_IN_STACK ix86_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 #undef TARGET_FUNCTION_ARG_ADVANCE
#define TARGET_FUNCTION_ARG_ADVANCE ix86_function_arg_advance #define TARGET_FUNCTION_ARG_ADVANCE ix86_function_arg_advance
#undef TARGET_FUNCTION_ARG #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> 2017-07-31 Jan Hubicka <hubicka@ucw.cz>
Martin Liska <mliska@suse.cz> Martin Liska <mliska@suse.cz>
......
/* { dg-do run { target *-*-linux* *-*-gnu* } } */ /* { dg-do run { target *-*-linux* *-*-gnu* } } */
/* { dg-options "-O2" } */ /* { dg-options "-O0" } */
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
int data;
/* Verify that naked function traps at the end. */ /* Verify that naked function traps at the end. */
void void
__attribute__((naked, noinline, noclone)) __attribute__((naked, noinline, noclone))
naked (void) #ifdef __i386__
__attribute__((regparm(1)))
#endif
naked (int data)
{ {
if (data == 0x12345678) if (data == 0x12345678)
return; return;
...@@ -32,8 +33,7 @@ int main () ...@@ -32,8 +33,7 @@ int main ()
s.sa_flags = 0; s.sa_flags = 0;
sigaction (SIGILL, &s, NULL); sigaction (SIGILL, &s, NULL);
data = 0x12345678; naked (0x12345678);
naked ();
abort (); abort ();
} }
/* { 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment