|
|
22033d |
commit 4361c221ff4b53f585a2e8c0ba38956c8132609f
|
|
|
22033d |
Author: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
|
|
22033d |
Date: Mon Feb 26 15:29:30 2018 +0000
|
|
|
22033d |
|
|
|
22033d |
i386: Update -mfunction-return= for return with pop
|
|
|
22033d |
|
|
|
22033d |
When -mfunction-return= is used, simple_return_pop_internal should pop
|
|
|
22033d |
return address into ECX register, adjust stack by bytes to pop from stack
|
|
|
22033d |
and jump to the return thunk via ECX register.
|
|
|
22033d |
|
|
|
22033d |
Tested on i686 and x86-64.
|
|
|
22033d |
|
|
|
22033d |
PR target/84530
|
|
|
22033d |
* config/i386/i386-protos.h (ix86_output_indirect_jmp): Remove
|
|
|
22033d |
the bool argument.
|
|
|
22033d |
(ix86_output_indirect_function_return): New prototype.
|
|
|
22033d |
(ix86_split_simple_return_pop_internal): Likewise.
|
|
|
22033d |
* config/i386/i386.c (indirect_return_via_cx): New.
|
|
|
22033d |
(indirect_return_via_cx_bnd): Likewise.
|
|
|
22033d |
(indirect_thunk_name): Handle return va CX_REG.
|
|
|
22033d |
(output_indirect_thunk_function): Create alias for
|
|
|
22033d |
__x86_return_thunk_[re]cx and __x86_return_thunk_[re]cx_bnd.
|
|
|
22033d |
(ix86_output_indirect_jmp): Remove the bool argument.
|
|
|
22033d |
(ix86_output_indirect_function_return): New function.
|
|
|
22033d |
(ix86_split_simple_return_pop_internal): Likewise.
|
|
|
22033d |
* config/i386/i386.md (*indirect_jump): Don't pass false
|
|
|
22033d |
to ix86_output_indirect_jmp.
|
|
|
22033d |
(*tablejump_1): Likewise.
|
|
|
22033d |
(simple_return_pop_internal): Change it to define_insn_and_split.
|
|
|
22033d |
Call ix86_split_simple_return_pop_internal to split it for
|
|
|
22033d |
-mfunction-return=.
|
|
|
22033d |
(simple_return_indirect_internal): Call
|
|
|
22033d |
ix86_output_indirect_function_return instead of
|
|
|
22033d |
ix86_output_indirect_jmp.
|
|
|
22033d |
|
|
|
22033d |
gcc/testsuite/
|
|
|
22033d |
|
|
|
22033d |
PR target/84530
|
|
|
22033d |
* gcc.target/i386/ret-thunk-22.c: New test.
|
|
|
22033d |
* gcc.target/i386/ret-thunk-23.c: Likewise.
|
|
|
22033d |
* gcc.target/i386/ret-thunk-24.c: Likewise.
|
|
|
22033d |
* gcc.target/i386/ret-thunk-25.c: Likewise.
|
|
|
22033d |
* gcc.target/i386/ret-thunk-26.c: Likewise.
|
|
|
22033d |
|
|
|
22033d |
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257992 138bc75d-0d04-0410-961f-82ee72b054a4
|
|
|
22033d |
|
|
|
22033d |
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
|
|
|
22033d |
index 4e4b2100f79..394d4aebf96 100644
|
|
|
22033d |
--- a/gcc/config/i386/i386-protos.h
|
|
|
22033d |
+++ b/gcc/config/i386/i386-protos.h
|
|
|
22033d |
@@ -306,8 +306,10 @@ extern enum attr_cpu ix86_schedule;
|
|
|
22033d |
#endif
|
|
|
22033d |
|
|
|
22033d |
extern const char * ix86_output_call_insn (rtx insn, rtx call_op);
|
|
|
22033d |
-extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
|
|
|
22033d |
+extern const char * ix86_output_indirect_jmp (rtx call_op);
|
|
|
22033d |
extern const char * ix86_output_function_return (bool long_p);
|
|
|
22033d |
+extern const char * ix86_output_indirect_function_return (rtx ret_op);
|
|
|
22033d |
+extern void ix86_split_simple_return_pop_internal (rtx);
|
|
|
22033d |
|
|
|
22033d |
#ifdef RTX_CODE
|
|
|
22033d |
/* Target data for multipass lookahead scheduling.
|
|
|
22033d |
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
|
|
22033d |
index c25d26ca826..a8238a001ee 100644
|
|
|
22033d |
--- a/gcc/config/i386/i386.c
|
|
|
22033d |
+++ b/gcc/config/i386/i386.c
|
|
|
22033d |
@@ -8777,6 +8777,9 @@ static bool indirect_thunk_needed = false;
|
|
|
22033d |
by call and return thunks functions. */
|
|
|
22033d |
static int indirect_thunks_used;
|
|
|
22033d |
|
|
|
22033d |
+/* True if return thunk function via CX is needed. */
|
|
|
22033d |
+static bool indirect_return_via_cx;
|
|
|
22033d |
+
|
|
|
22033d |
#ifndef INDIRECT_LABEL
|
|
|
22033d |
# define INDIRECT_LABEL "LIND"
|
|
|
22033d |
#endif
|
|
|
22033d |
@@ -8786,26 +8789,29 @@ static int indirect_thunks_used;
|
|
|
22033d |
static void
|
|
|
22033d |
indirect_thunk_name (char name[32], int regno, bool ret_p)
|
|
|
22033d |
{
|
|
|
22033d |
- if (regno >= 0 && ret_p)
|
|
|
22033d |
+ if (regno != INVALID_REGNUM && regno != CX_REG && ret_p)
|
|
|
22033d |
gcc_unreachable ();
|
|
|
22033d |
|
|
|
22033d |
if (USE_HIDDEN_LINKONCE)
|
|
|
22033d |
{
|
|
|
22033d |
- if (regno >= 0)
|
|
|
22033d |
+ const char *prefix;
|
|
|
22033d |
+
|
|
|
22033d |
+ prefix = "";
|
|
|
22033d |
+
|
|
|
22033d |
+ const char *ret = ret_p ? "return" : "indirect";
|
|
|
22033d |
+
|
|
|
22033d |
+ if (regno != INVALID_REGNUM)
|
|
|
22033d |
{
|
|
|
22033d |
const char *reg_prefix;
|
|
|
22033d |
if (LEGACY_INT_REGNO_P (regno))
|
|
|
22033d |
reg_prefix = TARGET_64BIT ? "r" : "e";
|
|
|
22033d |
else
|
|
|
22033d |
reg_prefix = "";
|
|
|
22033d |
- sprintf (name, "__x86_indirect_thunk_%s%s",
|
|
|
22033d |
- reg_prefix, reg_names[regno]);
|
|
|
22033d |
+ sprintf (name, "__x86_%s_thunk%s_%s%s",
|
|
|
22033d |
+ ret, prefix, reg_prefix, reg_names[regno]);
|
|
|
22033d |
}
|
|
|
22033d |
else
|
|
|
22033d |
- {
|
|
|
22033d |
- const char *ret = ret_p ? "return" : "indirect";
|
|
|
22033d |
- sprintf (name, "__x86_%s_thunk", ret);
|
|
|
22033d |
- }
|
|
|
22033d |
+ sprintf (name, "__x86_%s_thunk%s", ret, prefix);
|
|
|
22033d |
}
|
|
|
22033d |
else
|
|
|
22033d |
{
|
|
|
22033d |
@@ -8947,9 +8953,18 @@ output_indirect_thunk_function (int regno)
|
|
|
22033d |
ASM_OUTPUT_LABEL (asm_out_file, name);
|
|
|
22033d |
}
|
|
|
22033d |
|
|
|
22033d |
- if (regno < 0)
|
|
|
22033d |
+ /* Create alias for __x86_return_thunk or
|
|
|
22033d |
+ __x86_return_thunk_ecx. */
|
|
|
22033d |
+ bool need_alias;
|
|
|
22033d |
+ if (regno == INVALID_REGNUM)
|
|
|
22033d |
+ need_alias = true;
|
|
|
22033d |
+ else if (regno == CX_REG)
|
|
|
22033d |
+ need_alias = indirect_return_via_cx;
|
|
|
22033d |
+ else
|
|
|
22033d |
+ need_alias = false;
|
|
|
22033d |
+
|
|
|
22033d |
+ if (need_alias)
|
|
|
22033d |
{
|
|
|
22033d |
- /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
|
|
|
22033d |
char alias[32];
|
|
|
22033d |
|
|
|
22033d |
indirect_thunk_name (alias, regno, true);
|
|
|
22033d |
@@ -24704,21 +24719,21 @@ ix86_output_indirect_branch (rtx call_op, const char *xasm,
|
|
|
22033d |
else
|
|
|
22033d |
ix86_output_indirect_branch_via_push (call_op, xasm, sibcall_p);
|
|
|
22033d |
}
|
|
|
22033d |
+
|
|
|
22033d |
/* Output indirect jump. CALL_OP is the jump target. Jump is a
|
|
|
22033d |
function return if RET_P is true. */
|
|
|
22033d |
|
|
|
22033d |
const char *
|
|
|
22033d |
-ix86_output_indirect_jmp (rtx call_op, bool ret_p)
|
|
|
22033d |
+ix86_output_indirect_jmp (rtx call_op)
|
|
|
22033d |
{
|
|
|
22033d |
if (cfun->machine->indirect_branch_type != indirect_branch_keep)
|
|
|
22033d |
{
|
|
|
22033d |
struct ix86_frame frame;
|
|
|
22033d |
ix86_compute_frame_layout (&frame);
|
|
|
22033d |
|
|
|
22033d |
- /* We can't have red-zone if this isn't a function return since
|
|
|
22033d |
- "call" in the indirect thunk pushes the return address onto
|
|
|
22033d |
- stack, destroying red-zone. */
|
|
|
22033d |
- if (!ret_p && frame.red_zone_size != 0)
|
|
|
22033d |
+ /* We can't have red-zone since "call" in the indirect thunk
|
|
|
22033d |
+ pushes the return address onto the stack, destroying the red-zone. */
|
|
|
22033d |
+ if (frame.red_zone_size != 0)
|
|
|
22033d |
gcc_unreachable ();
|
|
|
22033d |
|
|
|
22033d |
ix86_output_indirect_branch (call_op, "%0", true);
|
|
|
22033d |
@@ -24759,6 +24774,75 @@ ix86_output_function_return (bool long_p)
|
|
|
22033d |
return "rep%; ret";
|
|
|
22033d |
}
|
|
|
22033d |
|
|
|
22033d |
+/* Output indirect function return. RET_OP is the function return
|
|
|
22033d |
+ target. */
|
|
|
22033d |
+
|
|
|
22033d |
+const char *
|
|
|
22033d |
+ix86_output_indirect_function_return (rtx ret_op)
|
|
|
22033d |
+{
|
|
|
22033d |
+ if (cfun->machine->function_return_type != indirect_branch_keep)
|
|
|
22033d |
+ {
|
|
|
22033d |
+ char thunk_name[32];
|
|
|
22033d |
+ enum indirect_thunk_prefix need_prefix
|
|
|
22033d |
+ = indirect_thunk_need_prefix (current_output_insn);
|
|
|
22033d |
+ unsigned int regno = REGNO (ret_op);
|
|
|
22033d |
+ gcc_assert (regno == CX_REG);
|
|
|
22033d |
+
|
|
|
22033d |
+ if (cfun->machine->function_return_type
|
|
|
22033d |
+ != indirect_branch_thunk_inline)
|
|
|
22033d |
+ {
|
|
|
22033d |
+ bool need_thunk = (cfun->machine->function_return_type
|
|
|
22033d |
+ == indirect_branch_thunk);
|
|
|
22033d |
+ indirect_thunk_name (thunk_name, regno, need_prefix, true);
|
|
|
22033d |
+ if (need_thunk)
|
|
|
22033d |
+ {
|
|
|
22033d |
+ indirect_return_via_cx = true;
|
|
|
22033d |
+ indirect_thunks_used |= 1 << CX_REG;
|
|
|
22033d |
+ }
|
|
|
22033d |
+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
|
|
|
22033d |
+ }
|
|
|
22033d |
+ else
|
|
|
22033d |
+ output_indirect_thunk (need_prefix, regno);
|
|
|
22033d |
+
|
|
|
22033d |
+ return "";
|
|
|
22033d |
+ }
|
|
|
22033d |
+ else
|
|
|
22033d |
+ return "jmp\t%A0";
|
|
|
22033d |
+}
|
|
|
22033d |
+
|
|
|
22033d |
+/* Split simple return with popping POPC bytes from stack to indirect
|
|
|
22033d |
+ branch with stack adjustment . */
|
|
|
22033d |
+
|
|
|
22033d |
+void
|
|
|
22033d |
+ix86_split_simple_return_pop_internal (rtx popc)
|
|
|
22033d |
+{
|
|
|
22033d |
+ struct machine_function *m = cfun->machine;
|
|
|
22033d |
+ rtx ecx = gen_rtx_REG (SImode, CX_REG);
|
|
|
22033d |
+ rtx insn;
|
|
|
22033d |
+
|
|
|
22033d |
+ /* There is no "pascal" calling convention in any 64bit ABI. */
|
|
|
22033d |
+ gcc_assert (!TARGET_64BIT);
|
|
|
22033d |
+
|
|
|
22033d |
+ insn = emit_insn (gen_pop (ecx));
|
|
|
22033d |
+ m->fs.cfa_offset -= UNITS_PER_WORD;
|
|
|
22033d |
+ m->fs.sp_offset -= UNITS_PER_WORD;
|
|
|
22033d |
+
|
|
|
22033d |
+ rtx x = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD);
|
|
|
22033d |
+ x = gen_rtx_SET (VOIDmode, stack_pointer_rtx, x);
|
|
|
22033d |
+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x);
|
|
|
22033d |
+ add_reg_note (insn, REG_CFA_REGISTER, gen_rtx_SET (VOIDmode, ecx, pc_rtx));
|
|
|
22033d |
+ RTX_FRAME_RELATED_P (insn) = 1;
|
|
|
22033d |
+
|
|
|
22033d |
+ x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, popc);
|
|
|
22033d |
+ x = gen_rtx_SET (VOIDmode, stack_pointer_rtx, x);
|
|
|
22033d |
+ insn = emit_insn (x);
|
|
|
22033d |
+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x);
|
|
|
22033d |
+ RTX_FRAME_RELATED_P (insn) = 1;
|
|
|
22033d |
+
|
|
|
22033d |
+ /* Now return address is in ECX. */
|
|
|
22033d |
+ emit_jump_insn (gen_simple_return_indirect_internal (ecx));
|
|
|
22033d |
+}
|
|
|
22033d |
+
|
|
|
22033d |
/* Output the assembly for a call instruction. */
|
|
|
22033d |
|
|
|
22033d |
const char *
|
|
|
22033d |
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
|
|
22033d |
index 228f8f6d77a..3320ec233d2 100644
|
|
|
22033d |
--- a/gcc/config/i386/i386.md
|
|
|
22033d |
+++ b/gcc/config/i386/i386.md
|
|
|
22033d |
@@ -11282,7 +11282,7 @@
|
|
|
22033d |
(define_insn "*indirect_jump"
|
|
|
22033d |
[(set (pc) (match_operand:W 0 "indirect_branch_operand" "rw"))]
|
|
|
22033d |
""
|
|
|
22033d |
- "* return ix86_output_indirect_jmp (operands[0], false);"
|
|
|
22033d |
+ "* return ix86_output_indirect_jmp (operands[0]);"
|
|
|
22033d |
[(set (attr "type")
|
|
|
22033d |
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
|
|
22033d |
!= indirect_branch_keep)")
|
|
|
22033d |
@@ -11336,7 +11336,7 @@
|
|
|
22033d |
[(set (pc) (match_operand:W 0 "indirect_branch_operand" "rw"))
|
|
|
22033d |
(use (label_ref (match_operand 1)))]
|
|
|
22033d |
""
|
|
|
22033d |
- "* return ix86_output_indirect_jmp (operands[0], false);"
|
|
|
22033d |
+ "* return ix86_output_indirect_jmp (operands[0]);"
|
|
|
22033d |
[(set (attr "type")
|
|
|
22033d |
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
|
|
22033d |
!= indirect_branch_keep)")
|
|
|
22033d |
@@ -11769,11 +11769,14 @@
|
|
|
22033d |
(set_attr "prefix_rep" "1")
|
|
|
22033d |
(set_attr "modrm" "0")])
|
|
|
22033d |
|
|
|
22033d |
-(define_insn "simple_return_pop_internal"
|
|
|
22033d |
+(define_insn_and_split "simple_return_pop_internal"
|
|
|
22033d |
[(simple_return)
|
|
|
22033d |
(use (match_operand:SI 0 "const_int_operand"))]
|
|
|
22033d |
"reload_completed"
|
|
|
22033d |
"ret\t%0"
|
|
|
22033d |
+ "&& cfun->machine->function_return_type != indirect_branch_keep"
|
|
|
22033d |
+ [(const_int 0)]
|
|
|
22033d |
+ "ix86_split_simple_return_pop_internal (operands[0]); DONE;"
|
|
|
22033d |
[(set_attr "length" "3")
|
|
|
22033d |
(set_attr "atom_unit" "jeu")
|
|
|
22033d |
(set_attr "length_immediate" "2")
|
|
|
22033d |
@@ -11783,7 +11786,7 @@
|
|
|
22033d |
[(simple_return)
|
|
|
22033d |
(use (match_operand:SI 0 "register_operand" "r"))]
|
|
|
22033d |
"reload_completed"
|
|
|
22033d |
- "* return ix86_output_indirect_jmp (operands[0], true);"
|
|
|
22033d |
+ "* return ix86_output_indirect_function_return (operands[0]);"
|
|
|
22033d |
[(set (attr "type")
|
|
|
22033d |
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
|
|
22033d |
!= indirect_branch_keep)")
|
|
|
22033d |
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-22.c b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
|
|
22033d |
new file mode 100644
|
|
|
22033d |
index 00000000000..89e086de97b
|
|
|
22033d |
--- /dev/null
|
|
|
22033d |
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
|
|
22033d |
@@ -0,0 +1,15 @@
|
|
|
22033d |
+/* PR target/r84530 */
|
|
|
22033d |
+/* { dg-do compile { target ia32 } } */
|
|
|
22033d |
+/* { dg-options "-O2 -mfunction-return=thunk" } */
|
|
|
22033d |
+
|
|
|
22033d |
+struct s { _Complex unsigned short x; };
|
|
|
22033d |
+struct s gs = { 100 + 200i };
|
|
|
22033d |
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
|
|
22033d |
+
|
|
|
22033d |
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler {\tpause} } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler {\tlfence} } } */
|
|
|
22033d |
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-23.c b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
|
|
22033d |
new file mode 100644
|
|
|
22033d |
index 00000000000..43f0ccaa854
|
|
|
22033d |
--- /dev/null
|
|
|
22033d |
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
|
|
22033d |
@@ -0,0 +1,15 @@
|
|
|
22033d |
+/* PR target/r84530 */
|
|
|
22033d |
+/* { dg-do compile { target ia32 } } */
|
|
|
22033d |
+/* { dg-options "-O2 -mfunction-return=thunk-extern" } */
|
|
|
22033d |
+
|
|
|
22033d |
+struct s { _Complex unsigned short x; };
|
|
|
22033d |
+struct s gs = { 100 + 200i };
|
|
|
22033d |
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
|
|
22033d |
+
|
|
|
22033d |
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler-not {\tpause} } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler-not {\tlfence} } } */
|
|
|
22033d |
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-24.c b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
|
|
22033d |
new file mode 100644
|
|
|
22033d |
index 00000000000..8729e35147e
|
|
|
22033d |
--- /dev/null
|
|
|
22033d |
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
|
|
22033d |
@@ -0,0 +1,15 @@
|
|
|
22033d |
+/* PR target/r84530 */
|
|
|
22033d |
+/* { dg-do compile { target ia32 } } */
|
|
|
22033d |
+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */
|
|
|
22033d |
+
|
|
|
22033d |
+struct s { _Complex unsigned short x; };
|
|
|
22033d |
+struct s gs = { 100 + 200i };
|
|
|
22033d |
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
|
|
22033d |
+
|
|
|
22033d |
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler {\tpause} } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler {\tlfence} } } */
|
|
|
22033d |
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-25.c b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
|
|
22033d |
new file mode 100644
|
|
|
22033d |
index 00000000000..f73553c9a9f
|
|
|
22033d |
--- /dev/null
|
|
|
22033d |
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
|
|
22033d |
@@ -0,0 +1,14 @@
|
|
|
22033d |
+/* PR target/r84530 */
|
|
|
22033d |
+/* { dg-do compile { target ia32 } } */
|
|
|
22033d |
+/* { dg-options "-O2 -mfunction-return=thunk -fno-pic" } */
|
|
|
22033d |
+
|
|
|
22033d |
+struct s { _Complex unsigned short x; };
|
|
|
22033d |
+struct s gs = { 100 + 200i };
|
|
|
22033d |
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
|
|
22033d |
+
|
|
|
22033d |
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler {\tpause} } } */
|
|
|
22033d |
+/* { dg-final { scan-assembler {\tlfence} } } */
|
|
|
22033d |
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-26.c b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
|
|
22033d |
new file mode 100644
|
|
|
22033d |
index 00000000000..9144e988735
|
|
|
22033d |
--- /dev/null
|
|
|
22033d |
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
|
|
22033d |
@@ -0,0 +1,40 @@
|
|
|
22033d |
+/* PR target/r84530 */
|
|
|
22033d |
+/* { dg-do run } */
|
|
|
22033d |
+/* { dg-options "-Os -mfunction-return=thunk" } */
|
|
|
22033d |
+
|
|
|
22033d |
+struct S { int i; };
|
|
|
22033d |
+__attribute__((const, noinline, noclone))
|
|
|
22033d |
+struct S foo (int x)
|
|
|
22033d |
+{
|
|
|
22033d |
+ struct S s;
|
|
|
22033d |
+ s.i = x;
|
|
|
22033d |
+ return s;
|
|
|
22033d |
+}
|
|
|
22033d |
+
|
|
|
22033d |
+int a[2048], b[2048], c[2048], d[2048];
|
|
|
22033d |
+struct S e[2048];
|
|
|
22033d |
+
|
|
|
22033d |
+__attribute__((noinline, noclone)) void
|
|
|
22033d |
+bar (void)
|
|
|
22033d |
+{
|
|
|
22033d |
+ int i;
|
|
|
22033d |
+ for (i = 0; i < 1024; i++)
|
|
|
22033d |
+ {
|
|
|
22033d |
+ e[i] = foo (i);
|
|
|
22033d |
+ a[i+2] = a[i] + a[i+1];
|
|
|
22033d |
+ b[10] = b[10] + i;
|
|
|
22033d |
+ c[i] = c[2047 - i];
|
|
|
22033d |
+ d[i] = d[i + 1];
|
|
|
22033d |
+ }
|
|
|
22033d |
+}
|
|
|
22033d |
+
|
|
|
22033d |
+int
|
|
|
22033d |
+main ()
|
|
|
22033d |
+{
|
|
|
22033d |
+ int i;
|
|
|
22033d |
+ bar ();
|
|
|
22033d |
+ for (i = 0; i < 1024; i++)
|
|
|
22033d |
+ if (e[i].i != i)
|
|
|
22033d |
+ __builtin_abort ();
|
|
|
22033d |
+ return 0;
|
|
|
22033d |
+}
|