970 lines
35 KiB
Diff
970 lines
35 KiB
Diff
commit 32d1bf204411cd668271877e039783b229536d5c
|
|
Author: root <root@lenovo-x3950-01.khw.lab.eng.bos.redhat.com>
|
|
Date: Thu Jan 18 17:43:15 2018 -0500
|
|
|
|
HJ's patch #2
|
|
|
|
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
|
|
index 4ae3000..269ca7c 100644
|
|
--- a/gcc/config/i386/i386-protos.h
|
|
+++ b/gcc/config/i386/i386-protos.h
|
|
@@ -279,4 +279,5 @@ extern enum attr_cpu ix86_schedule;
|
|
|
|
extern const char * ix86_output_call_insn (rtx insn, rtx call_op);
|
|
extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
|
|
+extern const char * ix86_output_function_return (bool long_p);
|
|
|
|
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
|
index 410cbc8..9277ba9 100644
|
|
--- a/gcc/config/i386/i386.c
|
|
+++ b/gcc/config/i386/i386.c
|
|
@@ -2071,6 +2071,7 @@ int x86_prefetch_sse;
|
|
static int ix86_regparm;
|
|
|
|
enum indirect_branch ix86_indirect_branch;
|
|
+enum indirect_branch ix86_function_return;
|
|
|
|
/* -mstackrealign option */
|
|
extern int ix86_force_align_arg_pointer;
|
|
@@ -3496,6 +3497,20 @@ override_options (bool main_args_p)
|
|
error ("Unsupported indirect branch type\n");
|
|
}
|
|
|
|
+ if (ix86_function_return_string)
|
|
+ {
|
|
+ if (strcmp (ix86_function_return_string, "keep") == 0)
|
|
+ ix86_function_return = indirect_branch_keep;
|
|
+ else if (strcmp (ix86_function_return_string, "thunk") == 0)
|
|
+ ix86_function_return = indirect_branch_thunk;
|
|
+ else if (strcmp (ix86_function_return_string, "thunk-inline") == 0)
|
|
+ ix86_function_return = indirect_branch_thunk_inline;
|
|
+ else if (strcmp (ix86_function_return_string, "thunk-extern") == 0)
|
|
+ ix86_function_return = indirect_branch_thunk_extern;
|
|
+ else
|
|
+ error ("Unsupported function return type\n");
|
|
+ }
|
|
+
|
|
/* Validate -mregparm= value. */
|
|
if (ix86_regparm_string)
|
|
{
|
|
@@ -4450,6 +4465,31 @@ ix86_set_indirect_branch_type (tree fndecl)
|
|
else
|
|
cfun->machine->indirect_branch_type = ix86_indirect_branch;
|
|
}
|
|
+
|
|
+ if (cfun->machine->function_return_type == indirect_branch_unset)
|
|
+ {
|
|
+ tree attr = lookup_attribute ("function_return",
|
|
+ DECL_ATTRIBUTES (fndecl));
|
|
+ if (attr != NULL)
|
|
+ {
|
|
+ tree args = TREE_VALUE (attr);
|
|
+ if (args == NULL)
|
|
+ gcc_unreachable ();
|
|
+ tree cst = TREE_VALUE (args);
|
|
+ if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
|
|
+ cfun->machine->function_return_type = indirect_branch_keep;
|
|
+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
|
|
+ cfun->machine->function_return_type = indirect_branch_thunk;
|
|
+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
|
|
+ cfun->machine->function_return_type = indirect_branch_thunk_inline;
|
|
+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
|
|
+ cfun->machine->function_return_type = indirect_branch_thunk_extern;
|
|
+ else
|
|
+ gcc_unreachable ();
|
|
+ }
|
|
+ else
|
|
+ cfun->machine->function_return_type = ix86_function_return;
|
|
+ }
|
|
}
|
|
|
|
/* Remember the last target of ix86_set_current_function. */
|
|
@@ -4872,6 +4912,28 @@ ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int dummy,
|
|
}
|
|
}
|
|
|
|
+ if (is_attribute_p ("function_return", name))
|
|
+ {
|
|
+ tree cst = TREE_VALUE (args);
|
|
+ if (TREE_CODE (cst) != STRING_CST)
|
|
+ {
|
|
+ warning (OPT_Wattributes,
|
|
+ "%qE attribute requires a string constant argument",
|
|
+ name);
|
|
+ *no_add_attrs = true;
|
|
+ }
|
|
+ else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
|
|
+ && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
|
|
+ && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
|
|
+ && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
|
|
+ {
|
|
+ warning (OPT_Wattributes,
|
|
+ "argument to %qE attribute is not "
|
|
+ "(keep|thunk|thunk-inline|thunk-extern)", name);
|
|
+ *no_add_attrs = true;
|
|
+ }
|
|
+ }
|
|
+
|
|
return NULL_TREE;
|
|
}
|
|
|
|
@@ -8132,8 +8194,11 @@ static int indirect_thunks_used;
|
|
/* Fills in the label name that should be used for the indirect thunk. */
|
|
|
|
static void
|
|
-indirect_thunk_name (char name[32], int regno)
|
|
+indirect_thunk_name (char name[32], int regno, bool ret_p)
|
|
{
|
|
+ if (regno >= 0 && ret_p)
|
|
+ gcc_unreachable ();
|
|
+
|
|
if (USE_HIDDEN_LINKONCE)
|
|
{
|
|
if (regno >= 0)
|
|
@@ -8147,14 +8212,22 @@ indirect_thunk_name (char name[32], int regno)
|
|
reg_prefix, reg_names[regno]);
|
|
}
|
|
else
|
|
- sprintf (name, "__x86_indirect_thunk");
|
|
+ {
|
|
+ const char *ret = ret_p ? "return" : "indirect";
|
|
+ sprintf (name, "__x86_%s_thunk", ret);
|
|
+ }
|
|
}
|
|
else
|
|
{
|
|
if (regno >= 0)
|
|
ASM_GENERATE_INTERNAL_LABEL (name, "LITR", regno);
|
|
else
|
|
- ASM_GENERATE_INTERNAL_LABEL (name, "LIT", 0);
|
|
+ {
|
|
+ if (ret_p)
|
|
+ ASM_GENERATE_INTERNAL_LABEL (name, "LRT", 0);
|
|
+ else
|
|
+ ASM_GENERATE_INTERNAL_LABEL (name, "LIT", 0);
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -8240,7 +8313,7 @@ output_indirect_thunk_function (int regno)
|
|
tree decl;
|
|
|
|
/* Create __x86_indirect_thunk. */
|
|
- indirect_thunk_name (name, regno);
|
|
+ indirect_thunk_name (name, regno, false);
|
|
decl = build_decl (FUNCTION_DECL,
|
|
get_identifier (name),
|
|
build_function_type_list (void_type_node, NULL_TREE));
|
|
@@ -8284,6 +8357,36 @@ output_indirect_thunk_function (int regno)
|
|
ASM_OUTPUT_LABEL (asm_out_file, name);
|
|
}
|
|
|
|
+ if (regno < 0)
|
|
+ {
|
|
+ /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
|
|
+ char alias[32];
|
|
+
|
|
+ indirect_thunk_name (alias, regno, true);
|
|
+#if TARGET_MACHO
|
|
+ if (TARGET_MACHO)
|
|
+ {
|
|
+ fputs ("\t.weak_definition\t", asm_out_file);
|
|
+ assemble_name (asm_out_file, alias);
|
|
+ fputs ("\n\t.private_extern\t", asm_out_file);
|
|
+ assemble_name (asm_out_file, alias);
|
|
+ putc ('\n', asm_out_file);
|
|
+ ASM_OUTPUT_LABEL (asm_out_file, alias);
|
|
+ }
|
|
+#else
|
|
+ ASM_OUTPUT_DEF (asm_out_file, alias, name);
|
|
+ if (USE_HIDDEN_LINKONCE)
|
|
+ {
|
|
+ fputs ("\t.globl\t", asm_out_file);
|
|
+ assemble_name (asm_out_file, alias);
|
|
+ putc ('\n', asm_out_file);
|
|
+ fputs ("\t.hidden\t", asm_out_file);
|
|
+ assemble_name (asm_out_file, alias);
|
|
+ putc ('\n', asm_out_file);
|
|
+ }
|
|
+#endif
|
|
+ }
|
|
+
|
|
DECL_INITIAL (decl) = make_node (BLOCK);
|
|
current_function_decl = decl;
|
|
allocate_struct_function (decl, false);
|
|
@@ -21088,7 +21191,7 @@ ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p)
|
|
i -= (FIRST_REX_INT_REG - LAST_INT_REG - 1);
|
|
indirect_thunks_used |= 1 << i;
|
|
}
|
|
- indirect_thunk_name (thunk_name_buf, regno);
|
|
+ indirect_thunk_name (thunk_name_buf, regno, false);
|
|
thunk_name = thunk_name_buf;
|
|
}
|
|
else
|
|
@@ -21172,7 +21275,7 @@ ix86_output_indirect_branch_via_push (rtx call_op, const char *xasm,
|
|
{
|
|
if (cfun->machine->indirect_branch_type == indirect_branch_thunk)
|
|
indirect_thunk_needed = true;
|
|
- indirect_thunk_name (thunk_name_buf, regno);
|
|
+ indirect_thunk_name (thunk_name_buf, regno, false);
|
|
thunk_name = thunk_name_buf;
|
|
}
|
|
else
|
|
@@ -21293,6 +21396,37 @@ ix86_output_indirect_jmp (rtx call_op, bool ret_p)
|
|
return "jmp\t%A0";
|
|
}
|
|
|
|
+/* Output function return. CALL_OP is the jump target. Add a REP
|
|
+ prefix to RET if LONG_P is true and function return is kept. */
|
|
+
|
|
+const char *
|
|
+ix86_output_function_return (bool long_p)
|
|
+{
|
|
+ if (cfun->machine->function_return_type != indirect_branch_keep)
|
|
+ {
|
|
+ char thunk_name[32];
|
|
+
|
|
+ if (cfun->machine->function_return_type
|
|
+ != indirect_branch_thunk_inline)
|
|
+ {
|
|
+ bool need_thunk = (cfun->machine->function_return_type
|
|
+ == indirect_branch_thunk);
|
|
+ indirect_thunk_name (thunk_name, -1, true);
|
|
+ indirect_thunk_needed |= need_thunk;
|
|
+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
|
|
+ }
|
|
+ else
|
|
+ output_indirect_thunk (-1);
|
|
+
|
|
+ return "";
|
|
+ }
|
|
+
|
|
+ if (!long_p)
|
|
+ return "ret";
|
|
+
|
|
+ return "rep; ret";
|
|
+}
|
|
+
|
|
/* Output the assembly for a call instruction. */
|
|
|
|
const char *
|
|
@@ -31630,6 +31764,7 @@ static const struct attribute_spec ix86_attribute_table[] =
|
|
{ "ms_abi", 0, 0, false, true, true, ix86_handle_abi_attribute },
|
|
{ "sysv_abi", 0, 0, false, true, true, ix86_handle_abi_attribute },
|
|
{ "indirect_branch", 1, 1, true, false, false, ix86_handle_fndecl_attribute },
|
|
+ { "function_return", 1, 1, true, false, false, ix86_handle_fndecl_attribute },
|
|
/* End element. */
|
|
{ NULL, 0, 0, false, false, false, NULL }
|
|
};
|
|
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
|
|
index 5e239fd..b212ba3 100644
|
|
--- a/gcc/config/i386/i386.h
|
|
+++ b/gcc/config/i386/i386.h
|
|
@@ -2488,6 +2488,9 @@ struct machine_function GTY(())
|
|
/* If true, the current function has local indirect jumps, like
|
|
"indirect_jump" or "tablejump". */
|
|
BOOL_BITFIELD has_local_indirect_jump : 1;
|
|
+
|
|
+ /* How to generate function return. */
|
|
+ ENUM_BITFIELD(indirect_branch) function_return_type : 3;
|
|
};
|
|
#endif
|
|
|
|
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
|
index 37f7125..33f4059 100644
|
|
--- a/gcc/config/i386/i386.md
|
|
+++ b/gcc/config/i386/i386.md
|
|
@@ -15676,7 +15676,7 @@
|
|
(define_insn "return_internal"
|
|
[(return)]
|
|
"reload_completed"
|
|
- "ret"
|
|
+ "* return ix86_output_function_return (false);"
|
|
[(set_attr "length" "1")
|
|
(set_attr "atom_unit" "jeu")
|
|
(set_attr "length_immediate" "0")
|
|
@@ -15689,7 +15689,7 @@
|
|
[(return)
|
|
(unspec [(const_int 0)] UNSPEC_REP)]
|
|
"reload_completed"
|
|
- "rep\;ret"
|
|
+ "* return ix86_output_function_return (true);"
|
|
[(set_attr "length" "2")
|
|
(set_attr "atom_unit" "jeu")
|
|
(set_attr "length_immediate" "0")
|
|
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
|
|
index c8da9b0..f0a0217 100644
|
|
--- a/gcc/config/i386/i386.opt
|
|
+++ b/gcc/config/i386/i386.opt
|
|
@@ -383,3 +383,7 @@ Support F16C built-in functions and code generation
|
|
mindirect-branch=
|
|
Target Report RejectNegative Joined Var(ix86_indirect_branch_string) Init("keep")
|
|
Convert indirect call and jump to call and return thunks.
|
|
+
|
|
+mfunction-return=
|
|
+Target Report RejectNegative Joined Var(ix86_function_return_string) Init("keep")
|
|
+Convert function return to call and return thunk.
|
|
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
|
|
index 3840235..4431179 100644
|
|
--- a/gcc/doc/extend.texi
|
|
+++ b/gcc/doc/extend.texi
|
|
@@ -3119,6 +3119,15 @@ call and jump to call and return thunk. @samp{thunk-inline} converts
|
|
indirect call and jump to inlined call and return thunk.
|
|
@samp{thunk-extern} converts indirect call and jump to external call
|
|
and return thunk provided in a separate object file.
|
|
+
|
|
+@item function_return("@var{choice}")
|
|
+@cindex @code{function_return} function attribute, x86
|
|
+On x86 targets, the @code{function_return} attribute causes the compiler
|
|
+to convert function return with @var{choice}. @samp{keep} keeps function
|
|
+return unmodified. @samp{thunk} converts function return to call and
|
|
+return thunk. @samp{thunk-inline} converts function return to inlined
|
|
+call and return thunk. @samp{thunk-extern} converts function return to
|
|
+external call and return thunk provided in a separate object file.
|
|
@end table
|
|
|
|
On the 386, you can use either multiple strings to specify multiple
|
|
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
|
|
index 790d8b0..5bf5978 100644
|
|
--- a/gcc/doc/invoke.texi
|
|
+++ b/gcc/doc/invoke.texi
|
|
@@ -592,7 +592,7 @@ Objective-C and Objective-C++ Dialects}.
|
|
-mcmodel=@var{code-model} @gol
|
|
-m32 -m64 -mlarge-data-threshold=@var{num} @gol
|
|
-msse2avx
|
|
--mindirect-branch=@var{choice}}
|
|
+-mindirect-branch=@var{choice} -mfunction-return==@var{choice}}
|
|
|
|
@emph{i386 and x86-64 Windows Options}
|
|
@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll
|
|
@@ -11716,6 +11716,17 @@ to external call and return thunk provided in a separate object file.
|
|
You can control this behavior for a specific function by using the
|
|
function attribute @code{indirect_branch}. @xref{Function Attributes}.
|
|
|
|
+@item -mfunction-return=@var{choice}
|
|
+@opindex -mfunction-return
|
|
+Convert function return with @var{choice}. The default is @samp{keep},
|
|
+which keeps function return unmodified. @samp{thunk} converts function
|
|
+return to call and return thunk. @samp{thunk-inline} converts function
|
|
+return to inlined call and return thunk. @samp{thunk-extern} converts
|
|
+function return to external call and return thunk provided in a separate
|
|
+object file. You can control this behavior for a specific function by
|
|
+using the function attribute @code{function_return}.
|
|
+@xref{Function Attributes}.
|
|
+
|
|
@end table
|
|
|
|
These @samp{-m} switches are supported in addition to the above
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c
|
|
index 87f6dae..034b4cc 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c
|
|
index 6bc4f0a..e0c57cb 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c
|
|
index 41e30b6..caa4402 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c
|
|
index 4d0aa72..8ff2840 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
|
|
index 6d51704..1084d6c 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
|
|
|
void func0 (void);
|
|
void func1 (void);
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c
|
|
index efccdec..7c45142 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c
|
|
index ca3814e..9eebc84 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c
|
|
index e5bc318..1013e75 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c
|
|
index b228fbd..2422489 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c
|
|
index 0316448..c62dfab 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c
|
|
index 8805b54..c42ed39 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c
|
|
index 60056ea..02ae316 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
|
|
|
|
void func0 (void);
|
|
void func1 (void);
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c
|
|
index 564ed39..d730d31 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
|
|
|
void func0 (void);
|
|
void func1 (void);
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c
|
|
index 7fd01d6..f424181 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c
|
|
index 825f6b2..ac54868 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c
|
|
index 4708319..4a21e28 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c
|
|
index e4a864a..53cf271 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
|
|
index ebff3c0..0fb4565 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
|
|
|
void func0 (void);
|
|
void func1 (void);
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c
|
|
index 78d58cd..cb31009 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c
|
|
index 825049f..29c836f 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c
|
|
index 894903c..be13f55 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c
|
|
index 4a1df86..c2e08e2 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
|
|
|
typedef void (*dispatch_t)(long offset);
|
|
|
|
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
|
|
index 5948f6c..77cce21 100644
|
|
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
|
|
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
|
|
@@ -1,5 +1,5 @@
|
|
/* { dg-do compile } */
|
|
-/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
|
|
|
void func0 (void);
|
|
void func1 (void);
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-1.c b/gcc/testsuite/gcc.target/i386/ret-thunk-1.c
|
|
new file mode 100644
|
|
index 0000000..7223f67
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-1.c
|
|
@@ -0,0 +1,13 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=thunk" } */
|
|
+
|
|
+void
|
|
+foo (void)
|
|
+{
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler {\tpause} } } */
|
|
+/* { dg-final { scan-assembler {\tlfence} } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
|
new file mode 100644
|
|
index 0000000..501a173
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
|
@@ -0,0 +1,20 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
|
|
+
|
|
+extern void (*bar) (void);
|
|
+
|
|
+int
|
|
+foo (void)
|
|
+{
|
|
+ bar ();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-times {\tpause} 2 } } */
|
|
+/* { dg-final { scan-assembler-times {\tlfence} 2 } } */
|
|
+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } } */
|
|
+/* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
|
new file mode 100644
|
|
index 0000000..c1dc86f
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
|
@@ -0,0 +1,20 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
|
|
+
|
|
+extern void (*bar) (void);
|
|
+
|
|
+int
|
|
+foo (void)
|
|
+{
|
|
+ bar ();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-times {\tpause} 1 } } */
|
|
+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */
|
|
+/* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
|
new file mode 100644
|
|
index 0000000..5f99dc2
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
|
@@ -0,0 +1,19 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
|
+
|
|
+extern void (*bar) (void);
|
|
+
|
|
+int
|
|
+foo (void)
|
|
+{
|
|
+ bar ();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-times {\tpause} 1 } } */
|
|
+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */
|
|
+/* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
|
new file mode 100644
|
|
index 0000000..9d159df
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
|
@@ -0,0 +1,20 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
|
+
|
|
+extern void (*bar) (void);
|
|
+extern int foo (void) __attribute__ ((function_return("thunk")));
|
|
+
|
|
+int
|
|
+foo (void)
|
|
+{
|
|
+ bar ();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-times {\tpause} 2 } } */
|
|
+/* { dg-final { scan-assembler-times {\tlfence} 2 } } */
|
|
+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" } } */
|
|
+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 3 } } */
|
|
+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 3 } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_indirect_thunk" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
|
new file mode 100644
|
|
index 0000000..807d99a
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
|
@@ -0,0 +1,20 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
|
+
|
|
+extern void (*bar) (void);
|
|
+
|
|
+__attribute__ ((function_return("thunk-inline")))
|
|
+int
|
|
+foo (void)
|
|
+{
|
|
+ bar ();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler-times {\tpause} 1 } } */
|
|
+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
|
new file mode 100644
|
|
index 0000000..ccc82a1
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
|
@@ -0,0 +1,20 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
|
|
+
|
|
+extern void (*bar) (void);
|
|
+
|
|
+__attribute__ ((function_return("thunk-extern"), indirect_branch("thunk")))
|
|
+int
|
|
+foo (void)
|
|
+{
|
|
+ bar ();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler-times {\tpause} 1 } } */
|
|
+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */
|
|
+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-16.c b/gcc/testsuite/gcc.target/i386/ret-thunk-16.c
|
|
new file mode 100644
|
|
index 0000000..a16cad1
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-16.c
|
|
@@ -0,0 +1,18 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk-extern -fno-pic" } */
|
|
+
|
|
+extern void (*bar) (void);
|
|
+
|
|
+__attribute__ ((function_return("keep"), indirect_branch("keep")))
|
|
+int
|
|
+foo (void)
|
|
+{
|
|
+ bar ();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */
|
|
+/* { dg-final { scan-assembler-not "__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-2.c b/gcc/testsuite/gcc.target/i386/ret-thunk-2.c
|
|
new file mode 100644
|
|
index 0000000..c6659e3
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-2.c
|
|
@@ -0,0 +1,13 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */
|
|
+
|
|
+void
|
|
+foo (void)
|
|
+{
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler {\tpause} } } */
|
|
+/* { dg-final { scan-assembler {\tlfence} } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-3.c b/gcc/testsuite/gcc.target/i386/ret-thunk-3.c
|
|
new file mode 100644
|
|
index 0000000..0f7f388
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-3.c
|
|
@@ -0,0 +1,12 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=thunk-extern" } */
|
|
+
|
|
+void
|
|
+foo (void)
|
|
+{
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-4.c b/gcc/testsuite/gcc.target/i386/ret-thunk-4.c
|
|
new file mode 100644
|
|
index 0000000..9ae37e8
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-4.c
|
|
@@ -0,0 +1,12 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep" } */
|
|
+
|
|
+void
|
|
+foo (void)
|
|
+{
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-5.c b/gcc/testsuite/gcc.target/i386/ret-thunk-5.c
|
|
new file mode 100644
|
|
index 0000000..4bd0d2a
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-5.c
|
|
@@ -0,0 +1,15 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep" } */
|
|
+
|
|
+extern void foo (void) __attribute__ ((function_return("thunk")));
|
|
+
|
|
+void
|
|
+foo (void)
|
|
+{
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler {\tpause} } } */
|
|
+/* { dg-final { scan-assembler {\tlfence} } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-6.c b/gcc/testsuite/gcc.target/i386/ret-thunk-6.c
|
|
new file mode 100644
|
|
index 0000000..053841f
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-6.c
|
|
@@ -0,0 +1,14 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep" } */
|
|
+
|
|
+__attribute__ ((function_return("thunk-inline")))
|
|
+void
|
|
+foo (void)
|
|
+{
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler {\tpause} } } */
|
|
+/* { dg-final { scan-assembler {\tlfence} } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-7.c b/gcc/testsuite/gcc.target/i386/ret-thunk-7.c
|
|
new file mode 100644
|
|
index 0000000..262e678
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-7.c
|
|
@@ -0,0 +1,13 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=keep" } */
|
|
+
|
|
+__attribute__ ((function_return("thunk-extern")))
|
|
+void
|
|
+foo (void)
|
|
+{
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-8.c b/gcc/testsuite/gcc.target/i386/ret-thunk-8.c
|
|
new file mode 100644
|
|
index 0000000..c1658e9
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-8.c
|
|
@@ -0,0 +1,14 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */
|
|
+
|
|
+extern void foo (void) __attribute__ ((function_return("keep")));
|
|
+
|
|
+void
|
|
+foo (void)
|
|
+{
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */
|
|
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
|
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
|
new file mode 100644
|
|
index 0000000..617d5c6
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
|
@@ -0,0 +1,20 @@
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
|
|
+
|
|
+extern void (*bar) (void);
|
|
+
|
|
+int
|
|
+foo (void)
|
|
+{
|
|
+ bar ();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
|
+/* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */
|
|
+/* { dg-final { scan-assembler-times {\tpause} 1 } } */
|
|
+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */
|
|
+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" } } */
|
|
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */
|