Commit a5463d23 by H.J. Lu

Properly align stack in gcc.target/i386/cleanup-[12].c

	PR testsuite/70364
	* gcc.target/i386/cleanup-1.c: Include <stddef.h>.
	(check): New function.
	(bar): Call check.
	(foo): Align stack to 16 bytes when calling bar.
	* gcc.target/i386/cleanup-2.c: Likewise.

From-SVN: r234557
parent 9c49362f
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <unwind.h> #include <unwind.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
...@@ -47,6 +48,14 @@ handler (void *p __attribute__((unused))) ...@@ -47,6 +48,14 @@ handler (void *p __attribute__((unused)))
_exit (0); _exit (0);
} }
static void
__attribute__((noinline))
check (intptr_t p)
{
if ((p & 15) != 0)
abort ();
}
static int __attribute__((noinline)) static int __attribute__((noinline))
fn5 (void) fn5 (void)
{ {
...@@ -59,6 +68,8 @@ void ...@@ -59,6 +68,8 @@ void
bar (void) bar (void)
{ {
char dummy __attribute__((cleanup (counter))); char dummy __attribute__((cleanup (counter)));
unsigned long tmp[4] __attribute__((aligned(16)));
check ((intptr_t) tmp);
fn5 (); fn5 ();
} }
...@@ -133,9 +144,9 @@ foo (int x) ...@@ -133,9 +144,9 @@ foo (int x)
".type _L_mutex_lock_%=, @function\n" ".type _L_mutex_lock_%=, @function\n"
"_L_mutex_lock_%=:\n" "_L_mutex_lock_%=:\n"
"1:\t" "leaq %1, %%rdi\n" "1:\t" "leaq %1, %%rdi\n"
"2:\t" "subq $128, %%rsp\n" "2:\t" "subq $136, %%rsp\n"
"3:\t" "call bar\n" "3:\t" "call bar\n"
"4:\t" "addq $128, %%rsp\n" "4:\t" "addq $136, %%rsp\n"
"5:\t" "jmp 24f\n" "5:\t" "jmp 24f\n"
"6:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t" "6:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t"
".previous\n\t" ".previous\n\t"
...@@ -179,7 +190,7 @@ foo (int x) ...@@ -179,7 +190,7 @@ foo (int x)
".sleb128 4b-3b\n" ".sleb128 4b-3b\n"
"16:\t" ".byte 0x40 + (4b-3b-1) # DW_CFA_advance_loc\n\t" "16:\t" ".byte 0x40 + (4b-3b-1) # DW_CFA_advance_loc\n\t"
".byte 0x0e # DW_CFA_def_cfa_offset\n\t" ".byte 0x0e # DW_CFA_def_cfa_offset\n\t"
".uleb128 128\n\t" ".uleb128 136\n\t"
".byte 0x16 # DW_CFA_val_expression\n\t" ".byte 0x16 # DW_CFA_val_expression\n\t"
".uleb128 0x10\n\t" ".uleb128 0x10\n\t"
".uleb128 20f-17f\n" ".uleb128 20f-17f\n"
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <unwind.h> #include <unwind.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
...@@ -47,6 +48,14 @@ handler (void *p __attribute__((unused))) ...@@ -47,6 +48,14 @@ handler (void *p __attribute__((unused)))
_exit (0); _exit (0);
} }
static void
__attribute__((noinline))
check (intptr_t p)
{
if ((p & 15) != 0)
abort ();
}
static int __attribute__((noinline)) static int __attribute__((noinline))
fn5 (void) fn5 (void)
{ {
...@@ -59,6 +68,8 @@ void ...@@ -59,6 +68,8 @@ void
bar (void) bar (void)
{ {
char dummy __attribute__((cleanup (counter))); char dummy __attribute__((cleanup (counter)));
unsigned long tmp[4] __attribute__((aligned(16)));
check ((intptr_t) tmp);
fn5 (); fn5 ();
} }
...@@ -74,9 +85,9 @@ foo (int x) ...@@ -74,9 +85,9 @@ foo (int x)
".type _L_mutex_lock_%=, @function\n" ".type _L_mutex_lock_%=, @function\n"
"_L_mutex_lock_%=:\n" "_L_mutex_lock_%=:\n"
"1:\t" "leaq %1, %%rdi\n" "1:\t" "leaq %1, %%rdi\n"
"2:\t" "subq $128, %%rsp\n" "2:\t" "subq $136, %%rsp\n"
"3:\t" "call bar\n" "3:\t" "call bar\n"
"4:\t" "addq $128, %%rsp\n" "4:\t" "addq $136, %%rsp\n"
"5:\t" "jmp 21f\n" "5:\t" "jmp 21f\n"
"6:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t" "6:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t"
".previous\n\t" ".previous\n\t"
...@@ -160,7 +171,7 @@ foo (int x) ...@@ -160,7 +171,7 @@ foo (int x)
".uleb128 6b-5b-1\n" ".uleb128 6b-5b-1\n"
"19:\t" ".byte 0x40 + (3b-1b) # DW_CFA_advance_loc\n\t" "19:\t" ".byte 0x40 + (3b-1b) # DW_CFA_advance_loc\n\t"
".byte 0xe # DW_CFA_def_cfa_offset\n\t" ".byte 0xe # DW_CFA_def_cfa_offset\n\t"
".uleb128 128\n\t" ".uleb128 136\n\t"
".byte 0x40 + (5b-3b) # DW_CFA_advance_loc\n\t" ".byte 0x40 + (5b-3b) # DW_CFA_advance_loc\n\t"
".byte 0xe # DW_CFA_def_cfa_offset\n\t" ".byte 0xe # DW_CFA_def_cfa_offset\n\t"
".uleb128 0\n\t" ".uleb128 0\n\t"
......
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