Updated gcc-armhf, gcc-aarch64 and gcc-x86_64 to r8 (#1456)
This commit is contained in:
parent
12f0b3ce80
commit
471391afb8
42 changed files with 22197 additions and 6 deletions
|
@ -0,0 +1,241 @@
|
|||
From b1d2df5090abc9202a7bf2d224ac90de22908d21 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 15 Jan 2018 11:27:24 +0000
|
||||
Subject: [PATCH 01/13] i386: Move struct ix86_frame to machine_function
|
||||
|
||||
Make ix86_frame available to i386 code generation. This is needed to
|
||||
backport the patch set of -mindirect-branch= to mitigate variant #2 of
|
||||
the speculative execution vulnerabilities on x86 processors identified
|
||||
by CVE-2017-5715, aka Spectre.
|
||||
|
||||
Backport from mainline
|
||||
2017-06-01 Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
|
||||
* config/i386/i386.c (ix86_frame): Moved to ...
|
||||
* config/i386/i386.h (ix86_frame): Here.
|
||||
(machine_function): Add frame.
|
||||
* config/i386/i386.c (ix86_compute_frame_layout): Repace the
|
||||
frame argument with &cfun->machine->frame.
|
||||
(ix86_can_use_return_insn_p): Don't pass &frame to
|
||||
ix86_compute_frame_layout. Copy frame from cfun->machine->frame.
|
||||
(ix86_can_eliminate): Likewise.
|
||||
(ix86_expand_prologue): Likewise.
|
||||
(ix86_expand_epilogue): Likewise.
|
||||
(ix86_expand_split_stack_prologue): Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 68 ++++++++++----------------------------------------
|
||||
gcc/config/i386/i386.h | 53 ++++++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 65 insertions(+), 56 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 8b5faac5129..a1ff32b648b 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -2434,53 +2434,6 @@ struct GTY(()) stack_local_entry {
|
||||
struct stack_local_entry *next;
|
||||
};
|
||||
|
||||
-/* Structure describing stack frame layout.
|
||||
- Stack grows downward:
|
||||
-
|
||||
- [arguments]
|
||||
- <- ARG_POINTER
|
||||
- saved pc
|
||||
-
|
||||
- saved static chain if ix86_static_chain_on_stack
|
||||
-
|
||||
- saved frame pointer if frame_pointer_needed
|
||||
- <- HARD_FRAME_POINTER
|
||||
- [saved regs]
|
||||
- <- regs_save_offset
|
||||
- [padding0]
|
||||
-
|
||||
- [saved SSE regs]
|
||||
- <- sse_regs_save_offset
|
||||
- [padding1] |
|
||||
- | <- FRAME_POINTER
|
||||
- [va_arg registers] |
|
||||
- |
|
||||
- [frame] |
|
||||
- |
|
||||
- [padding2] | = to_allocate
|
||||
- <- STACK_POINTER
|
||||
- */
|
||||
-struct ix86_frame
|
||||
-{
|
||||
- int nsseregs;
|
||||
- int nregs;
|
||||
- int va_arg_size;
|
||||
- int red_zone_size;
|
||||
- int outgoing_arguments_size;
|
||||
-
|
||||
- /* The offsets relative to ARG_POINTER. */
|
||||
- HOST_WIDE_INT frame_pointer_offset;
|
||||
- HOST_WIDE_INT hard_frame_pointer_offset;
|
||||
- HOST_WIDE_INT stack_pointer_offset;
|
||||
- HOST_WIDE_INT hfp_save_offset;
|
||||
- HOST_WIDE_INT reg_save_offset;
|
||||
- HOST_WIDE_INT sse_reg_save_offset;
|
||||
-
|
||||
- /* When save_regs_using_mov is set, emit prologue using
|
||||
- move instead of push instructions. */
|
||||
- bool save_regs_using_mov;
|
||||
-};
|
||||
-
|
||||
/* Which cpu are we scheduling for. */
|
||||
enum attr_cpu ix86_schedule;
|
||||
|
||||
@@ -2572,7 +2525,7 @@ static unsigned int ix86_function_arg_boundary (machine_mode,
|
||||
const_tree);
|
||||
static rtx ix86_static_chain (const_tree, bool);
|
||||
static int ix86_function_regparm (const_tree, const_tree);
|
||||
-static void ix86_compute_frame_layout (struct ix86_frame *);
|
||||
+static void ix86_compute_frame_layout (void);
|
||||
static bool ix86_expand_vector_init_one_nonzero (bool, machine_mode,
|
||||
rtx, rtx, int);
|
||||
static void ix86_add_new_builtins (HOST_WIDE_INT);
|
||||
@@ -10944,7 +10897,8 @@ ix86_can_use_return_insn_p (void)
|
||||
if (crtl->args.pops_args && crtl->args.size >= 32768)
|
||||
return 0;
|
||||
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = cfun->machine->frame;
|
||||
return (frame.stack_pointer_offset == UNITS_PER_WORD
|
||||
&& (frame.nregs + frame.nsseregs) == 0);
|
||||
}
|
||||
@@ -11355,8 +11309,8 @@ ix86_can_eliminate (const int from, const int to)
|
||||
HOST_WIDE_INT
|
||||
ix86_initial_elimination_offset (int from, int to)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ struct ix86_frame frame = cfun->machine->frame;
|
||||
|
||||
if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
|
||||
return frame.hard_frame_pointer_offset;
|
||||
@@ -11395,8 +11349,9 @@ ix86_builtin_setjmp_frame_value (void)
|
||||
/* Fill structure ix86_frame about frame of currently computed function. */
|
||||
|
||||
static void
|
||||
-ix86_compute_frame_layout (struct ix86_frame *frame)
|
||||
+ix86_compute_frame_layout (void)
|
||||
{
|
||||
+ struct ix86_frame *frame = &cfun->machine->frame;
|
||||
unsigned HOST_WIDE_INT stack_alignment_needed;
|
||||
HOST_WIDE_INT offset;
|
||||
unsigned HOST_WIDE_INT preferred_alignment;
|
||||
@@ -12702,7 +12657,8 @@ ix86_expand_prologue (void)
|
||||
m->fs.sp_offset = INCOMING_FRAME_SP_OFFSET;
|
||||
m->fs.sp_valid = true;
|
||||
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = m->frame;
|
||||
|
||||
if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
|
||||
{
|
||||
@@ -13379,7 +13335,8 @@ ix86_expand_epilogue (int style)
|
||||
bool using_drap;
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = m->frame;
|
||||
|
||||
m->fs.sp_valid = (!frame_pointer_needed
|
||||
|| (crtl->sp_is_unchanging
|
||||
@@ -13876,7 +13833,8 @@ ix86_expand_split_stack_prologue (void)
|
||||
gcc_assert (flag_split_stack && reload_completed);
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = cfun->machine->frame;
|
||||
allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
|
||||
|
||||
/* This is the label we will branch to if we have enough stack
|
||||
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
|
||||
index 8113f83c7fd..54144166172 100644
|
||||
--- a/gcc/config/i386/i386.h
|
||||
+++ b/gcc/config/i386/i386.h
|
||||
@@ -2427,9 +2427,56 @@ enum avx_u128_state
|
||||
|
||||
#define FASTCALL_PREFIX '@'
|
||||
|
||||
+#ifndef USED_FOR_TARGET
|
||||
+/* Structure describing stack frame layout.
|
||||
+ Stack grows downward:
|
||||
+
|
||||
+ [arguments]
|
||||
+ <- ARG_POINTER
|
||||
+ saved pc
|
||||
+
|
||||
+ saved static chain if ix86_static_chain_on_stack
|
||||
+
|
||||
+ saved frame pointer if frame_pointer_needed
|
||||
+ <- HARD_FRAME_POINTER
|
||||
+ [saved regs]
|
||||
+ <- regs_save_offset
|
||||
+ [padding0]
|
||||
+
|
||||
+ [saved SSE regs]
|
||||
+ <- sse_regs_save_offset
|
||||
+ [padding1] |
|
||||
+ | <- FRAME_POINTER
|
||||
+ [va_arg registers] |
|
||||
+ |
|
||||
+ [frame] |
|
||||
+ |
|
||||
+ [padding2] | = to_allocate
|
||||
+ <- STACK_POINTER
|
||||
+ */
|
||||
+struct GTY(()) ix86_frame
|
||||
+{
|
||||
+ int nsseregs;
|
||||
+ int nregs;
|
||||
+ int va_arg_size;
|
||||
+ int red_zone_size;
|
||||
+ int outgoing_arguments_size;
|
||||
+
|
||||
+ /* The offsets relative to ARG_POINTER. */
|
||||
+ HOST_WIDE_INT frame_pointer_offset;
|
||||
+ HOST_WIDE_INT hard_frame_pointer_offset;
|
||||
+ HOST_WIDE_INT stack_pointer_offset;
|
||||
+ HOST_WIDE_INT hfp_save_offset;
|
||||
+ HOST_WIDE_INT reg_save_offset;
|
||||
+ HOST_WIDE_INT sse_reg_save_offset;
|
||||
+
|
||||
+ /* When save_regs_using_mov is set, emit prologue using
|
||||
+ move instead of push instructions. */
|
||||
+ bool save_regs_using_mov;
|
||||
+};
|
||||
+
|
||||
/* Machine specific frame tracking during prologue/epilogue generation. */
|
||||
|
||||
-#ifndef USED_FOR_TARGET
|
||||
struct GTY(()) machine_frame_state
|
||||
{
|
||||
/* This pair tracks the currently active CFA as reg+offset. When reg
|
||||
@@ -2475,6 +2522,9 @@ struct GTY(()) machine_function {
|
||||
int varargs_fpr_size;
|
||||
int optimize_mode_switching[MAX_386_ENTITIES];
|
||||
|
||||
+ /* Cached initial frame layout for the current function. */
|
||||
+ struct ix86_frame frame;
|
||||
+
|
||||
/* Number of saved registers USE_FAST_PROLOGUE_EPILOGUE
|
||||
has been computed for. */
|
||||
int use_fast_prologue_epilogue_nregs;
|
||||
@@ -2554,6 +2604,7 @@ struct GTY(()) machine_function {
|
||||
#define ix86_current_function_calls_tls_descriptor \
|
||||
(ix86_tls_descriptor_calls_expanded_in_cfun && df_regs_ever_live_p (SP_REG))
|
||||
#define ix86_static_chain_on_stack (cfun->machine->static_chain_on_stack)
|
||||
+#define ix86_red_zone_size (cfun->machine->frame.red_zone_size)
|
||||
|
||||
/* Control behavior of x86_file_start. */
|
||||
#define X86_FILE_START_VERSION_DIRECTIVE false
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
From b1fc91cda7c15264116f3dde6944ead149123653 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 15 Jan 2018 11:28:44 +0000
|
||||
Subject: [PATCH 02/13] i386: Use reference of struct ix86_frame to avoid copy
|
||||
|
||||
When there is no need to make a copy of ix86_frame, we can use reference
|
||||
of struct ix86_frame to avoid copy.
|
||||
|
||||
Backport from mainline
|
||||
2017-11-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_can_use_return_insn_p): Use reference
|
||||
of struct ix86_frame.
|
||||
(ix86_initial_elimination_offset): Likewise.
|
||||
(ix86_expand_split_stack_prologue): Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 8 +++-----
|
||||
1 file changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index a1ff32b648b..13ebf107e90 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -10887,7 +10887,6 @@ symbolic_reference_mentioned_p (rtx op)
|
||||
bool
|
||||
ix86_can_use_return_insn_p (void)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
|
||||
if (! reload_completed || frame_pointer_needed)
|
||||
return 0;
|
||||
@@ -10898,7 +10897,7 @@ ix86_can_use_return_insn_p (void)
|
||||
return 0;
|
||||
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
return (frame.stack_pointer_offset == UNITS_PER_WORD
|
||||
&& (frame.nregs + frame.nsseregs) == 0);
|
||||
}
|
||||
@@ -11310,7 +11309,7 @@ HOST_WIDE_INT
|
||||
ix86_initial_elimination_offset (int from, int to)
|
||||
{
|
||||
ix86_compute_frame_layout ();
|
||||
- struct ix86_frame frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
|
||||
return frame.hard_frame_pointer_offset;
|
||||
@@ -13821,7 +13820,6 @@ static GTY(()) rtx split_stack_fn_large;
|
||||
void
|
||||
ix86_expand_split_stack_prologue (void)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
HOST_WIDE_INT allocate;
|
||||
unsigned HOST_WIDE_INT args_size;
|
||||
rtx_code_label *label;
|
||||
@@ -13834,7 +13832,7 @@ ix86_expand_split_stack_prologue (void)
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
|
||||
|
||||
/* This is the label we will branch to if we have enough stack
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
From 3e39c0a8053b3e960cf4c3aea3c814e7dc97cfd6 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Sat, 27 Jan 2018 13:10:24 +0000
|
||||
Subject: [PATCH 03/13] i386: Use const reference of struct ix86_frame to avoid
|
||||
copy
|
||||
|
||||
We can use const reference of struct ix86_frame to avoid making a local
|
||||
copy of ix86_frame. ix86_expand_epilogue makes a local copy of struct
|
||||
ix86_frame and uses the reg_save_offset field as a local variable. This
|
||||
patch uses a separate local variable for reg_save_offset.
|
||||
|
||||
Tested on x86-64 with ada.
|
||||
|
||||
Backport from mainline
|
||||
PR target/83905
|
||||
* config/i386/i386.c (ix86_expand_prologue): Use cost reference
|
||||
of struct ix86_frame.
|
||||
(ix86_expand_epilogue): Likewise. Add a local variable for
|
||||
the reg_save_offset field in struct ix86_frame.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257123 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 24 ++++++++++++------------
|
||||
1 file changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 13ebf107e90..6c98f7581e2 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -12633,7 +12633,6 @@ ix86_expand_prologue (void)
|
||||
{
|
||||
struct machine_function *m = cfun->machine;
|
||||
rtx insn, t;
|
||||
- struct ix86_frame frame;
|
||||
HOST_WIDE_INT allocate;
|
||||
bool int_registers_saved;
|
||||
bool sse_registers_saved;
|
||||
@@ -12657,7 +12656,7 @@ ix86_expand_prologue (void)
|
||||
m->fs.sp_valid = true;
|
||||
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = m->frame;
|
||||
+ const struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
|
||||
{
|
||||
@@ -13329,13 +13328,12 @@ ix86_expand_epilogue (int style)
|
||||
{
|
||||
struct machine_function *m = cfun->machine;
|
||||
struct machine_frame_state frame_state_save = m->fs;
|
||||
- struct ix86_frame frame;
|
||||
bool restore_regs_via_mov;
|
||||
bool using_drap;
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = m->frame;
|
||||
+ const struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
m->fs.sp_valid = (!frame_pointer_needed
|
||||
|| (crtl->sp_is_unchanging
|
||||
@@ -13377,11 +13375,13 @@ ix86_expand_epilogue (int style)
|
||||
+ UNITS_PER_WORD);
|
||||
}
|
||||
|
||||
+ HOST_WIDE_INT reg_save_offset = frame.reg_save_offset;
|
||||
+
|
||||
/* Special care must be taken for the normal return case of a function
|
||||
using eh_return: the eax and edx registers are marked as saved, but
|
||||
not restored along this path. Adjust the save location to match. */
|
||||
if (crtl->calls_eh_return && style != 2)
|
||||
- frame.reg_save_offset -= 2 * UNITS_PER_WORD;
|
||||
+ reg_save_offset -= 2 * UNITS_PER_WORD;
|
||||
|
||||
/* EH_RETURN requires the use of moves to function properly. */
|
||||
if (crtl->calls_eh_return)
|
||||
@@ -13397,11 +13397,11 @@ ix86_expand_epilogue (int style)
|
||||
else if (TARGET_EPILOGUE_USING_MOVE
|
||||
&& cfun->machine->use_fast_prologue_epilogue
|
||||
&& (frame.nregs > 1
|
||||
- || m->fs.sp_offset != frame.reg_save_offset))
|
||||
+ || m->fs.sp_offset != reg_save_offset))
|
||||
restore_regs_via_mov = true;
|
||||
else if (frame_pointer_needed
|
||||
&& !frame.nregs
|
||||
- && m->fs.sp_offset != frame.reg_save_offset)
|
||||
+ && m->fs.sp_offset != reg_save_offset)
|
||||
restore_regs_via_mov = true;
|
||||
else if (frame_pointer_needed
|
||||
&& TARGET_USE_LEAVE
|
||||
@@ -13439,7 +13439,7 @@ ix86_expand_epilogue (int style)
|
||||
rtx t;
|
||||
|
||||
if (frame.nregs)
|
||||
- ix86_emit_restore_regs_using_mov (frame.reg_save_offset, style == 2);
|
||||
+ ix86_emit_restore_regs_using_mov (reg_save_offset, style == 2);
|
||||
|
||||
/* eh_return epilogues need %ecx added to the stack pointer. */
|
||||
if (style == 2)
|
||||
@@ -13529,19 +13529,19 @@ ix86_expand_epilogue (int style)
|
||||
epilogues. */
|
||||
if (!m->fs.sp_valid
|
||||
|| (TARGET_SEH
|
||||
- && (m->fs.sp_offset - frame.reg_save_offset
|
||||
+ && (m->fs.sp_offset - reg_save_offset
|
||||
>= SEH_MAX_FRAME_SIZE)))
|
||||
{
|
||||
pro_epilogue_adjust_stack (stack_pointer_rtx, hard_frame_pointer_rtx,
|
||||
GEN_INT (m->fs.fp_offset
|
||||
- - frame.reg_save_offset),
|
||||
+ - reg_save_offset),
|
||||
style, false);
|
||||
}
|
||||
- else if (m->fs.sp_offset != frame.reg_save_offset)
|
||||
+ else if (m->fs.sp_offset != reg_save_offset)
|
||||
{
|
||||
pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
|
||||
GEN_INT (m->fs.sp_offset
|
||||
- - frame.reg_save_offset),
|
||||
+ - reg_save_offset),
|
||||
style,
|
||||
m->fs.cfa_reg == stack_pointer_rtx);
|
||||
}
|
||||
--
|
||||
2.16.3
|
||||
|
2149
cross/gcc-aarch64/0004-x86-Add-mindirect-branch.patch
Normal file
2149
cross/gcc-aarch64/0004-x86-Add-mindirect-branch.patch
Normal file
File diff suppressed because it is too large
Load diff
1565
cross/gcc-aarch64/0005-x86-Add-mfunction-return.patch
Normal file
1565
cross/gcc-aarch64/0005-x86-Add-mfunction-return.patch
Normal file
File diff suppressed because it is too large
Load diff
941
cross/gcc-aarch64/0006-x86-Add-mindirect-branch-register.patch
Normal file
941
cross/gcc-aarch64/0006-x86-Add-mindirect-branch-register.patch
Normal file
|
@ -0,0 +1,941 @@
|
|||
From 61bb7f0e152ce5be700a44007d036ea0de4b254d Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 6 Jan 2018 22:29:56 -0800
|
||||
Subject: [PATCH 06/13] x86: Add -mindirect-branch-register
|
||||
|
||||
Add -mindirect-branch-register to force indirect branch via register.
|
||||
This is implemented by disabling patterns of indirect branch via memory,
|
||||
similar to TARGET_X32.
|
||||
|
||||
-mindirect-branch= and -mfunction-return= tests are updated with
|
||||
-mno-indirect-branch-register to avoid false test failures when
|
||||
-mindirect-branch-register is added to RUNTESTFLAGS for "make check".
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Disallow memory operand for
|
||||
-mindirect-branch-register.
|
||||
(Bw): Likewise.
|
||||
* config/i386/predicates.md (indirect_branch_operand): Likewise.
|
||||
(GOT_memory_operand): Likewise.
|
||||
(call_insn_operand): Likewise.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
* config/i386/i386.md (indirect_jump): Call convert_memory_address
|
||||
for -mindirect-branch-register.
|
||||
(tablejump): Likewise.
|
||||
(*sibcall_memory): Likewise.
|
||||
(*sibcall_value_memory): Likewise.
|
||||
Disallow peepholes of indirect call and jump via memory for
|
||||
-mindirect-branch-register.
|
||||
(*call_pop): Replace m with Bw.
|
||||
(*call_value_pop): Likewise.
|
||||
(*sibcall_pop_memory): Replace m with Bs.
|
||||
* config/i386/i386.opt (mindirect-branch-register): New option.
|
||||
* doc/invoke.texi: Document -mindirect-branch-register option.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-1.c (dg-options): Add
|
||||
-mno-indirect-branch-register.
|
||||
* gcc.target/i386/indirect-thunk-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-7.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-10.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-11.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-12.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-13.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-14.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-15.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-9.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-register-1.c: New test.
|
||||
* gcc.target/i386/indirect-thunk-register-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-register-3.c: Likewise.
|
||||
|
||||
i386: Rename to ix86_indirect_branch_register
|
||||
|
||||
Rename the variable for -mindirect-branch-register to
|
||||
ix86_indirect_branch_register to match the command-line option name.
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Replace
|
||||
ix86_indirect_branch_thunk_register with
|
||||
ix86_indirect_branch_register.
|
||||
(Bw): Likewise.
|
||||
* config/i386/i386.md (indirect_jump): Likewise.
|
||||
(tablejump): Likewise.
|
||||
(*sibcall_memory): Likewise.
|
||||
(*sibcall_value_memory): Likewise.
|
||||
Peepholes of indirect call and jump via memory: Likewise.
|
||||
* config/i386/i386.opt: Likewise.
|
||||
* config/i386/predicates.md (indirect_branch_operand): Likewise.
|
||||
(GOT_memory_operand): Likewise.
|
||||
(call_insn_operand): Likewise.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
|
||||
x86: Rewrite ix86_indirect_branch_register logic
|
||||
|
||||
Rewrite ix86_indirect_branch_register logic with
|
||||
|
||||
(and (not (match_test "ix86_indirect_branch_register"))
|
||||
(original condition before r256662))
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/predicates.md (constant_call_address_operand):
|
||||
Rewrite ix86_indirect_branch_register logic.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
|
||||
Don't check ix86_indirect_branch_register for GOT operand
|
||||
|
||||
Since GOT_memory_operand and GOT32_symbol_operand are simple pattern
|
||||
matches, don't check ix86_indirect_branch_register here. If needed,
|
||||
-mindirect-branch= will convert indirect branch via GOT slot to a call
|
||||
and return thunk.
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Update
|
||||
ix86_indirect_branch_register check. Don't check
|
||||
ix86_indirect_branch_register with GOT_memory_operand.
|
||||
(Bw): Likewise.
|
||||
* config/i386/predicates.md (GOT_memory_operand): Don't check
|
||||
ix86_indirect_branch_register here.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
|
||||
i386: Rewrite indirect_branch_operand logic
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/predicates.md (indirect_branch_operand): Rewrite
|
||||
ix86_indirect_branch_register logic.
|
||||
---
|
||||
gcc/config/i386/constraints.md | 6 ++--
|
||||
gcc/config/i386/i386.md | 34 ++++++++++++++--------
|
||||
gcc/config/i386/i386.opt | 4 +++
|
||||
gcc/config/i386/predicates.md | 21 +++++++------
|
||||
gcc/doc/invoke.texi | 6 +++-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-1.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-2.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-3.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-4.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-5.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-6.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-register-1.c | 22 ++++++++++++++
|
||||
.../gcc.target/i386/indirect-thunk-register-2.c | 20 +++++++++++++
|
||||
.../gcc.target/i386/indirect-thunk-register-3.c | 19 ++++++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-10.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-11.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-12.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-13.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-14.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-15.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 2 +-
|
||||
47 files changed, 147 insertions(+), 63 deletions(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
|
||||
diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
|
||||
index 1a4c701ad13..9204c8e8487 100644
|
||||
--- a/gcc/config/i386/constraints.md
|
||||
+++ b/gcc/config/i386/constraints.md
|
||||
@@ -172,14 +172,16 @@
|
||||
|
||||
(define_constraint "Bs"
|
||||
"@internal Sibcall memory operand."
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (ior (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "sibcall_memory_operand"))
|
||||
(and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
(match_operand 0 "GOT_memory_operand"))))
|
||||
|
||||
(define_constraint "Bw"
|
||||
"@internal Call memory operand."
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (ior (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "memory_operand"))
|
||||
(and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
(match_operand 0 "GOT_memory_operand"))))
|
||||
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
||||
index 2da671e9f2d..05a88fff356 100644
|
||||
--- a/gcc/config/i386/i386.md
|
||||
+++ b/gcc/config/i386/i386.md
|
||||
@@ -11805,7 +11805,7 @@
|
||||
[(set (pc) (match_operand 0 "indirect_branch_operand"))]
|
||||
""
|
||||
{
|
||||
- if (TARGET_X32)
|
||||
+ if (TARGET_X32 || ix86_indirect_branch_register)
|
||||
operands[0] = convert_memory_address (word_mode, operands[0]);
|
||||
cfun->machine->has_local_indirect_jump = true;
|
||||
})
|
||||
@@ -11859,7 +11859,7 @@
|
||||
OPTAB_DIRECT);
|
||||
}
|
||||
|
||||
- if (TARGET_X32)
|
||||
+ if (TARGET_X32 || ix86_indirect_branch_register)
|
||||
operands[0] = convert_memory_address (word_mode, operands[0]);
|
||||
cfun->machine->has_local_indirect_jump = true;
|
||||
})
|
||||
@@ -12048,7 +12048,7 @@
|
||||
[(call (mem:QI (match_operand:W 0 "memory_operand" "m"))
|
||||
(match_operand 1))
|
||||
(unspec [(const_int 0)] UNSPEC_PEEPSIB)]
|
||||
- "!TARGET_X32"
|
||||
+ "!TARGET_X32 && !ix86_indirect_branch_register"
|
||||
"* return ix86_output_call_insn (insn, operands[0]);"
|
||||
[(set_attr "type" "call")])
|
||||
|
||||
@@ -12057,7 +12057,9 @@
|
||||
(match_operand:W 1 "memory_operand"))
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
|
||||
[(parallel [(call (mem:QI (match_dup 1))
|
||||
@@ -12070,7 +12072,9 @@
|
||||
(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
|
||||
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
@@ -12092,7 +12096,7 @@
|
||||
})
|
||||
|
||||
(define_insn "*call_pop"
|
||||
- [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lmBz"))
|
||||
+ [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lBwBz"))
|
||||
(match_operand 1))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
@@ -12112,7 +12116,7 @@
|
||||
[(set_attr "type" "call")])
|
||||
|
||||
(define_insn "*sibcall_pop_memory"
|
||||
- [(call (mem:QI (match_operand:SI 0 "memory_operand" "m"))
|
||||
+ [(call (mem:QI (match_operand:SI 0 "memory_operand" "Bs"))
|
||||
(match_operand 1))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
@@ -12166,7 +12170,9 @@
|
||||
[(set (match_operand:W 0 "register_operand")
|
||||
(match_operand:W 1 "memory_operand"))
|
||||
(set (pc) (match_dup 0))]
|
||||
- "!TARGET_X32 && peep2_reg_dead_p (2, operands[0])"
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && peep2_reg_dead_p (2, operands[0])"
|
||||
[(set (pc) (match_dup 1))])
|
||||
|
||||
;; Call subroutine, returning value in operand 0
|
||||
@@ -12244,7 +12250,7 @@
|
||||
(call (mem:QI (match_operand:W 1 "memory_operand" "m"))
|
||||
(match_operand 2)))
|
||||
(unspec [(const_int 0)] UNSPEC_PEEPSIB)]
|
||||
- "!TARGET_X32"
|
||||
+ "!TARGET_X32 && !ix86_indirect_branch_register"
|
||||
"* return ix86_output_call_insn (insn, operands[1]);"
|
||||
[(set_attr "type" "callv")])
|
||||
|
||||
@@ -12254,7 +12260,9 @@
|
||||
(set (match_operand 2)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3)))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
|
||||
[(parallel [(set (match_dup 2)
|
||||
@@ -12269,7 +12277,9 @@
|
||||
(set (match_operand 2)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3)))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
|
||||
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
@@ -12294,7 +12304,7 @@
|
||||
|
||||
(define_insn "*call_value_pop"
|
||||
[(set (match_operand 0)
|
||||
- (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lmBz"))
|
||||
+ (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lBwBz"))
|
||||
(match_operand 2)))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
|
||||
index ad5916fb643..a97f84f68f2 100644
|
||||
--- a/gcc/config/i386/i386.opt
|
||||
+++ b/gcc/config/i386/i386.opt
|
||||
@@ -921,3 +921,7 @@ Enum(indirect_branch) String(thunk-inline) Value(indirect_branch_thunk_inline)
|
||||
|
||||
EnumValue
|
||||
Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
|
||||
+
|
||||
+mindirect-branch-register
|
||||
+Target Report Var(ix86_indirect_branch_register) Init(0)
|
||||
+Force indirect call and jump via register.
|
||||
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
|
||||
index 93dda7bb0e7..d1f0a7dbf61 100644
|
||||
--- a/gcc/config/i386/predicates.md
|
||||
+++ b/gcc/config/i386/predicates.md
|
||||
@@ -593,7 +593,8 @@
|
||||
;; Test for a valid operand for indirect branch.
|
||||
(define_predicate "indirect_branch_operand"
|
||||
(ior (match_operand 0 "register_operand")
|
||||
- (and (not (match_test "TARGET_X32"))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "memory_operand"))))
|
||||
|
||||
;; Return true if OP is a memory operands that can be used in sibcalls.
|
||||
@@ -636,20 +637,22 @@
|
||||
(ior (match_test "constant_call_address_operand
|
||||
(op, mode == VOIDmode ? mode : Pmode)")
|
||||
(match_operand 0 "call_register_no_elim_operand")
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
- (match_operand 0 "memory_operand"))
|
||||
- (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
- (match_operand 0 "GOT_memory_operand")))))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (match_operand 0 "memory_operand"))
|
||||
+ (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
+ (match_operand 0 "GOT_memory_operand"))))))
|
||||
|
||||
;; Similarly, but for tail calls, in which we cannot allow memory references.
|
||||
(define_special_predicate "sibcall_insn_operand"
|
||||
(ior (match_test "constant_call_address_operand
|
||||
(op, mode == VOIDmode ? mode : Pmode)")
|
||||
(match_operand 0 "register_no_elim_operand")
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
- (match_operand 0 "sibcall_memory_operand"))
|
||||
- (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
- (match_operand 0 "GOT_memory_operand")))))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (match_operand 0 "sibcall_memory_operand"))
|
||||
+ (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
+ (match_operand 0 "GOT_memory_operand"))))))
|
||||
|
||||
;; Return true if OP is a 32-bit GOT symbol operand.
|
||||
(define_predicate "GOT32_symbol_operand"
|
||||
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
|
||||
index 337a761015a..94374661f2d 100644
|
||||
--- a/gcc/doc/invoke.texi
|
||||
+++ b/gcc/doc/invoke.texi
|
||||
@@ -1170,7 +1170,7 @@ See RS/6000 and PowerPC Options.
|
||||
-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
|
||||
-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
|
||||
-mmitigate-rop -mindirect-branch=@var{choice} @gol
|
||||
--mfunction-return=@var{choice}}
|
||||
+-mfunction-return=@var{choice} -mindirect-branch-register}
|
||||
|
||||
@emph{x86 Windows Options}
|
||||
@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
|
||||
@@ -24253,6 +24253,10 @@ object file. You can control this behavior for a specific function by
|
||||
using the function attribute @code{function_return}.
|
||||
@xref{Function Attributes}.
|
||||
|
||||
+@item -mindirect-branch-register
|
||||
+@opindex -mindirect-branch-register
|
||||
+Force indirect call and jump via register.
|
||||
+
|
||||
@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 e365ef5698a..60d09881a99 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 05a51ad9157..aac75163794 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 3c0d4c39f0b..9e24a385387 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -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 14d4ef6dd98..127b5d94523 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
typedef void (*dispatch_t)(long offset);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
index b4836c38d6c..fcaa18d10b7 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
index 1f06bd1af74..e4649283d10 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
|
||||
index bc6b47a636e..17c2d0faf88 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 2257be3affa..9194ccf3cbc 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 e9cfdc5879e..e51f261a612 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 f938db050f7..4aeec1833cd 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 4e58599692a..ac0e5999f63 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 b8d50249d8b..573cf1ef09e 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 455adabfe0e..b2b37fc6e2e 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 4595b841ec0..4a43e199931 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
|
||||
|
||||
void func0 (void);
|
||||
void func1 (void);
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
index 5e3e118e9bd..ac84ab623fa 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { ! x32 } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
|
||||
void (*dispatch) (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
index 2801aa4192e..ce655e8be1c 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { ! x32 } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
|
||||
void (*dispatch) (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
index 70b4fb36eea..d34485a0010 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
|
||||
void bar (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
index 3baf03ee77c..0e19830de4d 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
|
||||
void bar (char *);
|
||||
char buf[10];
|
||||
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 edeb264218c..579441f250e 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 1d00413a76a..c92e6f2b02d 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 06ebf1c9063..d9964c25bbd 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 1c8f9446636..d4dca4dc5fe 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
index 21740ac5b7f..5c07e02df6a 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
index a77c1f470b8..3eb440693a0 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
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 86e9fd1f1e4..aece9383697 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 3ecde878867..3aba5e8c81f 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 df32a19a2b5..0f0181d6672 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 9540996de01..2eef6f35a75 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 f3db6e2441f..e825a10f14c 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
index 0f687c3b027..c6d77e10352 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
index b27c6fc96a2..6454827b780 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
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 764a375fc37..c67066cf197 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
|
||||
void func0 (void);
|
||||
void func1 (void);
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
new file mode 100644
|
||||
index 00000000000..7d396a31953
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
@@ -0,0 +1,22 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */
|
||||
+/* { dg-final { scan-assembler {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk\n" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk_bnd\n" } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
new file mode 100644
|
||||
index 00000000000..e7e616bb271
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
@@ -0,0 +1,20 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */
|
||||
+/* { dg-final { scan-assembler {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
new file mode 100644
|
||||
index 00000000000..5320e923be2
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
@@ -0,0 +1,19 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not {\t(pause|pause|nop)} } } */
|
||||
+/* { 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-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
index 3a6727b5c54..e6fea84a4d9 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
index b8f68188313..e239ec4542f 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
index 01b0a02f80b..fa3181303c9 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
index 4b497b5f8af..fd5b41fdd3f 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
extern int foo (void) __attribute__ ((function_return("thunk")));
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
index 4ae4c44a3fd..d606373ead1 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
index 5b5bc765a7e..75e45e226b8 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
index fa24a1f7365..d1db41cc128 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
--
|
||||
2.16.3
|
||||
|
134
cross/gcc-aarch64/0007-x86-Add-V-register-operand-modifier.patch
Normal file
134
cross/gcc-aarch64/0007-x86-Add-V-register-operand-modifier.patch
Normal file
|
@ -0,0 +1,134 @@
|
|||
From 92308185917678406afee3c165ea5e71b53b3cc1 Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 6 Jan 2018 22:29:56 -0800
|
||||
Subject: [PATCH 07/13] x86: Add 'V' register operand modifier
|
||||
|
||||
Add 'V', a special modifier which prints the name of the full integer
|
||||
register without '%'. For
|
||||
|
||||
extern void (*func_p) (void);
|
||||
|
||||
void
|
||||
foo (void)
|
||||
{
|
||||
asm ("call __x86_indirect_thunk_%V0" : : "a" (func_p));
|
||||
}
|
||||
|
||||
it generates:
|
||||
|
||||
foo:
|
||||
movq func_p(%rip), %rax
|
||||
call __x86_indirect_thunk_rax
|
||||
ret
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (print_reg): Print the name of the full
|
||||
integer register without '%'.
|
||||
(ix86_print_operand): Handle 'V'.
|
||||
* doc/extend.texi: Document 'V' modifier.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-register-4.c: New test.
|
||||
---
|
||||
gcc/config/i386/i386.c | 13 ++++++++++++-
|
||||
gcc/doc/extend.texi | 3 +++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c | 13 +++++++++++++
|
||||
3 files changed, 28 insertions(+), 1 deletion(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 34e26a3a3c7..eeca7e5e490 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -16869,6 +16869,7 @@ put_condition_code (enum rtx_code code, machine_mode mode, bool reverse,
|
||||
If CODE is 'h', pretend the reg is the 'high' byte register.
|
||||
If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.
|
||||
If CODE is 'd', duplicate the operand for AVX instruction.
|
||||
+ If CODE is 'V', print naked full integer register name without %.
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -16879,7 +16880,7 @@ print_reg (rtx x, int code, FILE *file)
|
||||
unsigned int regno;
|
||||
bool duplicated;
|
||||
|
||||
- if (ASSEMBLER_DIALECT == ASM_ATT)
|
||||
+ if (ASSEMBLER_DIALECT == ASM_ATT && code != 'V')
|
||||
putc ('%', file);
|
||||
|
||||
if (x == pc_rtx)
|
||||
@@ -16922,6 +16923,14 @@ print_reg (rtx x, int code, FILE *file)
|
||||
&& regno != FPSR_REG
|
||||
&& regno != FPCR_REG);
|
||||
|
||||
+ if (code == 'V')
|
||||
+ {
|
||||
+ if (GENERAL_REGNO_P (regno))
|
||||
+ msize = GET_MODE_SIZE (word_mode);
|
||||
+ else
|
||||
+ error ("'V' modifier on non-integer register");
|
||||
+ }
|
||||
+
|
||||
duplicated = code == 'd' && TARGET_AVX;
|
||||
|
||||
switch (msize)
|
||||
@@ -17035,6 +17044,7 @@ print_reg (rtx x, int code, FILE *file)
|
||||
& -- print some in-use local-dynamic symbol name.
|
||||
H -- print a memory address offset by 8; used for sse high-parts
|
||||
Y -- print condition for XOP pcom* instruction.
|
||||
+ V -- print naked full integer register name without %.
|
||||
+ -- print a branch hint as 'cs' or 'ds' prefix
|
||||
; -- print a semicolon (after prefixes due to bug in older gas).
|
||||
~ -- print "i" if TARGET_AVX2, "f" otherwise.
|
||||
@@ -17259,6 +17269,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
|
||||
case 'X':
|
||||
case 'P':
|
||||
case 'p':
|
||||
+ case 'V':
|
||||
break;
|
||||
|
||||
case 's':
|
||||
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
|
||||
index 2cb6bd1ef3e..76ba1d4f913 100644
|
||||
--- a/gcc/doc/extend.texi
|
||||
+++ b/gcc/doc/extend.texi
|
||||
@@ -8511,6 +8511,9 @@ The table below shows the list of supported modifiers and their effects.
|
||||
@tab @code{2}
|
||||
@end multitable
|
||||
|
||||
+@code{V} is a special modifier which prints the name of the full integer
|
||||
+register without @code{%}.
|
||||
+
|
||||
@anchor{x86floatingpointasmoperands}
|
||||
@subsubsection x86 Floating-Point @code{asm} Operands
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
new file mode 100644
|
||||
index 00000000000..f0cd9b75be8
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
@@ -0,0 +1,13 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -fno-pic" } */
|
||||
+
|
||||
+extern void (*func_p) (void);
|
||||
+
|
||||
+void
|
||||
+foo (void)
|
||||
+{
|
||||
+ asm("call __x86_indirect_thunk_%V0" : : "a" (func_p));
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_eax" { target ia32 } } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_rax" { target { ! ia32 } } } } */
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,299 @@
|
|||
From 087b12213a5b4b8654c70320c671bb05c1b1b012 Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 13 Jan 2018 18:01:54 -0800
|
||||
Subject: [PATCH 08/13] x86: Disallow -mindirect-branch=/-mfunction-return=
|
||||
with -mcmodel=large
|
||||
|
||||
Since the thunk function may not be reachable in large code model,
|
||||
-mcmodel=large is incompatible with -mindirect-branch=thunk,
|
||||
-mindirect-branch=thunk-extern, -mfunction-return=thunk and
|
||||
-mfunction-return=thunk-extern. Issue an error when they are used with
|
||||
-mcmodel=large.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_set_indirect_branch_type): Disallow
|
||||
-mcmodel=large with -mindirect-branch=thunk,
|
||||
-mindirect-branch=thunk-extern, -mfunction-return=thunk and
|
||||
-mfunction-return=thunk-extern.
|
||||
* doc/invoke.texi: Document -mcmodel=large is incompatible with
|
||||
-mindirect-branch=thunk, -mindirect-branch=thunk-extern,
|
||||
-mfunction-return=thunk and -mfunction-return=thunk-extern.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-10.c: New test.
|
||||
* gcc.target/i386/indirect-thunk-8.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-9.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-10.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-11.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-9.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-17.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-18.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-19.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-20.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-21.c: Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 26 ++++++++++++++++++++++
|
||||
gcc/doc/invoke.texi | 11 +++++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-10.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-8.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-9.c | 7 ++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-10.c | 9 ++++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-11.c | 9 ++++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-9.c | 9 ++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-17.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-18.c | 8 +++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-19.c | 8 +++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-20.c | 9 ++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-21.c | 9 ++++++++
|
||||
13 files changed, 126 insertions(+)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index eeca7e5e490..9c038bee000 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -6389,6 +6389,19 @@ ix86_set_indirect_branch_type (tree fndecl)
|
||||
}
|
||||
else
|
||||
cfun->machine->indirect_branch_type = ix86_indirect_branch;
|
||||
+
|
||||
+ /* -mcmodel=large is not compatible with -mindirect-branch=thunk
|
||||
+ nor -mindirect-branch=thunk-extern. */
|
||||
+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
|
||||
+ && ((cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ || (cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk)))
|
||||
+ error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
|
||||
+ "compatible",
|
||||
+ ((cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ ? "thunk-extern" : "thunk"));
|
||||
}
|
||||
|
||||
if (cfun->machine->function_return_type == indirect_branch_unset)
|
||||
@@ -6414,6 +6427,19 @@ ix86_set_indirect_branch_type (tree fndecl)
|
||||
}
|
||||
else
|
||||
cfun->machine->function_return_type = ix86_function_return;
|
||||
+
|
||||
+ /* -mcmodel=large is not compatible with -mfunction-return=thunk
|
||||
+ nor -mfunction-return=thunk-extern. */
|
||||
+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
|
||||
+ && ((cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ || (cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk)))
|
||||
+ error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
|
||||
+ "compatible",
|
||||
+ ((cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ ? "thunk-extern" : "thunk"));
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
|
||||
index 94374661f2d..1dee495c86b 100644
|
||||
--- a/gcc/doc/invoke.texi
|
||||
+++ b/gcc/doc/invoke.texi
|
||||
@@ -24242,6 +24242,11 @@ 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}.
|
||||
|
||||
+Note that @option{-mcmodel=large} is incompatible with
|
||||
+@option{-mindirect-branch=thunk} nor
|
||||
+@option{-mindirect-branch=thunk-extern} since the thunk function may
|
||||
+not be reachable in large code model.
|
||||
+
|
||||
@item -mfunction-return=@var{choice}
|
||||
@opindex -mfunction-return
|
||||
Convert function return with @var{choice}. The default is @samp{keep},
|
||||
@@ -24253,6 +24258,12 @@ object file. You can control this behavior for a specific function by
|
||||
using the function attribute @code{function_return}.
|
||||
@xref{Function Attributes}.
|
||||
|
||||
+Note that @option{-mcmodel=large} is incompatible with
|
||||
+@option{-mfunction-return=thunk} nor
|
||||
+@option{-mfunction-return=thunk-extern} since the thunk function may
|
||||
+not be reachable in large code model.
|
||||
+
|
||||
+
|
||||
@item -mindirect-branch-register
|
||||
@opindex -mindirect-branch-register
|
||||
Force indirect call and jump via register.
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
new file mode 100644
|
||||
index 00000000000..a0674bd2363
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
new file mode 100644
|
||||
index 00000000000..7a80a8986e8
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
new file mode 100644
|
||||
index 00000000000..d4d45c5114d
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
new file mode 100644
|
||||
index 00000000000..3a2aeaddbc5
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk-extern")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
new file mode 100644
|
||||
index 00000000000..8e52f032b6c
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk-inline")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
new file mode 100644
|
||||
index 00000000000..bdaa4f6911b
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-17.c b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
new file mode 100644
|
||||
index 00000000000..0605e2c6542
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-18.c b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
new file mode 100644
|
||||
index 00000000000..307019dc242
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
@@ -0,0 +1,8 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-19.c b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
new file mode 100644
|
||||
index 00000000000..772617f4010
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
@@ -0,0 +1,8 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-20.c b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
new file mode 100644
|
||||
index 00000000000..1e9f9bd5a66
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk-extern")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-21.c b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
new file mode 100644
|
||||
index 00000000000..eea07f7abe1
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk-inline")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
From 07857bd9fb9ccab67a932ad9df3e53f3f0c2c617 Mon Sep 17 00:00:00 2001
|
||||
From: uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Thu, 25 Jan 2018 19:39:01 +0000
|
||||
Subject: [PATCH 09/13] Use INVALID_REGNUM in indirect thunk processing
|
||||
|
||||
Backport from mainline
|
||||
2018-01-17 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
* config/i386/i386.c (indirect_thunk_name): Declare regno
|
||||
as unsigned int. Compare regno with INVALID_REGNUM.
|
||||
(output_indirect_thunk): Ditto.
|
||||
(output_indirect_thunk_function): Ditto.
|
||||
(ix86_code_end): Declare regno as unsigned int. Use INVALID_REGNUM
|
||||
in the call to output_indirect_thunk_function.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257067 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 30 +++++++++++++++---------------
|
||||
1 file changed, 15 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 9c038bee000..40126579c22 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11087,16 +11087,16 @@ static int indirect_thunks_bnd_used;
|
||||
/* Fills in the label name that should be used for the indirect thunk. */
|
||||
|
||||
static void
|
||||
-indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
- bool ret_p)
|
||||
+indirect_thunk_name (char name[32], unsigned int regno,
|
||||
+ bool need_bnd_p, bool ret_p)
|
||||
{
|
||||
- if (regno >= 0 && ret_p)
|
||||
+ if (regno != INVALID_REGNUM && ret_p)
|
||||
gcc_unreachable ();
|
||||
|
||||
if (USE_HIDDEN_LINKONCE)
|
||||
{
|
||||
const char *bnd = need_bnd_p ? "_bnd" : "";
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
const char *reg_prefix;
|
||||
if (LEGACY_INT_REGNO_P (regno))
|
||||
@@ -11114,7 +11114,7 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
}
|
||||
else
|
||||
{
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
if (need_bnd_p)
|
||||
ASM_GENERATE_INTERNAL_LABEL (name, "LITBR", regno);
|
||||
@@ -11166,7 +11166,7 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
*/
|
||||
|
||||
static void
|
||||
-output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
+output_indirect_thunk (bool need_bnd_p, unsigned int regno)
|
||||
{
|
||||
char indirectlabel1[32];
|
||||
char indirectlabel2[32];
|
||||
@@ -11196,7 +11196,7 @@ output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
|
||||
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
|
||||
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
/* MOV. */
|
||||
rtx xops[2];
|
||||
@@ -11220,12 +11220,12 @@ output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
}
|
||||
|
||||
/* Output a funtion with a call and return thunk for indirect branch.
|
||||
- If BND_P is true, the BND prefix is needed. If REGNO != -1, the
|
||||
- function address is in REGNO. Otherwise, the function address is
|
||||
+ If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM,
|
||||
+ the function address is in REGNO. Otherwise, the function address is
|
||||
on the top of stack. */
|
||||
|
||||
static void
|
||||
-output_indirect_thunk_function (bool need_bnd_p, int regno)
|
||||
+output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
{
|
||||
char name[32];
|
||||
tree decl;
|
||||
@@ -11274,7 +11274,7 @@ output_indirect_thunk_function (bool need_bnd_p, int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
- if (regno < 0)
|
||||
+ if (regno == INVALID_REGNUM)
|
||||
{
|
||||
/* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
|
||||
char alias[32];
|
||||
@@ -11348,16 +11348,16 @@ static void
|
||||
ix86_code_end (void)
|
||||
{
|
||||
rtx xops[2];
|
||||
- int regno;
|
||||
+ unsigned int regno;
|
||||
|
||||
if (indirect_thunk_needed)
|
||||
- output_indirect_thunk_function (false, -1);
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM);
|
||||
if (indirect_thunk_bnd_needed)
|
||||
- output_indirect_thunk_function (true, -1);
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM);
|
||||
|
||||
for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
|
||||
{
|
||||
- int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
+ unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
if ((indirect_thunks_used & (1 << i)))
|
||||
output_indirect_thunk_function (false, regno);
|
||||
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 3815e98f0f46b6c4c41e6810bad987bd083691aa Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Fri, 2 Feb 2018 16:47:02 +0000
|
||||
Subject: [PATCH 10/13] i386: Pass INVALID_REGNUM as invalid register number
|
||||
|
||||
Backport from mainline
|
||||
* config/i386/i386.c (ix86_output_function_return): Pass
|
||||
INVALID_REGNUM, instead of -1, as invalid register number to
|
||||
indirect_thunk_name and output_indirect_thunk.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257341 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 40126579c22..66502ee6da6 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -28056,7 +28056,8 @@ ix86_output_function_return (bool long_p)
|
||||
{
|
||||
bool need_thunk = (cfun->machine->function_return_type
|
||||
== indirect_branch_thunk);
|
||||
- indirect_thunk_name (thunk_name, -1, need_bnd_p, true);
|
||||
+ indirect_thunk_name (thunk_name, INVALID_REGNUM, need_bnd_p,
|
||||
+ true);
|
||||
if (need_bnd_p)
|
||||
{
|
||||
indirect_thunk_bnd_needed |= need_thunk;
|
||||
@@ -28069,7 +28070,7 @@ ix86_output_function_return (bool long_p)
|
||||
}
|
||||
}
|
||||
else
|
||||
- output_indirect_thunk (need_bnd_p, -1);
|
||||
+ output_indirect_thunk (need_bnd_p, INVALID_REGNUM);
|
||||
|
||||
return "";
|
||||
}
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,456 @@
|
|||
From 771535dec733e4b85924f00a3a94c29683d614e5 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 26 Feb 2018 15:29:30 +0000
|
||||
Subject: [PATCH 11/13] i386: Update -mfunction-return= for return with pop
|
||||
|
||||
When -mfunction-return= is used, simple_return_pop_internal should pop
|
||||
return address into ECX register, adjust stack by bytes to pop from stack
|
||||
and jump to the return thunk via ECX register.
|
||||
|
||||
Revision 257992 removed the bool argument from ix86_output_indirect_jmp.
|
||||
Update comments to reflect it.
|
||||
|
||||
Tested on i686 and x86-64.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_output_indirect_jmp): Update comments.
|
||||
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/84530
|
||||
* config/i386/i386-protos.h (ix86_output_indirect_jmp): Remove
|
||||
the bool argument.
|
||||
(ix86_output_indirect_function_return): New prototype.
|
||||
(ix86_split_simple_return_pop_internal): Likewise.
|
||||
* config/i386/i386.c (indirect_return_via_cx): New.
|
||||
(indirect_return_via_cx_bnd): Likewise.
|
||||
(indirect_thunk_name): Handle return va CX_REG.
|
||||
(output_indirect_thunk_function): Create alias for
|
||||
__x86_return_thunk_[re]cx and __x86_return_thunk_[re]cx_bnd.
|
||||
(ix86_output_indirect_jmp): Remove the bool argument.
|
||||
(ix86_output_indirect_function_return): New function.
|
||||
(ix86_split_simple_return_pop_internal): Likewise.
|
||||
* config/i386/i386.md (*indirect_jump): Don't pass false
|
||||
to ix86_output_indirect_jmp.
|
||||
(*tablejump_1): Likewise.
|
||||
(simple_return_pop_internal): Change it to define_insn_and_split.
|
||||
Call ix86_split_simple_return_pop_internal to split it for
|
||||
-mfunction-return=.
|
||||
(simple_return_indirect_internal): Call
|
||||
ix86_output_indirect_function_return instead of
|
||||
ix86_output_indirect_jmp.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/84530
|
||||
* gcc.target/i386/ret-thunk-22.c: New test.
|
||||
* gcc.target/i386/ret-thunk-23.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-24.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-25.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-26.c: Likewise.
|
||||
---
|
||||
gcc/config/i386/i386-protos.h | 4 +-
|
||||
gcc/config/i386/i386.c | 127 +++++++++++++++++++++++----
|
||||
gcc/config/i386/i386.md | 11 ++-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-22.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-23.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-24.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-25.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-26.c | 40 +++++++++
|
||||
8 files changed, 222 insertions(+), 20 deletions(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
|
||||
index 620d70ef9f6..c7a0ccb58d3 100644
|
||||
--- a/gcc/config/i386/i386-protos.h
|
||||
+++ b/gcc/config/i386/i386-protos.h
|
||||
@@ -311,8 +311,10 @@ extern enum attr_cpu ix86_schedule;
|
||||
#endif
|
||||
|
||||
extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
|
||||
-extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
|
||||
+extern const char * ix86_output_indirect_jmp (rtx call_op);
|
||||
extern const char * ix86_output_function_return (bool long_p);
|
||||
+extern const char * ix86_output_indirect_function_return (rtx ret_op);
|
||||
+extern void ix86_split_simple_return_pop_internal (rtx);
|
||||
extern bool ix86_operands_ok_for_move_multiple (rtx *operands, bool load,
|
||||
enum machine_mode mode);
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 66502ee6da6..21c3c18bd3c 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11080,6 +11080,12 @@ static int indirect_thunks_used;
|
||||
by call and return thunks functions with the BND prefix. */
|
||||
static int indirect_thunks_bnd_used;
|
||||
|
||||
+/* True if return thunk function via CX is needed. */
|
||||
+static bool indirect_return_via_cx;
|
||||
+/* True if return thunk function via CX with the BND prefix is
|
||||
+ needed. */
|
||||
+static bool indirect_return_via_cx_bnd;
|
||||
+
|
||||
#ifndef INDIRECT_LABEL
|
||||
# define INDIRECT_LABEL "LIND"
|
||||
#endif
|
||||
@@ -11090,12 +11096,13 @@ static void
|
||||
indirect_thunk_name (char name[32], unsigned int regno,
|
||||
bool need_bnd_p, bool ret_p)
|
||||
{
|
||||
- if (regno != INVALID_REGNUM && ret_p)
|
||||
+ if (regno != INVALID_REGNUM && regno != CX_REG && ret_p)
|
||||
gcc_unreachable ();
|
||||
|
||||
if (USE_HIDDEN_LINKONCE)
|
||||
{
|
||||
const char *bnd = need_bnd_p ? "_bnd" : "";
|
||||
+ const char *ret = ret_p ? "return" : "indirect";
|
||||
if (regno != INVALID_REGNUM)
|
||||
{
|
||||
const char *reg_prefix;
|
||||
@@ -11103,14 +11110,11 @@ indirect_thunk_name (char name[32], unsigned int regno,
|
||||
reg_prefix = TARGET_64BIT ? "r" : "e";
|
||||
else
|
||||
reg_prefix = "";
|
||||
- sprintf (name, "__x86_indirect_thunk%s_%s%s",
|
||||
- bnd, reg_prefix, reg_names[regno]);
|
||||
+ sprintf (name, "__x86_%s_thunk%s_%s%s",
|
||||
+ ret, bnd, reg_prefix, reg_names[regno]);
|
||||
}
|
||||
else
|
||||
- {
|
||||
- const char *ret = ret_p ? "return" : "indirect";
|
||||
- sprintf (name, "__x86_%s_thunk%s", ret, bnd);
|
||||
- }
|
||||
+ sprintf (name, "__x86_%s_thunk%s", ret, bnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -11274,9 +11278,23 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
+ /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or
|
||||
+ __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */
|
||||
+ bool need_alias;
|
||||
if (regno == INVALID_REGNUM)
|
||||
+ need_alias = true;
|
||||
+ else if (regno == CX_REG)
|
||||
+ {
|
||||
+ if (need_bnd_p)
|
||||
+ need_alias = indirect_return_via_cx_bnd;
|
||||
+ else
|
||||
+ need_alias = indirect_return_via_cx;
|
||||
+ }
|
||||
+ else
|
||||
+ need_alias = false;
|
||||
+
|
||||
+ if (need_alias)
|
||||
{
|
||||
- /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
|
||||
char alias[32];
|
||||
|
||||
indirect_thunk_name (alias, regno, need_bnd_p, true);
|
||||
@@ -28019,18 +28037,17 @@ ix86_output_indirect_branch (rtx call_op, const char *xasm,
|
||||
else
|
||||
ix86_output_indirect_branch_via_push (call_op, xasm, sibcall_p);
|
||||
}
|
||||
-/* Output indirect jump. CALL_OP is the jump target. Jump is a
|
||||
- function return if RET_P is true. */
|
||||
+
|
||||
+/* Output indirect jump. CALL_OP is the jump target. */
|
||||
|
||||
const char *
|
||||
-ix86_output_indirect_jmp (rtx call_op, bool ret_p)
|
||||
+ix86_output_indirect_jmp (rtx call_op)
|
||||
{
|
||||
if (cfun->machine->indirect_branch_type != indirect_branch_keep)
|
||||
{
|
||||
- /* We can't have red-zone if this isn't a function return since
|
||||
- "call" in the indirect thunk pushes the return address onto
|
||||
- stack, destroying red-zone. */
|
||||
- if (!ret_p && ix86_red_zone_size != 0)
|
||||
+ /* We can't have red-zone since "call" in the indirect thunk
|
||||
+ pushes the return address onto stack, destroying red-zone. */
|
||||
+ if (ix86_red_zone_size != 0)
|
||||
gcc_unreachable ();
|
||||
|
||||
ix86_output_indirect_branch (call_op, "%0", true);
|
||||
@@ -28081,6 +28098,86 @@ ix86_output_function_return (bool long_p)
|
||||
return "rep%; ret";
|
||||
}
|
||||
|
||||
+/* Output indirect function return. RET_OP is the function return
|
||||
+ target. */
|
||||
+
|
||||
+const char *
|
||||
+ix86_output_indirect_function_return (rtx ret_op)
|
||||
+{
|
||||
+ if (cfun->machine->function_return_type != indirect_branch_keep)
|
||||
+ {
|
||||
+ char thunk_name[32];
|
||||
+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
|
||||
+ unsigned int regno = REGNO (ret_op);
|
||||
+ gcc_assert (regno == CX_REG);
|
||||
+
|
||||
+ 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, regno, need_bnd_p, true);
|
||||
+ if (need_bnd_p)
|
||||
+ {
|
||||
+ if (need_thunk)
|
||||
+ {
|
||||
+ indirect_return_via_cx_bnd = true;
|
||||
+ indirect_thunks_bnd_used |= 1 << CX_REG;
|
||||
+ }
|
||||
+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if (need_thunk)
|
||||
+ {
|
||||
+ indirect_return_via_cx = true;
|
||||
+ indirect_thunks_used |= 1 << CX_REG;
|
||||
+ }
|
||||
+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ output_indirect_thunk (need_bnd_p, regno);
|
||||
+
|
||||
+ return "";
|
||||
+ }
|
||||
+ else
|
||||
+ return "%!jmp\t%A0";
|
||||
+}
|
||||
+
|
||||
+/* Split simple return with popping POPC bytes from stack to indirect
|
||||
+ branch with stack adjustment . */
|
||||
+
|
||||
+void
|
||||
+ix86_split_simple_return_pop_internal (rtx popc)
|
||||
+{
|
||||
+ struct machine_function *m = cfun->machine;
|
||||
+ rtx ecx = gen_rtx_REG (SImode, CX_REG);
|
||||
+ rtx_insn *insn;
|
||||
+
|
||||
+ /* There is no "pascal" calling convention in any 64bit ABI. */
|
||||
+ gcc_assert (!TARGET_64BIT);
|
||||
+
|
||||
+ insn = emit_insn (gen_pop (ecx));
|
||||
+ m->fs.cfa_offset -= UNITS_PER_WORD;
|
||||
+ m->fs.sp_offset -= UNITS_PER_WORD;
|
||||
+
|
||||
+ rtx x = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD);
|
||||
+ x = gen_rtx_SET (stack_pointer_rtx, x);
|
||||
+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x);
|
||||
+ add_reg_note (insn, REG_CFA_REGISTER, gen_rtx_SET (ecx, pc_rtx));
|
||||
+ RTX_FRAME_RELATED_P (insn) = 1;
|
||||
+
|
||||
+ x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, popc);
|
||||
+ x = gen_rtx_SET (stack_pointer_rtx, x);
|
||||
+ insn = emit_insn (x);
|
||||
+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x);
|
||||
+ RTX_FRAME_RELATED_P (insn) = 1;
|
||||
+
|
||||
+ /* Now return address is in ECX. */
|
||||
+ emit_jump_insn (gen_simple_return_indirect_internal (ecx));
|
||||
+}
|
||||
+
|
||||
/* Output the assembly for a call instruction. */
|
||||
|
||||
const char *
|
||||
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
||||
index 05a88fff356..857466a6361 100644
|
||||
--- a/gcc/config/i386/i386.md
|
||||
+++ b/gcc/config/i386/i386.md
|
||||
@@ -11813,7 +11813,7 @@
|
||||
(define_insn "*indirect_jump"
|
||||
[(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))]
|
||||
""
|
||||
- "* return ix86_output_indirect_jmp (operands[0], false);"
|
||||
+ "* return ix86_output_indirect_jmp (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
@@ -11868,7 +11868,7 @@
|
||||
[(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))
|
||||
(use (label_ref (match_operand 1)))]
|
||||
""
|
||||
- "* return ix86_output_indirect_jmp (operands[0], false);"
|
||||
+ "* return ix86_output_indirect_jmp (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
@@ -12520,11 +12520,14 @@
|
||||
(set_attr "prefix_rep" "1")
|
||||
(set_attr "modrm" "0")])
|
||||
|
||||
-(define_insn "simple_return_pop_internal"
|
||||
+(define_insn_and_split "simple_return_pop_internal"
|
||||
[(simple_return)
|
||||
(use (match_operand:SI 0 "const_int_operand"))]
|
||||
"reload_completed"
|
||||
"%!ret\t%0"
|
||||
+ "&& cfun->machine->function_return_type != indirect_branch_keep"
|
||||
+ [(const_int 0)]
|
||||
+ "ix86_split_simple_return_pop_internal (operands[0]); DONE;"
|
||||
[(set_attr "length" "3")
|
||||
(set_attr "atom_unit" "jeu")
|
||||
(set_attr "length_immediate" "2")
|
||||
@@ -12535,7 +12538,7 @@
|
||||
[(simple_return)
|
||||
(use (match_operand:SI 0 "register_operand" "r"))]
|
||||
"reload_completed"
|
||||
- "* return ix86_output_indirect_jmp (operands[0], true);"
|
||||
+ "* return ix86_output_indirect_function_return (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-22.c b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
new file mode 100644
|
||||
index 00000000000..89e086de97b
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { 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-23.c b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
new file mode 100644
|
||||
index 00000000000..43f0ccaa854
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-extern" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler-not {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not {\tlfence} } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-24.c b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
new file mode 100644
|
||||
index 00000000000..8729e35147e
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { 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-25.c b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
new file mode 100644
|
||||
index 00000000000..f73553c9a9f
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_bnd_ecx" } } */
|
||||
+/* { 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-26.c b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
new file mode 100644
|
||||
index 00000000000..9144e988735
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
@@ -0,0 +1,40 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do run } */
|
||||
+/* { dg-options "-Os -mfunction-return=thunk" } */
|
||||
+
|
||||
+struct S { int i; };
|
||||
+__attribute__((const, noinline, noclone))
|
||||
+struct S foo (int x)
|
||||
+{
|
||||
+ struct S s;
|
||||
+ s.i = x;
|
||||
+ return s;
|
||||
+}
|
||||
+
|
||||
+int a[2048], b[2048], c[2048], d[2048];
|
||||
+struct S e[2048];
|
||||
+
|
||||
+__attribute__((noinline, noclone)) void
|
||||
+bar (void)
|
||||
+{
|
||||
+ int i;
|
||||
+ for (i = 0; i < 1024; i++)
|
||||
+ {
|
||||
+ e[i] = foo (i);
|
||||
+ a[i+2] = a[i] + a[i+1];
|
||||
+ b[10] = b[10] + i;
|
||||
+ c[i] = c[2047 - i];
|
||||
+ d[i] = d[i + 1];
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+main ()
|
||||
+{
|
||||
+ int i;
|
||||
+ bar ();
|
||||
+ for (i = 0; i < 1024; i++)
|
||||
+ if (e[i].i != i)
|
||||
+ __builtin_abort ();
|
||||
+ return 0;
|
||||
+}
|
||||
--
|
||||
2.16.3
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,225 @@
|
|||
From e7fbaebc8ff650df76f43e92cb9ca59d5174ebe7 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Thu, 15 Mar 2018 17:54:40 +0000
|
||||
Subject: [PATCH 13/13] i386: Don't generate alias for function return thunk
|
||||
|
||||
Function return thunks shouldn't be aliased to indirect branch thunks
|
||||
since indirect branch thunks are placed in COMDAT section and a COMDAT
|
||||
section with indirect branch may not have function return thunk. This
|
||||
patch generates function return thunks directly.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
PR target/84574
|
||||
* config/i386/i386.c (indirect_thunk_needed): Update comments.
|
||||
(indirect_thunk_bnd_needed): Likewise.
|
||||
(indirect_thunks_used): Likewise.
|
||||
(indirect_thunks_bnd_used): Likewise.
|
||||
(indirect_return_needed): New.
|
||||
(indirect_return_bnd_needed): Likewise.
|
||||
(output_indirect_thunk_function): Add a bool argument for
|
||||
function return.
|
||||
(output_indirect_thunk_function): Don't generate alias for
|
||||
function return thunk.
|
||||
(ix86_code_end): Call output_indirect_thunk_function to generate
|
||||
function return thunks.
|
||||
(ix86_output_function_return): Set indirect_return_bnd_needed
|
||||
and indirect_return_needed instead of indirect_thunk_bnd_needed
|
||||
and indirect_thunk_needed.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
PR target/84574
|
||||
* gcc.target/i386/ret-thunk-9.c: Expect __x86_return_thunk
|
||||
label instead of __x86_indirect_thunk label.
|
||||
---
|
||||
gcc/config/i386/i386.c | 92 ++++++++++-------------------
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 2 +-
|
||||
2 files changed, 33 insertions(+), 61 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 21c3c18bd3c..f4cd1c6f4e9 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11067,19 +11067,23 @@ ix86_setup_frame_addresses (void)
|
||||
labels in call and return thunks. */
|
||||
static int indirectlabelno;
|
||||
|
||||
-/* True if call and return thunk functions are needed. */
|
||||
+/* True if call thunk function is needed. */
|
||||
static bool indirect_thunk_needed = false;
|
||||
-/* True if call and return thunk functions with the BND prefix are
|
||||
- needed. */
|
||||
+/* True if call thunk function with the BND prefix is needed. */
|
||||
static bool indirect_thunk_bnd_needed = false;
|
||||
|
||||
/* Bit masks of integer registers, which contain branch target, used
|
||||
- by call and return thunks functions. */
|
||||
+ by call thunk functions. */
|
||||
static int indirect_thunks_used;
|
||||
/* Bit masks of integer registers, which contain branch target, used
|
||||
- by call and return thunks functions with the BND prefix. */
|
||||
+ by call thunk functions with the BND prefix. */
|
||||
static int indirect_thunks_bnd_used;
|
||||
|
||||
+/* True if return thunk function is needed. */
|
||||
+static bool indirect_return_needed = false;
|
||||
+/* True if return thunk function with the BND prefix is needed. */
|
||||
+static bool indirect_return_bnd_needed = false;
|
||||
+
|
||||
/* True if return thunk function via CX is needed. */
|
||||
static bool indirect_return_via_cx;
|
||||
/* True if return thunk function via CX with the BND prefix is
|
||||
@@ -11226,16 +11230,18 @@ output_indirect_thunk (bool need_bnd_p, unsigned int regno)
|
||||
/* Output a funtion with a call and return thunk for indirect branch.
|
||||
If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM,
|
||||
the function address is in REGNO. Otherwise, the function address is
|
||||
- on the top of stack. */
|
||||
+ on the top of stack. Thunk is used for function return if RET_P is
|
||||
+ true. */
|
||||
|
||||
static void
|
||||
-output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
+output_indirect_thunk_function (bool need_bnd_p, unsigned int regno,
|
||||
+ bool ret_p)
|
||||
{
|
||||
char name[32];
|
||||
tree decl;
|
||||
|
||||
/* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */
|
||||
- indirect_thunk_name (name, regno, need_bnd_p, false);
|
||||
+ indirect_thunk_name (name, regno, need_bnd_p, ret_p);
|
||||
decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
|
||||
get_identifier (name),
|
||||
build_function_type_list (void_type_node, NULL_TREE));
|
||||
@@ -11278,50 +11284,6 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
- /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or
|
||||
- __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */
|
||||
- bool need_alias;
|
||||
- if (regno == INVALID_REGNUM)
|
||||
- need_alias = true;
|
||||
- else if (regno == CX_REG)
|
||||
- {
|
||||
- if (need_bnd_p)
|
||||
- need_alias = indirect_return_via_cx_bnd;
|
||||
- else
|
||||
- need_alias = indirect_return_via_cx;
|
||||
- }
|
||||
- else
|
||||
- need_alias = false;
|
||||
-
|
||||
- if (need_alias)
|
||||
- {
|
||||
- char alias[32];
|
||||
-
|
||||
- indirect_thunk_name (alias, regno, need_bnd_p, 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);
|
||||
@@ -11368,19 +11330,29 @@ ix86_code_end (void)
|
||||
rtx xops[2];
|
||||
unsigned int regno;
|
||||
|
||||
+ if (indirect_return_needed)
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM, true);
|
||||
+ if (indirect_return_bnd_needed)
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM, true);
|
||||
+
|
||||
+ if (indirect_return_via_cx)
|
||||
+ output_indirect_thunk_function (false, CX_REG, true);
|
||||
+ if (indirect_return_via_cx_bnd)
|
||||
+ output_indirect_thunk_function (true, CX_REG, true);
|
||||
+
|
||||
if (indirect_thunk_needed)
|
||||
- output_indirect_thunk_function (false, INVALID_REGNUM);
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM, false);
|
||||
if (indirect_thunk_bnd_needed)
|
||||
- output_indirect_thunk_function (true, INVALID_REGNUM);
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM, false);
|
||||
|
||||
for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
|
||||
{
|
||||
unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
if ((indirect_thunks_used & (1 << i)))
|
||||
- output_indirect_thunk_function (false, regno);
|
||||
+ output_indirect_thunk_function (false, regno, false);
|
||||
|
||||
if ((indirect_thunks_bnd_used & (1 << i)))
|
||||
- output_indirect_thunk_function (true, regno);
|
||||
+ output_indirect_thunk_function (true, regno, false);
|
||||
}
|
||||
|
||||
for (regno = AX_REG; regno <= SP_REG; regno++)
|
||||
@@ -11389,10 +11361,10 @@ ix86_code_end (void)
|
||||
tree decl;
|
||||
|
||||
if ((indirect_thunks_used & (1 << regno)))
|
||||
- output_indirect_thunk_function (false, regno);
|
||||
+ output_indirect_thunk_function (false, regno, false);
|
||||
|
||||
if ((indirect_thunks_bnd_used & (1 << regno)))
|
||||
- output_indirect_thunk_function (true, regno);
|
||||
+ output_indirect_thunk_function (true, regno, false);
|
||||
|
||||
if (!(pic_labels_used & (1 << regno)))
|
||||
continue;
|
||||
@@ -28077,12 +28049,12 @@ ix86_output_function_return (bool long_p)
|
||||
true);
|
||||
if (need_bnd_p)
|
||||
{
|
||||
- indirect_thunk_bnd_needed |= need_thunk;
|
||||
+ indirect_return_bnd_needed |= need_thunk;
|
||||
fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
- indirect_thunk_needed |= need_thunk;
|
||||
+ indirect_return_needed |= need_thunk;
|
||||
fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
|
||||
}
|
||||
}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
index d2df8b874e0..eee230ca2f6 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
@@ -13,7 +13,7 @@ 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 "__x86_indirect_thunk:" } } */
|
||||
+/* { dg-final { scan-assembler "__x86_return_thunk:" } } */
|
||||
/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */
|
||||
/* { dg-final { scan-assembler-times {\tpause} 2 } } */
|
||||
/* { dg-final { scan-assembler-times {\tlfence} 2 } } */
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -54,7 +54,7 @@ pkgver=6.4.0
|
|||
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""
|
||||
|
||||
pkgname="gcc-aarch64"
|
||||
pkgrel=7
|
||||
pkgrel=8
|
||||
pkgdesc="Stage2 cross-compiler for aarch64"
|
||||
url="http://gcc.gnu.org"
|
||||
arch="armhf x86_64 x86"
|
||||
|
@ -236,6 +236,20 @@ source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgba
|
|||
fix-linux-header-use-in-libgcc.patch
|
||||
gcc-pure64-mips.patch
|
||||
ada-mips64.patch
|
||||
|
||||
0001-i386-Move-struct-ix86_frame-to-machine_function.patch
|
||||
0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch
|
||||
0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch
|
||||
0004-x86-Add-mindirect-branch.patch
|
||||
0005-x86-Add-mfunction-return.patch
|
||||
0006-x86-Add-mindirect-branch-register.patch
|
||||
0007-x86-Add-V-register-operand-modifier.patch
|
||||
0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch
|
||||
0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch
|
||||
0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch
|
||||
0011-i386-Update-mfunction-return-for-return-with-pop.patch
|
||||
0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
|
||||
0013-i386-Don-t-generate-alias-for-function-return-thunk.patch
|
||||
"
|
||||
|
||||
# we build out-of-tree
|
||||
|
@ -715,4 +729,17 @@ f4ef08454e28c8732db69115e4998ec153399e8d229dd27f923dbdcf57b68128a65640d026cc7f45
|
|||
01c71cd5881fc07ea3b9b980697e89b3ca0fe98502958ceafc3fca18b2604c844e2f457feab711baf8e03f00a5383b0e38aac7eb954034e306f43d4a37f165ed fix-rs6000-pie.patch
|
||||
34a818d5be67eb1f34e44a80b83c28a9b9c17d37fc9fac639f490d6bb5b53ebe3318140d09c236a17d7c98f5a7792ae3d6cefccda8067a5e942d6305b9d1f87c fix-linux-header-use-in-libgcc.patch
|
||||
86be3338cc9c33089608bc4c5e3b7918c4e500a345c338f361b18c342119a6ed69af5495d72950de7106d760f003528b46ad14795e805f8a3331e206dcb234e3 gcc-pure64-mips.patch
|
||||
508f3bca214d88531d739d761d07affc953689b1540905c73420b34c246e1e6b72588cf89f0e1462752633f8ddc88da8c0238be2a1b6e1c213829cecee7924cf ada-mips64.patch"
|
||||
508f3bca214d88531d739d761d07affc953689b1540905c73420b34c246e1e6b72588cf89f0e1462752633f8ddc88da8c0238be2a1b6e1c213829cecee7924cf ada-mips64.patch
|
||||
7912964bf3a985e9f870250d6e068f715582a4fb04270849d697a50e6aad0cf50df3d483ff80a0eb777d9940fd85526dd8d0b85da9bc71a5f2fbc07616263866 0001-i386-Move-struct-ix86_frame-to-machine_function.patch
|
||||
baa27a4b912d8e27cd65a556b09cf45289a0e00e86dae3925f2923d1f3752080e80d80e159c996ef4156c4df1dfc3069114810a846672170ef3ae461ae0ab7e1 0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch
|
||||
6701d15000bdd7c4c98a8fece8c814f5e4e73603eecf84fe4dc5ac10f79b3074afba7c2cc9e51d08b2abade1c34cb0c944c08ead7a85db94e97158c752fd1aac 0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch
|
||||
4e7e71ae57e232b29a6455ec977f60b47df1356eca0e85976ae2b4567c4c39541be9f10c30fe0085d69be5acdb61dff51d3e9d7af587c95d9cd2cb9ee307bd13 0004-x86-Add-mindirect-branch.patch
|
||||
07f7fdbd9b4876f36ed7715a35a369dbaf1016f46c42a8935930cfcc9ea250de2dbe8113f077373ccce3c39cd728f957b6c4c7c6a7da299f160a4109f0bbe88d 0005-x86-Add-mfunction-return.patch
|
||||
76ea947591e5241f8e6216ce337baaf1b5dfe3f02d8251f77a4acd70e2a5e7798e2867d70f452027f51a2e3baf1b5c94c3bffe9ef8e0a5ce24dc5d509adaf414 0006-x86-Add-mindirect-branch-register.patch
|
||||
1c33c5cd34efb44d4fa0ace56e3d27ec802a66e03b08a29ab6122cbc70edbbe22313a34114437a41e09e0a6869af3cea3fb18f5bcb49db2f8e3f155026fe15f0 0007-x86-Add-V-register-operand-modifier.patch
|
||||
5366e2cff0629304394bf35e9417c7faea6b6f3fc565d0410a17fdafcb2b30c9a218f8ca098274c09ca4c982ff5b178ad6df5bf464ec541aa086966915c7fe11 0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch
|
||||
67c738b1f6afb09b6f0469c9cb282ab4d51fc8dd8e39df1cfdff8831788c1022081fccd446a482623f649898733aeaaa205cba0aa41162cdbdc74e57de9bb6eb 0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch
|
||||
b7b59f3203bf53168de2170b91738cd456f6ae205b3fe5bf8aacbaa8cc5624dd09c941ad8f1071d1ab8ab4fb5f69068a4bc792c0486fdec1ee2eb9c83688bb78 0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch
|
||||
c53d4c5968865abb709ee8a9af9d57917d43ea3ba31ee8312f9e8f338e9b1b44babf5aa3414848da7267e5cf13a9261815eb9185dc153cbd41ee7ce5ea23d2d0 0011-i386-Update-mfunction-return-for-return-with-pop.patch
|
||||
955080ba3e42cfe2f604e5dcef46aa6fca7c899c7808398947af655ff3b7954e30807ef85246986a5cc7db36dbc870db151e9fa8d8bc967b89ea56efdf64614c 0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
|
||||
3aae3a9cef8e8afe5a5433db8d9f410e1a2882481af01bb1d33232f987dbb74d7780c32be70b868bb391b3601b65ed3a16d777afea946f5eeaff72aa1e7fa3a9 0013-i386-Don-t-generate-alias-for-function-return-thunk.patch"
|
||||
|
|
|
@ -0,0 +1,241 @@
|
|||
From b1d2df5090abc9202a7bf2d224ac90de22908d21 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 15 Jan 2018 11:27:24 +0000
|
||||
Subject: [PATCH 01/13] i386: Move struct ix86_frame to machine_function
|
||||
|
||||
Make ix86_frame available to i386 code generation. This is needed to
|
||||
backport the patch set of -mindirect-branch= to mitigate variant #2 of
|
||||
the speculative execution vulnerabilities on x86 processors identified
|
||||
by CVE-2017-5715, aka Spectre.
|
||||
|
||||
Backport from mainline
|
||||
2017-06-01 Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
|
||||
* config/i386/i386.c (ix86_frame): Moved to ...
|
||||
* config/i386/i386.h (ix86_frame): Here.
|
||||
(machine_function): Add frame.
|
||||
* config/i386/i386.c (ix86_compute_frame_layout): Repace the
|
||||
frame argument with &cfun->machine->frame.
|
||||
(ix86_can_use_return_insn_p): Don't pass &frame to
|
||||
ix86_compute_frame_layout. Copy frame from cfun->machine->frame.
|
||||
(ix86_can_eliminate): Likewise.
|
||||
(ix86_expand_prologue): Likewise.
|
||||
(ix86_expand_epilogue): Likewise.
|
||||
(ix86_expand_split_stack_prologue): Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 68 ++++++++++----------------------------------------
|
||||
gcc/config/i386/i386.h | 53 ++++++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 65 insertions(+), 56 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 8b5faac5129..a1ff32b648b 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -2434,53 +2434,6 @@ struct GTY(()) stack_local_entry {
|
||||
struct stack_local_entry *next;
|
||||
};
|
||||
|
||||
-/* Structure describing stack frame layout.
|
||||
- Stack grows downward:
|
||||
-
|
||||
- [arguments]
|
||||
- <- ARG_POINTER
|
||||
- saved pc
|
||||
-
|
||||
- saved static chain if ix86_static_chain_on_stack
|
||||
-
|
||||
- saved frame pointer if frame_pointer_needed
|
||||
- <- HARD_FRAME_POINTER
|
||||
- [saved regs]
|
||||
- <- regs_save_offset
|
||||
- [padding0]
|
||||
-
|
||||
- [saved SSE regs]
|
||||
- <- sse_regs_save_offset
|
||||
- [padding1] |
|
||||
- | <- FRAME_POINTER
|
||||
- [va_arg registers] |
|
||||
- |
|
||||
- [frame] |
|
||||
- |
|
||||
- [padding2] | = to_allocate
|
||||
- <- STACK_POINTER
|
||||
- */
|
||||
-struct ix86_frame
|
||||
-{
|
||||
- int nsseregs;
|
||||
- int nregs;
|
||||
- int va_arg_size;
|
||||
- int red_zone_size;
|
||||
- int outgoing_arguments_size;
|
||||
-
|
||||
- /* The offsets relative to ARG_POINTER. */
|
||||
- HOST_WIDE_INT frame_pointer_offset;
|
||||
- HOST_WIDE_INT hard_frame_pointer_offset;
|
||||
- HOST_WIDE_INT stack_pointer_offset;
|
||||
- HOST_WIDE_INT hfp_save_offset;
|
||||
- HOST_WIDE_INT reg_save_offset;
|
||||
- HOST_WIDE_INT sse_reg_save_offset;
|
||||
-
|
||||
- /* When save_regs_using_mov is set, emit prologue using
|
||||
- move instead of push instructions. */
|
||||
- bool save_regs_using_mov;
|
||||
-};
|
||||
-
|
||||
/* Which cpu are we scheduling for. */
|
||||
enum attr_cpu ix86_schedule;
|
||||
|
||||
@@ -2572,7 +2525,7 @@ static unsigned int ix86_function_arg_boundary (machine_mode,
|
||||
const_tree);
|
||||
static rtx ix86_static_chain (const_tree, bool);
|
||||
static int ix86_function_regparm (const_tree, const_tree);
|
||||
-static void ix86_compute_frame_layout (struct ix86_frame *);
|
||||
+static void ix86_compute_frame_layout (void);
|
||||
static bool ix86_expand_vector_init_one_nonzero (bool, machine_mode,
|
||||
rtx, rtx, int);
|
||||
static void ix86_add_new_builtins (HOST_WIDE_INT);
|
||||
@@ -10944,7 +10897,8 @@ ix86_can_use_return_insn_p (void)
|
||||
if (crtl->args.pops_args && crtl->args.size >= 32768)
|
||||
return 0;
|
||||
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = cfun->machine->frame;
|
||||
return (frame.stack_pointer_offset == UNITS_PER_WORD
|
||||
&& (frame.nregs + frame.nsseregs) == 0);
|
||||
}
|
||||
@@ -11355,8 +11309,8 @@ ix86_can_eliminate (const int from, const int to)
|
||||
HOST_WIDE_INT
|
||||
ix86_initial_elimination_offset (int from, int to)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ struct ix86_frame frame = cfun->machine->frame;
|
||||
|
||||
if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
|
||||
return frame.hard_frame_pointer_offset;
|
||||
@@ -11395,8 +11349,9 @@ ix86_builtin_setjmp_frame_value (void)
|
||||
/* Fill structure ix86_frame about frame of currently computed function. */
|
||||
|
||||
static void
|
||||
-ix86_compute_frame_layout (struct ix86_frame *frame)
|
||||
+ix86_compute_frame_layout (void)
|
||||
{
|
||||
+ struct ix86_frame *frame = &cfun->machine->frame;
|
||||
unsigned HOST_WIDE_INT stack_alignment_needed;
|
||||
HOST_WIDE_INT offset;
|
||||
unsigned HOST_WIDE_INT preferred_alignment;
|
||||
@@ -12702,7 +12657,8 @@ ix86_expand_prologue (void)
|
||||
m->fs.sp_offset = INCOMING_FRAME_SP_OFFSET;
|
||||
m->fs.sp_valid = true;
|
||||
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = m->frame;
|
||||
|
||||
if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
|
||||
{
|
||||
@@ -13379,7 +13335,8 @@ ix86_expand_epilogue (int style)
|
||||
bool using_drap;
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = m->frame;
|
||||
|
||||
m->fs.sp_valid = (!frame_pointer_needed
|
||||
|| (crtl->sp_is_unchanging
|
||||
@@ -13876,7 +13833,8 @@ ix86_expand_split_stack_prologue (void)
|
||||
gcc_assert (flag_split_stack && reload_completed);
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = cfun->machine->frame;
|
||||
allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
|
||||
|
||||
/* This is the label we will branch to if we have enough stack
|
||||
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
|
||||
index 8113f83c7fd..54144166172 100644
|
||||
--- a/gcc/config/i386/i386.h
|
||||
+++ b/gcc/config/i386/i386.h
|
||||
@@ -2427,9 +2427,56 @@ enum avx_u128_state
|
||||
|
||||
#define FASTCALL_PREFIX '@'
|
||||
|
||||
+#ifndef USED_FOR_TARGET
|
||||
+/* Structure describing stack frame layout.
|
||||
+ Stack grows downward:
|
||||
+
|
||||
+ [arguments]
|
||||
+ <- ARG_POINTER
|
||||
+ saved pc
|
||||
+
|
||||
+ saved static chain if ix86_static_chain_on_stack
|
||||
+
|
||||
+ saved frame pointer if frame_pointer_needed
|
||||
+ <- HARD_FRAME_POINTER
|
||||
+ [saved regs]
|
||||
+ <- regs_save_offset
|
||||
+ [padding0]
|
||||
+
|
||||
+ [saved SSE regs]
|
||||
+ <- sse_regs_save_offset
|
||||
+ [padding1] |
|
||||
+ | <- FRAME_POINTER
|
||||
+ [va_arg registers] |
|
||||
+ |
|
||||
+ [frame] |
|
||||
+ |
|
||||
+ [padding2] | = to_allocate
|
||||
+ <- STACK_POINTER
|
||||
+ */
|
||||
+struct GTY(()) ix86_frame
|
||||
+{
|
||||
+ int nsseregs;
|
||||
+ int nregs;
|
||||
+ int va_arg_size;
|
||||
+ int red_zone_size;
|
||||
+ int outgoing_arguments_size;
|
||||
+
|
||||
+ /* The offsets relative to ARG_POINTER. */
|
||||
+ HOST_WIDE_INT frame_pointer_offset;
|
||||
+ HOST_WIDE_INT hard_frame_pointer_offset;
|
||||
+ HOST_WIDE_INT stack_pointer_offset;
|
||||
+ HOST_WIDE_INT hfp_save_offset;
|
||||
+ HOST_WIDE_INT reg_save_offset;
|
||||
+ HOST_WIDE_INT sse_reg_save_offset;
|
||||
+
|
||||
+ /* When save_regs_using_mov is set, emit prologue using
|
||||
+ move instead of push instructions. */
|
||||
+ bool save_regs_using_mov;
|
||||
+};
|
||||
+
|
||||
/* Machine specific frame tracking during prologue/epilogue generation. */
|
||||
|
||||
-#ifndef USED_FOR_TARGET
|
||||
struct GTY(()) machine_frame_state
|
||||
{
|
||||
/* This pair tracks the currently active CFA as reg+offset. When reg
|
||||
@@ -2475,6 +2522,9 @@ struct GTY(()) machine_function {
|
||||
int varargs_fpr_size;
|
||||
int optimize_mode_switching[MAX_386_ENTITIES];
|
||||
|
||||
+ /* Cached initial frame layout for the current function. */
|
||||
+ struct ix86_frame frame;
|
||||
+
|
||||
/* Number of saved registers USE_FAST_PROLOGUE_EPILOGUE
|
||||
has been computed for. */
|
||||
int use_fast_prologue_epilogue_nregs;
|
||||
@@ -2554,6 +2604,7 @@ struct GTY(()) machine_function {
|
||||
#define ix86_current_function_calls_tls_descriptor \
|
||||
(ix86_tls_descriptor_calls_expanded_in_cfun && df_regs_ever_live_p (SP_REG))
|
||||
#define ix86_static_chain_on_stack (cfun->machine->static_chain_on_stack)
|
||||
+#define ix86_red_zone_size (cfun->machine->frame.red_zone_size)
|
||||
|
||||
/* Control behavior of x86_file_start. */
|
||||
#define X86_FILE_START_VERSION_DIRECTIVE false
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
From b1fc91cda7c15264116f3dde6944ead149123653 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 15 Jan 2018 11:28:44 +0000
|
||||
Subject: [PATCH 02/13] i386: Use reference of struct ix86_frame to avoid copy
|
||||
|
||||
When there is no need to make a copy of ix86_frame, we can use reference
|
||||
of struct ix86_frame to avoid copy.
|
||||
|
||||
Backport from mainline
|
||||
2017-11-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_can_use_return_insn_p): Use reference
|
||||
of struct ix86_frame.
|
||||
(ix86_initial_elimination_offset): Likewise.
|
||||
(ix86_expand_split_stack_prologue): Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 8 +++-----
|
||||
1 file changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index a1ff32b648b..13ebf107e90 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -10887,7 +10887,6 @@ symbolic_reference_mentioned_p (rtx op)
|
||||
bool
|
||||
ix86_can_use_return_insn_p (void)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
|
||||
if (! reload_completed || frame_pointer_needed)
|
||||
return 0;
|
||||
@@ -10898,7 +10897,7 @@ ix86_can_use_return_insn_p (void)
|
||||
return 0;
|
||||
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
return (frame.stack_pointer_offset == UNITS_PER_WORD
|
||||
&& (frame.nregs + frame.nsseregs) == 0);
|
||||
}
|
||||
@@ -11310,7 +11309,7 @@ HOST_WIDE_INT
|
||||
ix86_initial_elimination_offset (int from, int to)
|
||||
{
|
||||
ix86_compute_frame_layout ();
|
||||
- struct ix86_frame frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
|
||||
return frame.hard_frame_pointer_offset;
|
||||
@@ -13821,7 +13820,6 @@ static GTY(()) rtx split_stack_fn_large;
|
||||
void
|
||||
ix86_expand_split_stack_prologue (void)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
HOST_WIDE_INT allocate;
|
||||
unsigned HOST_WIDE_INT args_size;
|
||||
rtx_code_label *label;
|
||||
@@ -13834,7 +13832,7 @@ ix86_expand_split_stack_prologue (void)
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
|
||||
|
||||
/* This is the label we will branch to if we have enough stack
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
From 3e39c0a8053b3e960cf4c3aea3c814e7dc97cfd6 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Sat, 27 Jan 2018 13:10:24 +0000
|
||||
Subject: [PATCH 03/13] i386: Use const reference of struct ix86_frame to avoid
|
||||
copy
|
||||
|
||||
We can use const reference of struct ix86_frame to avoid making a local
|
||||
copy of ix86_frame. ix86_expand_epilogue makes a local copy of struct
|
||||
ix86_frame and uses the reg_save_offset field as a local variable. This
|
||||
patch uses a separate local variable for reg_save_offset.
|
||||
|
||||
Tested on x86-64 with ada.
|
||||
|
||||
Backport from mainline
|
||||
PR target/83905
|
||||
* config/i386/i386.c (ix86_expand_prologue): Use cost reference
|
||||
of struct ix86_frame.
|
||||
(ix86_expand_epilogue): Likewise. Add a local variable for
|
||||
the reg_save_offset field in struct ix86_frame.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257123 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 24 ++++++++++++------------
|
||||
1 file changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 13ebf107e90..6c98f7581e2 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -12633,7 +12633,6 @@ ix86_expand_prologue (void)
|
||||
{
|
||||
struct machine_function *m = cfun->machine;
|
||||
rtx insn, t;
|
||||
- struct ix86_frame frame;
|
||||
HOST_WIDE_INT allocate;
|
||||
bool int_registers_saved;
|
||||
bool sse_registers_saved;
|
||||
@@ -12657,7 +12656,7 @@ ix86_expand_prologue (void)
|
||||
m->fs.sp_valid = true;
|
||||
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = m->frame;
|
||||
+ const struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
|
||||
{
|
||||
@@ -13329,13 +13328,12 @@ ix86_expand_epilogue (int style)
|
||||
{
|
||||
struct machine_function *m = cfun->machine;
|
||||
struct machine_frame_state frame_state_save = m->fs;
|
||||
- struct ix86_frame frame;
|
||||
bool restore_regs_via_mov;
|
||||
bool using_drap;
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = m->frame;
|
||||
+ const struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
m->fs.sp_valid = (!frame_pointer_needed
|
||||
|| (crtl->sp_is_unchanging
|
||||
@@ -13377,11 +13375,13 @@ ix86_expand_epilogue (int style)
|
||||
+ UNITS_PER_WORD);
|
||||
}
|
||||
|
||||
+ HOST_WIDE_INT reg_save_offset = frame.reg_save_offset;
|
||||
+
|
||||
/* Special care must be taken for the normal return case of a function
|
||||
using eh_return: the eax and edx registers are marked as saved, but
|
||||
not restored along this path. Adjust the save location to match. */
|
||||
if (crtl->calls_eh_return && style != 2)
|
||||
- frame.reg_save_offset -= 2 * UNITS_PER_WORD;
|
||||
+ reg_save_offset -= 2 * UNITS_PER_WORD;
|
||||
|
||||
/* EH_RETURN requires the use of moves to function properly. */
|
||||
if (crtl->calls_eh_return)
|
||||
@@ -13397,11 +13397,11 @@ ix86_expand_epilogue (int style)
|
||||
else if (TARGET_EPILOGUE_USING_MOVE
|
||||
&& cfun->machine->use_fast_prologue_epilogue
|
||||
&& (frame.nregs > 1
|
||||
- || m->fs.sp_offset != frame.reg_save_offset))
|
||||
+ || m->fs.sp_offset != reg_save_offset))
|
||||
restore_regs_via_mov = true;
|
||||
else if (frame_pointer_needed
|
||||
&& !frame.nregs
|
||||
- && m->fs.sp_offset != frame.reg_save_offset)
|
||||
+ && m->fs.sp_offset != reg_save_offset)
|
||||
restore_regs_via_mov = true;
|
||||
else if (frame_pointer_needed
|
||||
&& TARGET_USE_LEAVE
|
||||
@@ -13439,7 +13439,7 @@ ix86_expand_epilogue (int style)
|
||||
rtx t;
|
||||
|
||||
if (frame.nregs)
|
||||
- ix86_emit_restore_regs_using_mov (frame.reg_save_offset, style == 2);
|
||||
+ ix86_emit_restore_regs_using_mov (reg_save_offset, style == 2);
|
||||
|
||||
/* eh_return epilogues need %ecx added to the stack pointer. */
|
||||
if (style == 2)
|
||||
@@ -13529,19 +13529,19 @@ ix86_expand_epilogue (int style)
|
||||
epilogues. */
|
||||
if (!m->fs.sp_valid
|
||||
|| (TARGET_SEH
|
||||
- && (m->fs.sp_offset - frame.reg_save_offset
|
||||
+ && (m->fs.sp_offset - reg_save_offset
|
||||
>= SEH_MAX_FRAME_SIZE)))
|
||||
{
|
||||
pro_epilogue_adjust_stack (stack_pointer_rtx, hard_frame_pointer_rtx,
|
||||
GEN_INT (m->fs.fp_offset
|
||||
- - frame.reg_save_offset),
|
||||
+ - reg_save_offset),
|
||||
style, false);
|
||||
}
|
||||
- else if (m->fs.sp_offset != frame.reg_save_offset)
|
||||
+ else if (m->fs.sp_offset != reg_save_offset)
|
||||
{
|
||||
pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
|
||||
GEN_INT (m->fs.sp_offset
|
||||
- - frame.reg_save_offset),
|
||||
+ - reg_save_offset),
|
||||
style,
|
||||
m->fs.cfa_reg == stack_pointer_rtx);
|
||||
}
|
||||
--
|
||||
2.16.3
|
||||
|
2149
cross/gcc-armhf/0004-x86-Add-mindirect-branch.patch
Normal file
2149
cross/gcc-armhf/0004-x86-Add-mindirect-branch.patch
Normal file
File diff suppressed because it is too large
Load diff
1565
cross/gcc-armhf/0005-x86-Add-mfunction-return.patch
Normal file
1565
cross/gcc-armhf/0005-x86-Add-mfunction-return.patch
Normal file
File diff suppressed because it is too large
Load diff
941
cross/gcc-armhf/0006-x86-Add-mindirect-branch-register.patch
Normal file
941
cross/gcc-armhf/0006-x86-Add-mindirect-branch-register.patch
Normal file
|
@ -0,0 +1,941 @@
|
|||
From 61bb7f0e152ce5be700a44007d036ea0de4b254d Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 6 Jan 2018 22:29:56 -0800
|
||||
Subject: [PATCH 06/13] x86: Add -mindirect-branch-register
|
||||
|
||||
Add -mindirect-branch-register to force indirect branch via register.
|
||||
This is implemented by disabling patterns of indirect branch via memory,
|
||||
similar to TARGET_X32.
|
||||
|
||||
-mindirect-branch= and -mfunction-return= tests are updated with
|
||||
-mno-indirect-branch-register to avoid false test failures when
|
||||
-mindirect-branch-register is added to RUNTESTFLAGS for "make check".
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Disallow memory operand for
|
||||
-mindirect-branch-register.
|
||||
(Bw): Likewise.
|
||||
* config/i386/predicates.md (indirect_branch_operand): Likewise.
|
||||
(GOT_memory_operand): Likewise.
|
||||
(call_insn_operand): Likewise.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
* config/i386/i386.md (indirect_jump): Call convert_memory_address
|
||||
for -mindirect-branch-register.
|
||||
(tablejump): Likewise.
|
||||
(*sibcall_memory): Likewise.
|
||||
(*sibcall_value_memory): Likewise.
|
||||
Disallow peepholes of indirect call and jump via memory for
|
||||
-mindirect-branch-register.
|
||||
(*call_pop): Replace m with Bw.
|
||||
(*call_value_pop): Likewise.
|
||||
(*sibcall_pop_memory): Replace m with Bs.
|
||||
* config/i386/i386.opt (mindirect-branch-register): New option.
|
||||
* doc/invoke.texi: Document -mindirect-branch-register option.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-1.c (dg-options): Add
|
||||
-mno-indirect-branch-register.
|
||||
* gcc.target/i386/indirect-thunk-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-7.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-10.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-11.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-12.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-13.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-14.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-15.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-9.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-register-1.c: New test.
|
||||
* gcc.target/i386/indirect-thunk-register-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-register-3.c: Likewise.
|
||||
|
||||
i386: Rename to ix86_indirect_branch_register
|
||||
|
||||
Rename the variable for -mindirect-branch-register to
|
||||
ix86_indirect_branch_register to match the command-line option name.
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Replace
|
||||
ix86_indirect_branch_thunk_register with
|
||||
ix86_indirect_branch_register.
|
||||
(Bw): Likewise.
|
||||
* config/i386/i386.md (indirect_jump): Likewise.
|
||||
(tablejump): Likewise.
|
||||
(*sibcall_memory): Likewise.
|
||||
(*sibcall_value_memory): Likewise.
|
||||
Peepholes of indirect call and jump via memory: Likewise.
|
||||
* config/i386/i386.opt: Likewise.
|
||||
* config/i386/predicates.md (indirect_branch_operand): Likewise.
|
||||
(GOT_memory_operand): Likewise.
|
||||
(call_insn_operand): Likewise.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
|
||||
x86: Rewrite ix86_indirect_branch_register logic
|
||||
|
||||
Rewrite ix86_indirect_branch_register logic with
|
||||
|
||||
(and (not (match_test "ix86_indirect_branch_register"))
|
||||
(original condition before r256662))
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/predicates.md (constant_call_address_operand):
|
||||
Rewrite ix86_indirect_branch_register logic.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
|
||||
Don't check ix86_indirect_branch_register for GOT operand
|
||||
|
||||
Since GOT_memory_operand and GOT32_symbol_operand are simple pattern
|
||||
matches, don't check ix86_indirect_branch_register here. If needed,
|
||||
-mindirect-branch= will convert indirect branch via GOT slot to a call
|
||||
and return thunk.
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Update
|
||||
ix86_indirect_branch_register check. Don't check
|
||||
ix86_indirect_branch_register with GOT_memory_operand.
|
||||
(Bw): Likewise.
|
||||
* config/i386/predicates.md (GOT_memory_operand): Don't check
|
||||
ix86_indirect_branch_register here.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
|
||||
i386: Rewrite indirect_branch_operand logic
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/predicates.md (indirect_branch_operand): Rewrite
|
||||
ix86_indirect_branch_register logic.
|
||||
---
|
||||
gcc/config/i386/constraints.md | 6 ++--
|
||||
gcc/config/i386/i386.md | 34 ++++++++++++++--------
|
||||
gcc/config/i386/i386.opt | 4 +++
|
||||
gcc/config/i386/predicates.md | 21 +++++++------
|
||||
gcc/doc/invoke.texi | 6 +++-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-1.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-2.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-3.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-4.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-5.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-6.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-register-1.c | 22 ++++++++++++++
|
||||
.../gcc.target/i386/indirect-thunk-register-2.c | 20 +++++++++++++
|
||||
.../gcc.target/i386/indirect-thunk-register-3.c | 19 ++++++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-10.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-11.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-12.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-13.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-14.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-15.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 2 +-
|
||||
47 files changed, 147 insertions(+), 63 deletions(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
|
||||
diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
|
||||
index 1a4c701ad13..9204c8e8487 100644
|
||||
--- a/gcc/config/i386/constraints.md
|
||||
+++ b/gcc/config/i386/constraints.md
|
||||
@@ -172,14 +172,16 @@
|
||||
|
||||
(define_constraint "Bs"
|
||||
"@internal Sibcall memory operand."
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (ior (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "sibcall_memory_operand"))
|
||||
(and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
(match_operand 0 "GOT_memory_operand"))))
|
||||
|
||||
(define_constraint "Bw"
|
||||
"@internal Call memory operand."
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (ior (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "memory_operand"))
|
||||
(and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
(match_operand 0 "GOT_memory_operand"))))
|
||||
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
||||
index 2da671e9f2d..05a88fff356 100644
|
||||
--- a/gcc/config/i386/i386.md
|
||||
+++ b/gcc/config/i386/i386.md
|
||||
@@ -11805,7 +11805,7 @@
|
||||
[(set (pc) (match_operand 0 "indirect_branch_operand"))]
|
||||
""
|
||||
{
|
||||
- if (TARGET_X32)
|
||||
+ if (TARGET_X32 || ix86_indirect_branch_register)
|
||||
operands[0] = convert_memory_address (word_mode, operands[0]);
|
||||
cfun->machine->has_local_indirect_jump = true;
|
||||
})
|
||||
@@ -11859,7 +11859,7 @@
|
||||
OPTAB_DIRECT);
|
||||
}
|
||||
|
||||
- if (TARGET_X32)
|
||||
+ if (TARGET_X32 || ix86_indirect_branch_register)
|
||||
operands[0] = convert_memory_address (word_mode, operands[0]);
|
||||
cfun->machine->has_local_indirect_jump = true;
|
||||
})
|
||||
@@ -12048,7 +12048,7 @@
|
||||
[(call (mem:QI (match_operand:W 0 "memory_operand" "m"))
|
||||
(match_operand 1))
|
||||
(unspec [(const_int 0)] UNSPEC_PEEPSIB)]
|
||||
- "!TARGET_X32"
|
||||
+ "!TARGET_X32 && !ix86_indirect_branch_register"
|
||||
"* return ix86_output_call_insn (insn, operands[0]);"
|
||||
[(set_attr "type" "call")])
|
||||
|
||||
@@ -12057,7 +12057,9 @@
|
||||
(match_operand:W 1 "memory_operand"))
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
|
||||
[(parallel [(call (mem:QI (match_dup 1))
|
||||
@@ -12070,7 +12072,9 @@
|
||||
(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
|
||||
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
@@ -12092,7 +12096,7 @@
|
||||
})
|
||||
|
||||
(define_insn "*call_pop"
|
||||
- [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lmBz"))
|
||||
+ [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lBwBz"))
|
||||
(match_operand 1))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
@@ -12112,7 +12116,7 @@
|
||||
[(set_attr "type" "call")])
|
||||
|
||||
(define_insn "*sibcall_pop_memory"
|
||||
- [(call (mem:QI (match_operand:SI 0 "memory_operand" "m"))
|
||||
+ [(call (mem:QI (match_operand:SI 0 "memory_operand" "Bs"))
|
||||
(match_operand 1))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
@@ -12166,7 +12170,9 @@
|
||||
[(set (match_operand:W 0 "register_operand")
|
||||
(match_operand:W 1 "memory_operand"))
|
||||
(set (pc) (match_dup 0))]
|
||||
- "!TARGET_X32 && peep2_reg_dead_p (2, operands[0])"
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && peep2_reg_dead_p (2, operands[0])"
|
||||
[(set (pc) (match_dup 1))])
|
||||
|
||||
;; Call subroutine, returning value in operand 0
|
||||
@@ -12244,7 +12250,7 @@
|
||||
(call (mem:QI (match_operand:W 1 "memory_operand" "m"))
|
||||
(match_operand 2)))
|
||||
(unspec [(const_int 0)] UNSPEC_PEEPSIB)]
|
||||
- "!TARGET_X32"
|
||||
+ "!TARGET_X32 && !ix86_indirect_branch_register"
|
||||
"* return ix86_output_call_insn (insn, operands[1]);"
|
||||
[(set_attr "type" "callv")])
|
||||
|
||||
@@ -12254,7 +12260,9 @@
|
||||
(set (match_operand 2)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3)))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
|
||||
[(parallel [(set (match_dup 2)
|
||||
@@ -12269,7 +12277,9 @@
|
||||
(set (match_operand 2)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3)))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
|
||||
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
@@ -12294,7 +12304,7 @@
|
||||
|
||||
(define_insn "*call_value_pop"
|
||||
[(set (match_operand 0)
|
||||
- (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lmBz"))
|
||||
+ (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lBwBz"))
|
||||
(match_operand 2)))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
|
||||
index ad5916fb643..a97f84f68f2 100644
|
||||
--- a/gcc/config/i386/i386.opt
|
||||
+++ b/gcc/config/i386/i386.opt
|
||||
@@ -921,3 +921,7 @@ Enum(indirect_branch) String(thunk-inline) Value(indirect_branch_thunk_inline)
|
||||
|
||||
EnumValue
|
||||
Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
|
||||
+
|
||||
+mindirect-branch-register
|
||||
+Target Report Var(ix86_indirect_branch_register) Init(0)
|
||||
+Force indirect call and jump via register.
|
||||
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
|
||||
index 93dda7bb0e7..d1f0a7dbf61 100644
|
||||
--- a/gcc/config/i386/predicates.md
|
||||
+++ b/gcc/config/i386/predicates.md
|
||||
@@ -593,7 +593,8 @@
|
||||
;; Test for a valid operand for indirect branch.
|
||||
(define_predicate "indirect_branch_operand"
|
||||
(ior (match_operand 0 "register_operand")
|
||||
- (and (not (match_test "TARGET_X32"))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "memory_operand"))))
|
||||
|
||||
;; Return true if OP is a memory operands that can be used in sibcalls.
|
||||
@@ -636,20 +637,22 @@
|
||||
(ior (match_test "constant_call_address_operand
|
||||
(op, mode == VOIDmode ? mode : Pmode)")
|
||||
(match_operand 0 "call_register_no_elim_operand")
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
- (match_operand 0 "memory_operand"))
|
||||
- (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
- (match_operand 0 "GOT_memory_operand")))))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (match_operand 0 "memory_operand"))
|
||||
+ (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
+ (match_operand 0 "GOT_memory_operand"))))))
|
||||
|
||||
;; Similarly, but for tail calls, in which we cannot allow memory references.
|
||||
(define_special_predicate "sibcall_insn_operand"
|
||||
(ior (match_test "constant_call_address_operand
|
||||
(op, mode == VOIDmode ? mode : Pmode)")
|
||||
(match_operand 0 "register_no_elim_operand")
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
- (match_operand 0 "sibcall_memory_operand"))
|
||||
- (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
- (match_operand 0 "GOT_memory_operand")))))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (match_operand 0 "sibcall_memory_operand"))
|
||||
+ (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
+ (match_operand 0 "GOT_memory_operand"))))))
|
||||
|
||||
;; Return true if OP is a 32-bit GOT symbol operand.
|
||||
(define_predicate "GOT32_symbol_operand"
|
||||
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
|
||||
index 337a761015a..94374661f2d 100644
|
||||
--- a/gcc/doc/invoke.texi
|
||||
+++ b/gcc/doc/invoke.texi
|
||||
@@ -1170,7 +1170,7 @@ See RS/6000 and PowerPC Options.
|
||||
-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
|
||||
-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
|
||||
-mmitigate-rop -mindirect-branch=@var{choice} @gol
|
||||
--mfunction-return=@var{choice}}
|
||||
+-mfunction-return=@var{choice} -mindirect-branch-register}
|
||||
|
||||
@emph{x86 Windows Options}
|
||||
@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
|
||||
@@ -24253,6 +24253,10 @@ object file. You can control this behavior for a specific function by
|
||||
using the function attribute @code{function_return}.
|
||||
@xref{Function Attributes}.
|
||||
|
||||
+@item -mindirect-branch-register
|
||||
+@opindex -mindirect-branch-register
|
||||
+Force indirect call and jump via register.
|
||||
+
|
||||
@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 e365ef5698a..60d09881a99 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 05a51ad9157..aac75163794 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 3c0d4c39f0b..9e24a385387 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -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 14d4ef6dd98..127b5d94523 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
typedef void (*dispatch_t)(long offset);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
index b4836c38d6c..fcaa18d10b7 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
index 1f06bd1af74..e4649283d10 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
|
||||
index bc6b47a636e..17c2d0faf88 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 2257be3affa..9194ccf3cbc 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 e9cfdc5879e..e51f261a612 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 f938db050f7..4aeec1833cd 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 4e58599692a..ac0e5999f63 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 b8d50249d8b..573cf1ef09e 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 455adabfe0e..b2b37fc6e2e 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 4595b841ec0..4a43e199931 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
|
||||
|
||||
void func0 (void);
|
||||
void func1 (void);
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
index 5e3e118e9bd..ac84ab623fa 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { ! x32 } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
|
||||
void (*dispatch) (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
index 2801aa4192e..ce655e8be1c 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { ! x32 } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
|
||||
void (*dispatch) (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
index 70b4fb36eea..d34485a0010 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
|
||||
void bar (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
index 3baf03ee77c..0e19830de4d 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
|
||||
void bar (char *);
|
||||
char buf[10];
|
||||
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 edeb264218c..579441f250e 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 1d00413a76a..c92e6f2b02d 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 06ebf1c9063..d9964c25bbd 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 1c8f9446636..d4dca4dc5fe 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
index 21740ac5b7f..5c07e02df6a 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
index a77c1f470b8..3eb440693a0 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
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 86e9fd1f1e4..aece9383697 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 3ecde878867..3aba5e8c81f 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 df32a19a2b5..0f0181d6672 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 9540996de01..2eef6f35a75 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 f3db6e2441f..e825a10f14c 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
index 0f687c3b027..c6d77e10352 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
index b27c6fc96a2..6454827b780 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
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 764a375fc37..c67066cf197 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
|
||||
void func0 (void);
|
||||
void func1 (void);
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
new file mode 100644
|
||||
index 00000000000..7d396a31953
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
@@ -0,0 +1,22 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */
|
||||
+/* { dg-final { scan-assembler {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk\n" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk_bnd\n" } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
new file mode 100644
|
||||
index 00000000000..e7e616bb271
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
@@ -0,0 +1,20 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */
|
||||
+/* { dg-final { scan-assembler {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
new file mode 100644
|
||||
index 00000000000..5320e923be2
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
@@ -0,0 +1,19 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not {\t(pause|pause|nop)} } } */
|
||||
+/* { 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-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
index 3a6727b5c54..e6fea84a4d9 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
index b8f68188313..e239ec4542f 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
index 01b0a02f80b..fa3181303c9 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
index 4b497b5f8af..fd5b41fdd3f 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
extern int foo (void) __attribute__ ((function_return("thunk")));
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
index 4ae4c44a3fd..d606373ead1 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
index 5b5bc765a7e..75e45e226b8 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
index fa24a1f7365..d1db41cc128 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
--
|
||||
2.16.3
|
||||
|
134
cross/gcc-armhf/0007-x86-Add-V-register-operand-modifier.patch
Normal file
134
cross/gcc-armhf/0007-x86-Add-V-register-operand-modifier.patch
Normal file
|
@ -0,0 +1,134 @@
|
|||
From 92308185917678406afee3c165ea5e71b53b3cc1 Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 6 Jan 2018 22:29:56 -0800
|
||||
Subject: [PATCH 07/13] x86: Add 'V' register operand modifier
|
||||
|
||||
Add 'V', a special modifier which prints the name of the full integer
|
||||
register without '%'. For
|
||||
|
||||
extern void (*func_p) (void);
|
||||
|
||||
void
|
||||
foo (void)
|
||||
{
|
||||
asm ("call __x86_indirect_thunk_%V0" : : "a" (func_p));
|
||||
}
|
||||
|
||||
it generates:
|
||||
|
||||
foo:
|
||||
movq func_p(%rip), %rax
|
||||
call __x86_indirect_thunk_rax
|
||||
ret
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (print_reg): Print the name of the full
|
||||
integer register without '%'.
|
||||
(ix86_print_operand): Handle 'V'.
|
||||
* doc/extend.texi: Document 'V' modifier.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-register-4.c: New test.
|
||||
---
|
||||
gcc/config/i386/i386.c | 13 ++++++++++++-
|
||||
gcc/doc/extend.texi | 3 +++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c | 13 +++++++++++++
|
||||
3 files changed, 28 insertions(+), 1 deletion(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 34e26a3a3c7..eeca7e5e490 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -16869,6 +16869,7 @@ put_condition_code (enum rtx_code code, machine_mode mode, bool reverse,
|
||||
If CODE is 'h', pretend the reg is the 'high' byte register.
|
||||
If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.
|
||||
If CODE is 'd', duplicate the operand for AVX instruction.
|
||||
+ If CODE is 'V', print naked full integer register name without %.
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -16879,7 +16880,7 @@ print_reg (rtx x, int code, FILE *file)
|
||||
unsigned int regno;
|
||||
bool duplicated;
|
||||
|
||||
- if (ASSEMBLER_DIALECT == ASM_ATT)
|
||||
+ if (ASSEMBLER_DIALECT == ASM_ATT && code != 'V')
|
||||
putc ('%', file);
|
||||
|
||||
if (x == pc_rtx)
|
||||
@@ -16922,6 +16923,14 @@ print_reg (rtx x, int code, FILE *file)
|
||||
&& regno != FPSR_REG
|
||||
&& regno != FPCR_REG);
|
||||
|
||||
+ if (code == 'V')
|
||||
+ {
|
||||
+ if (GENERAL_REGNO_P (regno))
|
||||
+ msize = GET_MODE_SIZE (word_mode);
|
||||
+ else
|
||||
+ error ("'V' modifier on non-integer register");
|
||||
+ }
|
||||
+
|
||||
duplicated = code == 'd' && TARGET_AVX;
|
||||
|
||||
switch (msize)
|
||||
@@ -17035,6 +17044,7 @@ print_reg (rtx x, int code, FILE *file)
|
||||
& -- print some in-use local-dynamic symbol name.
|
||||
H -- print a memory address offset by 8; used for sse high-parts
|
||||
Y -- print condition for XOP pcom* instruction.
|
||||
+ V -- print naked full integer register name without %.
|
||||
+ -- print a branch hint as 'cs' or 'ds' prefix
|
||||
; -- print a semicolon (after prefixes due to bug in older gas).
|
||||
~ -- print "i" if TARGET_AVX2, "f" otherwise.
|
||||
@@ -17259,6 +17269,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
|
||||
case 'X':
|
||||
case 'P':
|
||||
case 'p':
|
||||
+ case 'V':
|
||||
break;
|
||||
|
||||
case 's':
|
||||
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
|
||||
index 2cb6bd1ef3e..76ba1d4f913 100644
|
||||
--- a/gcc/doc/extend.texi
|
||||
+++ b/gcc/doc/extend.texi
|
||||
@@ -8511,6 +8511,9 @@ The table below shows the list of supported modifiers and their effects.
|
||||
@tab @code{2}
|
||||
@end multitable
|
||||
|
||||
+@code{V} is a special modifier which prints the name of the full integer
|
||||
+register without @code{%}.
|
||||
+
|
||||
@anchor{x86floatingpointasmoperands}
|
||||
@subsubsection x86 Floating-Point @code{asm} Operands
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
new file mode 100644
|
||||
index 00000000000..f0cd9b75be8
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
@@ -0,0 +1,13 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -fno-pic" } */
|
||||
+
|
||||
+extern void (*func_p) (void);
|
||||
+
|
||||
+void
|
||||
+foo (void)
|
||||
+{
|
||||
+ asm("call __x86_indirect_thunk_%V0" : : "a" (func_p));
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_eax" { target ia32 } } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_rax" { target { ! ia32 } } } } */
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,299 @@
|
|||
From 087b12213a5b4b8654c70320c671bb05c1b1b012 Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 13 Jan 2018 18:01:54 -0800
|
||||
Subject: [PATCH 08/13] x86: Disallow -mindirect-branch=/-mfunction-return=
|
||||
with -mcmodel=large
|
||||
|
||||
Since the thunk function may not be reachable in large code model,
|
||||
-mcmodel=large is incompatible with -mindirect-branch=thunk,
|
||||
-mindirect-branch=thunk-extern, -mfunction-return=thunk and
|
||||
-mfunction-return=thunk-extern. Issue an error when they are used with
|
||||
-mcmodel=large.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_set_indirect_branch_type): Disallow
|
||||
-mcmodel=large with -mindirect-branch=thunk,
|
||||
-mindirect-branch=thunk-extern, -mfunction-return=thunk and
|
||||
-mfunction-return=thunk-extern.
|
||||
* doc/invoke.texi: Document -mcmodel=large is incompatible with
|
||||
-mindirect-branch=thunk, -mindirect-branch=thunk-extern,
|
||||
-mfunction-return=thunk and -mfunction-return=thunk-extern.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-10.c: New test.
|
||||
* gcc.target/i386/indirect-thunk-8.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-9.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-10.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-11.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-9.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-17.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-18.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-19.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-20.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-21.c: Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 26 ++++++++++++++++++++++
|
||||
gcc/doc/invoke.texi | 11 +++++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-10.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-8.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-9.c | 7 ++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-10.c | 9 ++++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-11.c | 9 ++++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-9.c | 9 ++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-17.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-18.c | 8 +++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-19.c | 8 +++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-20.c | 9 ++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-21.c | 9 ++++++++
|
||||
13 files changed, 126 insertions(+)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index eeca7e5e490..9c038bee000 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -6389,6 +6389,19 @@ ix86_set_indirect_branch_type (tree fndecl)
|
||||
}
|
||||
else
|
||||
cfun->machine->indirect_branch_type = ix86_indirect_branch;
|
||||
+
|
||||
+ /* -mcmodel=large is not compatible with -mindirect-branch=thunk
|
||||
+ nor -mindirect-branch=thunk-extern. */
|
||||
+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
|
||||
+ && ((cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ || (cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk)))
|
||||
+ error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
|
||||
+ "compatible",
|
||||
+ ((cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ ? "thunk-extern" : "thunk"));
|
||||
}
|
||||
|
||||
if (cfun->machine->function_return_type == indirect_branch_unset)
|
||||
@@ -6414,6 +6427,19 @@ ix86_set_indirect_branch_type (tree fndecl)
|
||||
}
|
||||
else
|
||||
cfun->machine->function_return_type = ix86_function_return;
|
||||
+
|
||||
+ /* -mcmodel=large is not compatible with -mfunction-return=thunk
|
||||
+ nor -mfunction-return=thunk-extern. */
|
||||
+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
|
||||
+ && ((cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ || (cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk)))
|
||||
+ error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
|
||||
+ "compatible",
|
||||
+ ((cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ ? "thunk-extern" : "thunk"));
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
|
||||
index 94374661f2d..1dee495c86b 100644
|
||||
--- a/gcc/doc/invoke.texi
|
||||
+++ b/gcc/doc/invoke.texi
|
||||
@@ -24242,6 +24242,11 @@ 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}.
|
||||
|
||||
+Note that @option{-mcmodel=large} is incompatible with
|
||||
+@option{-mindirect-branch=thunk} nor
|
||||
+@option{-mindirect-branch=thunk-extern} since the thunk function may
|
||||
+not be reachable in large code model.
|
||||
+
|
||||
@item -mfunction-return=@var{choice}
|
||||
@opindex -mfunction-return
|
||||
Convert function return with @var{choice}. The default is @samp{keep},
|
||||
@@ -24253,6 +24258,12 @@ object file. You can control this behavior for a specific function by
|
||||
using the function attribute @code{function_return}.
|
||||
@xref{Function Attributes}.
|
||||
|
||||
+Note that @option{-mcmodel=large} is incompatible with
|
||||
+@option{-mfunction-return=thunk} nor
|
||||
+@option{-mfunction-return=thunk-extern} since the thunk function may
|
||||
+not be reachable in large code model.
|
||||
+
|
||||
+
|
||||
@item -mindirect-branch-register
|
||||
@opindex -mindirect-branch-register
|
||||
Force indirect call and jump via register.
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
new file mode 100644
|
||||
index 00000000000..a0674bd2363
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
new file mode 100644
|
||||
index 00000000000..7a80a8986e8
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
new file mode 100644
|
||||
index 00000000000..d4d45c5114d
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
new file mode 100644
|
||||
index 00000000000..3a2aeaddbc5
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk-extern")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
new file mode 100644
|
||||
index 00000000000..8e52f032b6c
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk-inline")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
new file mode 100644
|
||||
index 00000000000..bdaa4f6911b
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-17.c b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
new file mode 100644
|
||||
index 00000000000..0605e2c6542
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-18.c b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
new file mode 100644
|
||||
index 00000000000..307019dc242
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
@@ -0,0 +1,8 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-19.c b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
new file mode 100644
|
||||
index 00000000000..772617f4010
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
@@ -0,0 +1,8 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-20.c b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
new file mode 100644
|
||||
index 00000000000..1e9f9bd5a66
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk-extern")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-21.c b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
new file mode 100644
|
||||
index 00000000000..eea07f7abe1
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk-inline")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
From 07857bd9fb9ccab67a932ad9df3e53f3f0c2c617 Mon Sep 17 00:00:00 2001
|
||||
From: uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Thu, 25 Jan 2018 19:39:01 +0000
|
||||
Subject: [PATCH 09/13] Use INVALID_REGNUM in indirect thunk processing
|
||||
|
||||
Backport from mainline
|
||||
2018-01-17 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
* config/i386/i386.c (indirect_thunk_name): Declare regno
|
||||
as unsigned int. Compare regno with INVALID_REGNUM.
|
||||
(output_indirect_thunk): Ditto.
|
||||
(output_indirect_thunk_function): Ditto.
|
||||
(ix86_code_end): Declare regno as unsigned int. Use INVALID_REGNUM
|
||||
in the call to output_indirect_thunk_function.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257067 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 30 +++++++++++++++---------------
|
||||
1 file changed, 15 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 9c038bee000..40126579c22 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11087,16 +11087,16 @@ static int indirect_thunks_bnd_used;
|
||||
/* Fills in the label name that should be used for the indirect thunk. */
|
||||
|
||||
static void
|
||||
-indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
- bool ret_p)
|
||||
+indirect_thunk_name (char name[32], unsigned int regno,
|
||||
+ bool need_bnd_p, bool ret_p)
|
||||
{
|
||||
- if (regno >= 0 && ret_p)
|
||||
+ if (regno != INVALID_REGNUM && ret_p)
|
||||
gcc_unreachable ();
|
||||
|
||||
if (USE_HIDDEN_LINKONCE)
|
||||
{
|
||||
const char *bnd = need_bnd_p ? "_bnd" : "";
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
const char *reg_prefix;
|
||||
if (LEGACY_INT_REGNO_P (regno))
|
||||
@@ -11114,7 +11114,7 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
}
|
||||
else
|
||||
{
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
if (need_bnd_p)
|
||||
ASM_GENERATE_INTERNAL_LABEL (name, "LITBR", regno);
|
||||
@@ -11166,7 +11166,7 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
*/
|
||||
|
||||
static void
|
||||
-output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
+output_indirect_thunk (bool need_bnd_p, unsigned int regno)
|
||||
{
|
||||
char indirectlabel1[32];
|
||||
char indirectlabel2[32];
|
||||
@@ -11196,7 +11196,7 @@ output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
|
||||
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
|
||||
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
/* MOV. */
|
||||
rtx xops[2];
|
||||
@@ -11220,12 +11220,12 @@ output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
}
|
||||
|
||||
/* Output a funtion with a call and return thunk for indirect branch.
|
||||
- If BND_P is true, the BND prefix is needed. If REGNO != -1, the
|
||||
- function address is in REGNO. Otherwise, the function address is
|
||||
+ If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM,
|
||||
+ the function address is in REGNO. Otherwise, the function address is
|
||||
on the top of stack. */
|
||||
|
||||
static void
|
||||
-output_indirect_thunk_function (bool need_bnd_p, int regno)
|
||||
+output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
{
|
||||
char name[32];
|
||||
tree decl;
|
||||
@@ -11274,7 +11274,7 @@ output_indirect_thunk_function (bool need_bnd_p, int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
- if (regno < 0)
|
||||
+ if (regno == INVALID_REGNUM)
|
||||
{
|
||||
/* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
|
||||
char alias[32];
|
||||
@@ -11348,16 +11348,16 @@ static void
|
||||
ix86_code_end (void)
|
||||
{
|
||||
rtx xops[2];
|
||||
- int regno;
|
||||
+ unsigned int regno;
|
||||
|
||||
if (indirect_thunk_needed)
|
||||
- output_indirect_thunk_function (false, -1);
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM);
|
||||
if (indirect_thunk_bnd_needed)
|
||||
- output_indirect_thunk_function (true, -1);
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM);
|
||||
|
||||
for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
|
||||
{
|
||||
- int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
+ unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
if ((indirect_thunks_used & (1 << i)))
|
||||
output_indirect_thunk_function (false, regno);
|
||||
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 3815e98f0f46b6c4c41e6810bad987bd083691aa Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Fri, 2 Feb 2018 16:47:02 +0000
|
||||
Subject: [PATCH 10/13] i386: Pass INVALID_REGNUM as invalid register number
|
||||
|
||||
Backport from mainline
|
||||
* config/i386/i386.c (ix86_output_function_return): Pass
|
||||
INVALID_REGNUM, instead of -1, as invalid register number to
|
||||
indirect_thunk_name and output_indirect_thunk.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257341 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 40126579c22..66502ee6da6 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -28056,7 +28056,8 @@ ix86_output_function_return (bool long_p)
|
||||
{
|
||||
bool need_thunk = (cfun->machine->function_return_type
|
||||
== indirect_branch_thunk);
|
||||
- indirect_thunk_name (thunk_name, -1, need_bnd_p, true);
|
||||
+ indirect_thunk_name (thunk_name, INVALID_REGNUM, need_bnd_p,
|
||||
+ true);
|
||||
if (need_bnd_p)
|
||||
{
|
||||
indirect_thunk_bnd_needed |= need_thunk;
|
||||
@@ -28069,7 +28070,7 @@ ix86_output_function_return (bool long_p)
|
||||
}
|
||||
}
|
||||
else
|
||||
- output_indirect_thunk (need_bnd_p, -1);
|
||||
+ output_indirect_thunk (need_bnd_p, INVALID_REGNUM);
|
||||
|
||||
return "";
|
||||
}
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,456 @@
|
|||
From 771535dec733e4b85924f00a3a94c29683d614e5 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 26 Feb 2018 15:29:30 +0000
|
||||
Subject: [PATCH 11/13] i386: Update -mfunction-return= for return with pop
|
||||
|
||||
When -mfunction-return= is used, simple_return_pop_internal should pop
|
||||
return address into ECX register, adjust stack by bytes to pop from stack
|
||||
and jump to the return thunk via ECX register.
|
||||
|
||||
Revision 257992 removed the bool argument from ix86_output_indirect_jmp.
|
||||
Update comments to reflect it.
|
||||
|
||||
Tested on i686 and x86-64.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_output_indirect_jmp): Update comments.
|
||||
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/84530
|
||||
* config/i386/i386-protos.h (ix86_output_indirect_jmp): Remove
|
||||
the bool argument.
|
||||
(ix86_output_indirect_function_return): New prototype.
|
||||
(ix86_split_simple_return_pop_internal): Likewise.
|
||||
* config/i386/i386.c (indirect_return_via_cx): New.
|
||||
(indirect_return_via_cx_bnd): Likewise.
|
||||
(indirect_thunk_name): Handle return va CX_REG.
|
||||
(output_indirect_thunk_function): Create alias for
|
||||
__x86_return_thunk_[re]cx and __x86_return_thunk_[re]cx_bnd.
|
||||
(ix86_output_indirect_jmp): Remove the bool argument.
|
||||
(ix86_output_indirect_function_return): New function.
|
||||
(ix86_split_simple_return_pop_internal): Likewise.
|
||||
* config/i386/i386.md (*indirect_jump): Don't pass false
|
||||
to ix86_output_indirect_jmp.
|
||||
(*tablejump_1): Likewise.
|
||||
(simple_return_pop_internal): Change it to define_insn_and_split.
|
||||
Call ix86_split_simple_return_pop_internal to split it for
|
||||
-mfunction-return=.
|
||||
(simple_return_indirect_internal): Call
|
||||
ix86_output_indirect_function_return instead of
|
||||
ix86_output_indirect_jmp.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/84530
|
||||
* gcc.target/i386/ret-thunk-22.c: New test.
|
||||
* gcc.target/i386/ret-thunk-23.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-24.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-25.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-26.c: Likewise.
|
||||
---
|
||||
gcc/config/i386/i386-protos.h | 4 +-
|
||||
gcc/config/i386/i386.c | 127 +++++++++++++++++++++++----
|
||||
gcc/config/i386/i386.md | 11 ++-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-22.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-23.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-24.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-25.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-26.c | 40 +++++++++
|
||||
8 files changed, 222 insertions(+), 20 deletions(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
|
||||
index 620d70ef9f6..c7a0ccb58d3 100644
|
||||
--- a/gcc/config/i386/i386-protos.h
|
||||
+++ b/gcc/config/i386/i386-protos.h
|
||||
@@ -311,8 +311,10 @@ extern enum attr_cpu ix86_schedule;
|
||||
#endif
|
||||
|
||||
extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
|
||||
-extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
|
||||
+extern const char * ix86_output_indirect_jmp (rtx call_op);
|
||||
extern const char * ix86_output_function_return (bool long_p);
|
||||
+extern const char * ix86_output_indirect_function_return (rtx ret_op);
|
||||
+extern void ix86_split_simple_return_pop_internal (rtx);
|
||||
extern bool ix86_operands_ok_for_move_multiple (rtx *operands, bool load,
|
||||
enum machine_mode mode);
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 66502ee6da6..21c3c18bd3c 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11080,6 +11080,12 @@ static int indirect_thunks_used;
|
||||
by call and return thunks functions with the BND prefix. */
|
||||
static int indirect_thunks_bnd_used;
|
||||
|
||||
+/* True if return thunk function via CX is needed. */
|
||||
+static bool indirect_return_via_cx;
|
||||
+/* True if return thunk function via CX with the BND prefix is
|
||||
+ needed. */
|
||||
+static bool indirect_return_via_cx_bnd;
|
||||
+
|
||||
#ifndef INDIRECT_LABEL
|
||||
# define INDIRECT_LABEL "LIND"
|
||||
#endif
|
||||
@@ -11090,12 +11096,13 @@ static void
|
||||
indirect_thunk_name (char name[32], unsigned int regno,
|
||||
bool need_bnd_p, bool ret_p)
|
||||
{
|
||||
- if (regno != INVALID_REGNUM && ret_p)
|
||||
+ if (regno != INVALID_REGNUM && regno != CX_REG && ret_p)
|
||||
gcc_unreachable ();
|
||||
|
||||
if (USE_HIDDEN_LINKONCE)
|
||||
{
|
||||
const char *bnd = need_bnd_p ? "_bnd" : "";
|
||||
+ const char *ret = ret_p ? "return" : "indirect";
|
||||
if (regno != INVALID_REGNUM)
|
||||
{
|
||||
const char *reg_prefix;
|
||||
@@ -11103,14 +11110,11 @@ indirect_thunk_name (char name[32], unsigned int regno,
|
||||
reg_prefix = TARGET_64BIT ? "r" : "e";
|
||||
else
|
||||
reg_prefix = "";
|
||||
- sprintf (name, "__x86_indirect_thunk%s_%s%s",
|
||||
- bnd, reg_prefix, reg_names[regno]);
|
||||
+ sprintf (name, "__x86_%s_thunk%s_%s%s",
|
||||
+ ret, bnd, reg_prefix, reg_names[regno]);
|
||||
}
|
||||
else
|
||||
- {
|
||||
- const char *ret = ret_p ? "return" : "indirect";
|
||||
- sprintf (name, "__x86_%s_thunk%s", ret, bnd);
|
||||
- }
|
||||
+ sprintf (name, "__x86_%s_thunk%s", ret, bnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -11274,9 +11278,23 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
+ /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or
|
||||
+ __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */
|
||||
+ bool need_alias;
|
||||
if (regno == INVALID_REGNUM)
|
||||
+ need_alias = true;
|
||||
+ else if (regno == CX_REG)
|
||||
+ {
|
||||
+ if (need_bnd_p)
|
||||
+ need_alias = indirect_return_via_cx_bnd;
|
||||
+ else
|
||||
+ need_alias = indirect_return_via_cx;
|
||||
+ }
|
||||
+ else
|
||||
+ need_alias = false;
|
||||
+
|
||||
+ if (need_alias)
|
||||
{
|
||||
- /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
|
||||
char alias[32];
|
||||
|
||||
indirect_thunk_name (alias, regno, need_bnd_p, true);
|
||||
@@ -28019,18 +28037,17 @@ ix86_output_indirect_branch (rtx call_op, const char *xasm,
|
||||
else
|
||||
ix86_output_indirect_branch_via_push (call_op, xasm, sibcall_p);
|
||||
}
|
||||
-/* Output indirect jump. CALL_OP is the jump target. Jump is a
|
||||
- function return if RET_P is true. */
|
||||
+
|
||||
+/* Output indirect jump. CALL_OP is the jump target. */
|
||||
|
||||
const char *
|
||||
-ix86_output_indirect_jmp (rtx call_op, bool ret_p)
|
||||
+ix86_output_indirect_jmp (rtx call_op)
|
||||
{
|
||||
if (cfun->machine->indirect_branch_type != indirect_branch_keep)
|
||||
{
|
||||
- /* We can't have red-zone if this isn't a function return since
|
||||
- "call" in the indirect thunk pushes the return address onto
|
||||
- stack, destroying red-zone. */
|
||||
- if (!ret_p && ix86_red_zone_size != 0)
|
||||
+ /* We can't have red-zone since "call" in the indirect thunk
|
||||
+ pushes the return address onto stack, destroying red-zone. */
|
||||
+ if (ix86_red_zone_size != 0)
|
||||
gcc_unreachable ();
|
||||
|
||||
ix86_output_indirect_branch (call_op, "%0", true);
|
||||
@@ -28081,6 +28098,86 @@ ix86_output_function_return (bool long_p)
|
||||
return "rep%; ret";
|
||||
}
|
||||
|
||||
+/* Output indirect function return. RET_OP is the function return
|
||||
+ target. */
|
||||
+
|
||||
+const char *
|
||||
+ix86_output_indirect_function_return (rtx ret_op)
|
||||
+{
|
||||
+ if (cfun->machine->function_return_type != indirect_branch_keep)
|
||||
+ {
|
||||
+ char thunk_name[32];
|
||||
+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
|
||||
+ unsigned int regno = REGNO (ret_op);
|
||||
+ gcc_assert (regno == CX_REG);
|
||||
+
|
||||
+ 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, regno, need_bnd_p, true);
|
||||
+ if (need_bnd_p)
|
||||
+ {
|
||||
+ if (need_thunk)
|
||||
+ {
|
||||
+ indirect_return_via_cx_bnd = true;
|
||||
+ indirect_thunks_bnd_used |= 1 << CX_REG;
|
||||
+ }
|
||||
+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if (need_thunk)
|
||||
+ {
|
||||
+ indirect_return_via_cx = true;
|
||||
+ indirect_thunks_used |= 1 << CX_REG;
|
||||
+ }
|
||||
+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ output_indirect_thunk (need_bnd_p, regno);
|
||||
+
|
||||
+ return "";
|
||||
+ }
|
||||
+ else
|
||||
+ return "%!jmp\t%A0";
|
||||
+}
|
||||
+
|
||||
+/* Split simple return with popping POPC bytes from stack to indirect
|
||||
+ branch with stack adjustment . */
|
||||
+
|
||||
+void
|
||||
+ix86_split_simple_return_pop_internal (rtx popc)
|
||||
+{
|
||||
+ struct machine_function *m = cfun->machine;
|
||||
+ rtx ecx = gen_rtx_REG (SImode, CX_REG);
|
||||
+ rtx_insn *insn;
|
||||
+
|
||||
+ /* There is no "pascal" calling convention in any 64bit ABI. */
|
||||
+ gcc_assert (!TARGET_64BIT);
|
||||
+
|
||||
+ insn = emit_insn (gen_pop (ecx));
|
||||
+ m->fs.cfa_offset -= UNITS_PER_WORD;
|
||||
+ m->fs.sp_offset -= UNITS_PER_WORD;
|
||||
+
|
||||
+ rtx x = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD);
|
||||
+ x = gen_rtx_SET (stack_pointer_rtx, x);
|
||||
+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x);
|
||||
+ add_reg_note (insn, REG_CFA_REGISTER, gen_rtx_SET (ecx, pc_rtx));
|
||||
+ RTX_FRAME_RELATED_P (insn) = 1;
|
||||
+
|
||||
+ x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, popc);
|
||||
+ x = gen_rtx_SET (stack_pointer_rtx, x);
|
||||
+ insn = emit_insn (x);
|
||||
+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x);
|
||||
+ RTX_FRAME_RELATED_P (insn) = 1;
|
||||
+
|
||||
+ /* Now return address is in ECX. */
|
||||
+ emit_jump_insn (gen_simple_return_indirect_internal (ecx));
|
||||
+}
|
||||
+
|
||||
/* Output the assembly for a call instruction. */
|
||||
|
||||
const char *
|
||||
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
||||
index 05a88fff356..857466a6361 100644
|
||||
--- a/gcc/config/i386/i386.md
|
||||
+++ b/gcc/config/i386/i386.md
|
||||
@@ -11813,7 +11813,7 @@
|
||||
(define_insn "*indirect_jump"
|
||||
[(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))]
|
||||
""
|
||||
- "* return ix86_output_indirect_jmp (operands[0], false);"
|
||||
+ "* return ix86_output_indirect_jmp (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
@@ -11868,7 +11868,7 @@
|
||||
[(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))
|
||||
(use (label_ref (match_operand 1)))]
|
||||
""
|
||||
- "* return ix86_output_indirect_jmp (operands[0], false);"
|
||||
+ "* return ix86_output_indirect_jmp (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
@@ -12520,11 +12520,14 @@
|
||||
(set_attr "prefix_rep" "1")
|
||||
(set_attr "modrm" "0")])
|
||||
|
||||
-(define_insn "simple_return_pop_internal"
|
||||
+(define_insn_and_split "simple_return_pop_internal"
|
||||
[(simple_return)
|
||||
(use (match_operand:SI 0 "const_int_operand"))]
|
||||
"reload_completed"
|
||||
"%!ret\t%0"
|
||||
+ "&& cfun->machine->function_return_type != indirect_branch_keep"
|
||||
+ [(const_int 0)]
|
||||
+ "ix86_split_simple_return_pop_internal (operands[0]); DONE;"
|
||||
[(set_attr "length" "3")
|
||||
(set_attr "atom_unit" "jeu")
|
||||
(set_attr "length_immediate" "2")
|
||||
@@ -12535,7 +12538,7 @@
|
||||
[(simple_return)
|
||||
(use (match_operand:SI 0 "register_operand" "r"))]
|
||||
"reload_completed"
|
||||
- "* return ix86_output_indirect_jmp (operands[0], true);"
|
||||
+ "* return ix86_output_indirect_function_return (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-22.c b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
new file mode 100644
|
||||
index 00000000000..89e086de97b
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { 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-23.c b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
new file mode 100644
|
||||
index 00000000000..43f0ccaa854
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-extern" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler-not {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not {\tlfence} } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-24.c b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
new file mode 100644
|
||||
index 00000000000..8729e35147e
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { 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-25.c b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
new file mode 100644
|
||||
index 00000000000..f73553c9a9f
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_bnd_ecx" } } */
|
||||
+/* { 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-26.c b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
new file mode 100644
|
||||
index 00000000000..9144e988735
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
@@ -0,0 +1,40 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do run } */
|
||||
+/* { dg-options "-Os -mfunction-return=thunk" } */
|
||||
+
|
||||
+struct S { int i; };
|
||||
+__attribute__((const, noinline, noclone))
|
||||
+struct S foo (int x)
|
||||
+{
|
||||
+ struct S s;
|
||||
+ s.i = x;
|
||||
+ return s;
|
||||
+}
|
||||
+
|
||||
+int a[2048], b[2048], c[2048], d[2048];
|
||||
+struct S e[2048];
|
||||
+
|
||||
+__attribute__((noinline, noclone)) void
|
||||
+bar (void)
|
||||
+{
|
||||
+ int i;
|
||||
+ for (i = 0; i < 1024; i++)
|
||||
+ {
|
||||
+ e[i] = foo (i);
|
||||
+ a[i+2] = a[i] + a[i+1];
|
||||
+ b[10] = b[10] + i;
|
||||
+ c[i] = c[2047 - i];
|
||||
+ d[i] = d[i + 1];
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+main ()
|
||||
+{
|
||||
+ int i;
|
||||
+ bar ();
|
||||
+ for (i = 0; i < 1024; i++)
|
||||
+ if (e[i].i != i)
|
||||
+ __builtin_abort ();
|
||||
+ return 0;
|
||||
+}
|
||||
--
|
||||
2.16.3
|
||||
|
1003
cross/gcc-armhf/0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
Normal file
1003
cross/gcc-armhf/0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,225 @@
|
|||
From e7fbaebc8ff650df76f43e92cb9ca59d5174ebe7 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Thu, 15 Mar 2018 17:54:40 +0000
|
||||
Subject: [PATCH 13/13] i386: Don't generate alias for function return thunk
|
||||
|
||||
Function return thunks shouldn't be aliased to indirect branch thunks
|
||||
since indirect branch thunks are placed in COMDAT section and a COMDAT
|
||||
section with indirect branch may not have function return thunk. This
|
||||
patch generates function return thunks directly.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
PR target/84574
|
||||
* config/i386/i386.c (indirect_thunk_needed): Update comments.
|
||||
(indirect_thunk_bnd_needed): Likewise.
|
||||
(indirect_thunks_used): Likewise.
|
||||
(indirect_thunks_bnd_used): Likewise.
|
||||
(indirect_return_needed): New.
|
||||
(indirect_return_bnd_needed): Likewise.
|
||||
(output_indirect_thunk_function): Add a bool argument for
|
||||
function return.
|
||||
(output_indirect_thunk_function): Don't generate alias for
|
||||
function return thunk.
|
||||
(ix86_code_end): Call output_indirect_thunk_function to generate
|
||||
function return thunks.
|
||||
(ix86_output_function_return): Set indirect_return_bnd_needed
|
||||
and indirect_return_needed instead of indirect_thunk_bnd_needed
|
||||
and indirect_thunk_needed.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
PR target/84574
|
||||
* gcc.target/i386/ret-thunk-9.c: Expect __x86_return_thunk
|
||||
label instead of __x86_indirect_thunk label.
|
||||
---
|
||||
gcc/config/i386/i386.c | 92 ++++++++++-------------------
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 2 +-
|
||||
2 files changed, 33 insertions(+), 61 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 21c3c18bd3c..f4cd1c6f4e9 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11067,19 +11067,23 @@ ix86_setup_frame_addresses (void)
|
||||
labels in call and return thunks. */
|
||||
static int indirectlabelno;
|
||||
|
||||
-/* True if call and return thunk functions are needed. */
|
||||
+/* True if call thunk function is needed. */
|
||||
static bool indirect_thunk_needed = false;
|
||||
-/* True if call and return thunk functions with the BND prefix are
|
||||
- needed. */
|
||||
+/* True if call thunk function with the BND prefix is needed. */
|
||||
static bool indirect_thunk_bnd_needed = false;
|
||||
|
||||
/* Bit masks of integer registers, which contain branch target, used
|
||||
- by call and return thunks functions. */
|
||||
+ by call thunk functions. */
|
||||
static int indirect_thunks_used;
|
||||
/* Bit masks of integer registers, which contain branch target, used
|
||||
- by call and return thunks functions with the BND prefix. */
|
||||
+ by call thunk functions with the BND prefix. */
|
||||
static int indirect_thunks_bnd_used;
|
||||
|
||||
+/* True if return thunk function is needed. */
|
||||
+static bool indirect_return_needed = false;
|
||||
+/* True if return thunk function with the BND prefix is needed. */
|
||||
+static bool indirect_return_bnd_needed = false;
|
||||
+
|
||||
/* True if return thunk function via CX is needed. */
|
||||
static bool indirect_return_via_cx;
|
||||
/* True if return thunk function via CX with the BND prefix is
|
||||
@@ -11226,16 +11230,18 @@ output_indirect_thunk (bool need_bnd_p, unsigned int regno)
|
||||
/* Output a funtion with a call and return thunk for indirect branch.
|
||||
If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM,
|
||||
the function address is in REGNO. Otherwise, the function address is
|
||||
- on the top of stack. */
|
||||
+ on the top of stack. Thunk is used for function return if RET_P is
|
||||
+ true. */
|
||||
|
||||
static void
|
||||
-output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
+output_indirect_thunk_function (bool need_bnd_p, unsigned int regno,
|
||||
+ bool ret_p)
|
||||
{
|
||||
char name[32];
|
||||
tree decl;
|
||||
|
||||
/* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */
|
||||
- indirect_thunk_name (name, regno, need_bnd_p, false);
|
||||
+ indirect_thunk_name (name, regno, need_bnd_p, ret_p);
|
||||
decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
|
||||
get_identifier (name),
|
||||
build_function_type_list (void_type_node, NULL_TREE));
|
||||
@@ -11278,50 +11284,6 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
- /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or
|
||||
- __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */
|
||||
- bool need_alias;
|
||||
- if (regno == INVALID_REGNUM)
|
||||
- need_alias = true;
|
||||
- else if (regno == CX_REG)
|
||||
- {
|
||||
- if (need_bnd_p)
|
||||
- need_alias = indirect_return_via_cx_bnd;
|
||||
- else
|
||||
- need_alias = indirect_return_via_cx;
|
||||
- }
|
||||
- else
|
||||
- need_alias = false;
|
||||
-
|
||||
- if (need_alias)
|
||||
- {
|
||||
- char alias[32];
|
||||
-
|
||||
- indirect_thunk_name (alias, regno, need_bnd_p, 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);
|
||||
@@ -11368,19 +11330,29 @@ ix86_code_end (void)
|
||||
rtx xops[2];
|
||||
unsigned int regno;
|
||||
|
||||
+ if (indirect_return_needed)
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM, true);
|
||||
+ if (indirect_return_bnd_needed)
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM, true);
|
||||
+
|
||||
+ if (indirect_return_via_cx)
|
||||
+ output_indirect_thunk_function (false, CX_REG, true);
|
||||
+ if (indirect_return_via_cx_bnd)
|
||||
+ output_indirect_thunk_function (true, CX_REG, true);
|
||||
+
|
||||
if (indirect_thunk_needed)
|
||||
- output_indirect_thunk_function (false, INVALID_REGNUM);
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM, false);
|
||||
if (indirect_thunk_bnd_needed)
|
||||
- output_indirect_thunk_function (true, INVALID_REGNUM);
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM, false);
|
||||
|
||||
for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
|
||||
{
|
||||
unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
if ((indirect_thunks_used & (1 << i)))
|
||||
- output_indirect_thunk_function (false, regno);
|
||||
+ output_indirect_thunk_function (false, regno, false);
|
||||
|
||||
if ((indirect_thunks_bnd_used & (1 << i)))
|
||||
- output_indirect_thunk_function (true, regno);
|
||||
+ output_indirect_thunk_function (true, regno, false);
|
||||
}
|
||||
|
||||
for (regno = AX_REG; regno <= SP_REG; regno++)
|
||||
@@ -11389,10 +11361,10 @@ ix86_code_end (void)
|
||||
tree decl;
|
||||
|
||||
if ((indirect_thunks_used & (1 << regno)))
|
||||
- output_indirect_thunk_function (false, regno);
|
||||
+ output_indirect_thunk_function (false, regno, false);
|
||||
|
||||
if ((indirect_thunks_bnd_used & (1 << regno)))
|
||||
- output_indirect_thunk_function (true, regno);
|
||||
+ output_indirect_thunk_function (true, regno, false);
|
||||
|
||||
if (!(pic_labels_used & (1 << regno)))
|
||||
continue;
|
||||
@@ -28077,12 +28049,12 @@ ix86_output_function_return (bool long_p)
|
||||
true);
|
||||
if (need_bnd_p)
|
||||
{
|
||||
- indirect_thunk_bnd_needed |= need_thunk;
|
||||
+ indirect_return_bnd_needed |= need_thunk;
|
||||
fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
- indirect_thunk_needed |= need_thunk;
|
||||
+ indirect_return_needed |= need_thunk;
|
||||
fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
|
||||
}
|
||||
}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
index d2df8b874e0..eee230ca2f6 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
@@ -13,7 +13,7 @@ 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 "__x86_indirect_thunk:" } } */
|
||||
+/* { dg-final { scan-assembler "__x86_return_thunk:" } } */
|
||||
/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */
|
||||
/* { dg-final { scan-assembler-times {\tpause} 2 } } */
|
||||
/* { dg-final { scan-assembler-times {\tlfence} 2 } } */
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -54,7 +54,7 @@ pkgver=6.4.0
|
|||
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""
|
||||
|
||||
pkgname="gcc-armhf"
|
||||
pkgrel=7
|
||||
pkgrel=8
|
||||
pkgdesc="Stage2 cross-compiler for armhf"
|
||||
url="http://gcc.gnu.org"
|
||||
arch="aarch64 x86_64 x86"
|
||||
|
@ -236,6 +236,20 @@ source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgba
|
|||
fix-linux-header-use-in-libgcc.patch
|
||||
gcc-pure64-mips.patch
|
||||
ada-mips64.patch
|
||||
|
||||
0001-i386-Move-struct-ix86_frame-to-machine_function.patch
|
||||
0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch
|
||||
0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch
|
||||
0004-x86-Add-mindirect-branch.patch
|
||||
0005-x86-Add-mfunction-return.patch
|
||||
0006-x86-Add-mindirect-branch-register.patch
|
||||
0007-x86-Add-V-register-operand-modifier.patch
|
||||
0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch
|
||||
0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch
|
||||
0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch
|
||||
0011-i386-Update-mfunction-return-for-return-with-pop.patch
|
||||
0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
|
||||
0013-i386-Don-t-generate-alias-for-function-return-thunk.patch
|
||||
"
|
||||
|
||||
# we build out-of-tree
|
||||
|
@ -715,4 +729,17 @@ f4ef08454e28c8732db69115e4998ec153399e8d229dd27f923dbdcf57b68128a65640d026cc7f45
|
|||
01c71cd5881fc07ea3b9b980697e89b3ca0fe98502958ceafc3fca18b2604c844e2f457feab711baf8e03f00a5383b0e38aac7eb954034e306f43d4a37f165ed fix-rs6000-pie.patch
|
||||
34a818d5be67eb1f34e44a80b83c28a9b9c17d37fc9fac639f490d6bb5b53ebe3318140d09c236a17d7c98f5a7792ae3d6cefccda8067a5e942d6305b9d1f87c fix-linux-header-use-in-libgcc.patch
|
||||
86be3338cc9c33089608bc4c5e3b7918c4e500a345c338f361b18c342119a6ed69af5495d72950de7106d760f003528b46ad14795e805f8a3331e206dcb234e3 gcc-pure64-mips.patch
|
||||
508f3bca214d88531d739d761d07affc953689b1540905c73420b34c246e1e6b72588cf89f0e1462752633f8ddc88da8c0238be2a1b6e1c213829cecee7924cf ada-mips64.patch"
|
||||
508f3bca214d88531d739d761d07affc953689b1540905c73420b34c246e1e6b72588cf89f0e1462752633f8ddc88da8c0238be2a1b6e1c213829cecee7924cf ada-mips64.patch
|
||||
7912964bf3a985e9f870250d6e068f715582a4fb04270849d697a50e6aad0cf50df3d483ff80a0eb777d9940fd85526dd8d0b85da9bc71a5f2fbc07616263866 0001-i386-Move-struct-ix86_frame-to-machine_function.patch
|
||||
baa27a4b912d8e27cd65a556b09cf45289a0e00e86dae3925f2923d1f3752080e80d80e159c996ef4156c4df1dfc3069114810a846672170ef3ae461ae0ab7e1 0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch
|
||||
6701d15000bdd7c4c98a8fece8c814f5e4e73603eecf84fe4dc5ac10f79b3074afba7c2cc9e51d08b2abade1c34cb0c944c08ead7a85db94e97158c752fd1aac 0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch
|
||||
4e7e71ae57e232b29a6455ec977f60b47df1356eca0e85976ae2b4567c4c39541be9f10c30fe0085d69be5acdb61dff51d3e9d7af587c95d9cd2cb9ee307bd13 0004-x86-Add-mindirect-branch.patch
|
||||
07f7fdbd9b4876f36ed7715a35a369dbaf1016f46c42a8935930cfcc9ea250de2dbe8113f077373ccce3c39cd728f957b6c4c7c6a7da299f160a4109f0bbe88d 0005-x86-Add-mfunction-return.patch
|
||||
76ea947591e5241f8e6216ce337baaf1b5dfe3f02d8251f77a4acd70e2a5e7798e2867d70f452027f51a2e3baf1b5c94c3bffe9ef8e0a5ce24dc5d509adaf414 0006-x86-Add-mindirect-branch-register.patch
|
||||
1c33c5cd34efb44d4fa0ace56e3d27ec802a66e03b08a29ab6122cbc70edbbe22313a34114437a41e09e0a6869af3cea3fb18f5bcb49db2f8e3f155026fe15f0 0007-x86-Add-V-register-operand-modifier.patch
|
||||
5366e2cff0629304394bf35e9417c7faea6b6f3fc565d0410a17fdafcb2b30c9a218f8ca098274c09ca4c982ff5b178ad6df5bf464ec541aa086966915c7fe11 0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch
|
||||
67c738b1f6afb09b6f0469c9cb282ab4d51fc8dd8e39df1cfdff8831788c1022081fccd446a482623f649898733aeaaa205cba0aa41162cdbdc74e57de9bb6eb 0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch
|
||||
b7b59f3203bf53168de2170b91738cd456f6ae205b3fe5bf8aacbaa8cc5624dd09c941ad8f1071d1ab8ab4fb5f69068a4bc792c0486fdec1ee2eb9c83688bb78 0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch
|
||||
c53d4c5968865abb709ee8a9af9d57917d43ea3ba31ee8312f9e8f338e9b1b44babf5aa3414848da7267e5cf13a9261815eb9185dc153cbd41ee7ce5ea23d2d0 0011-i386-Update-mfunction-return-for-return-with-pop.patch
|
||||
955080ba3e42cfe2f604e5dcef46aa6fca7c899c7808398947af655ff3b7954e30807ef85246986a5cc7db36dbc870db151e9fa8d8bc967b89ea56efdf64614c 0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
|
||||
3aae3a9cef8e8afe5a5433db8d9f410e1a2882481af01bb1d33232f987dbb74d7780c32be70b868bb391b3601b65ed3a16d777afea946f5eeaff72aa1e7fa3a9 0013-i386-Don-t-generate-alias-for-function-return-thunk.patch"
|
||||
|
|
|
@ -0,0 +1,241 @@
|
|||
From b1d2df5090abc9202a7bf2d224ac90de22908d21 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 15 Jan 2018 11:27:24 +0000
|
||||
Subject: [PATCH 01/13] i386: Move struct ix86_frame to machine_function
|
||||
|
||||
Make ix86_frame available to i386 code generation. This is needed to
|
||||
backport the patch set of -mindirect-branch= to mitigate variant #2 of
|
||||
the speculative execution vulnerabilities on x86 processors identified
|
||||
by CVE-2017-5715, aka Spectre.
|
||||
|
||||
Backport from mainline
|
||||
2017-06-01 Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
|
||||
* config/i386/i386.c (ix86_frame): Moved to ...
|
||||
* config/i386/i386.h (ix86_frame): Here.
|
||||
(machine_function): Add frame.
|
||||
* config/i386/i386.c (ix86_compute_frame_layout): Repace the
|
||||
frame argument with &cfun->machine->frame.
|
||||
(ix86_can_use_return_insn_p): Don't pass &frame to
|
||||
ix86_compute_frame_layout. Copy frame from cfun->machine->frame.
|
||||
(ix86_can_eliminate): Likewise.
|
||||
(ix86_expand_prologue): Likewise.
|
||||
(ix86_expand_epilogue): Likewise.
|
||||
(ix86_expand_split_stack_prologue): Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 68 ++++++++++----------------------------------------
|
||||
gcc/config/i386/i386.h | 53 ++++++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 65 insertions(+), 56 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 8b5faac5129..a1ff32b648b 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -2434,53 +2434,6 @@ struct GTY(()) stack_local_entry {
|
||||
struct stack_local_entry *next;
|
||||
};
|
||||
|
||||
-/* Structure describing stack frame layout.
|
||||
- Stack grows downward:
|
||||
-
|
||||
- [arguments]
|
||||
- <- ARG_POINTER
|
||||
- saved pc
|
||||
-
|
||||
- saved static chain if ix86_static_chain_on_stack
|
||||
-
|
||||
- saved frame pointer if frame_pointer_needed
|
||||
- <- HARD_FRAME_POINTER
|
||||
- [saved regs]
|
||||
- <- regs_save_offset
|
||||
- [padding0]
|
||||
-
|
||||
- [saved SSE regs]
|
||||
- <- sse_regs_save_offset
|
||||
- [padding1] |
|
||||
- | <- FRAME_POINTER
|
||||
- [va_arg registers] |
|
||||
- |
|
||||
- [frame] |
|
||||
- |
|
||||
- [padding2] | = to_allocate
|
||||
- <- STACK_POINTER
|
||||
- */
|
||||
-struct ix86_frame
|
||||
-{
|
||||
- int nsseregs;
|
||||
- int nregs;
|
||||
- int va_arg_size;
|
||||
- int red_zone_size;
|
||||
- int outgoing_arguments_size;
|
||||
-
|
||||
- /* The offsets relative to ARG_POINTER. */
|
||||
- HOST_WIDE_INT frame_pointer_offset;
|
||||
- HOST_WIDE_INT hard_frame_pointer_offset;
|
||||
- HOST_WIDE_INT stack_pointer_offset;
|
||||
- HOST_WIDE_INT hfp_save_offset;
|
||||
- HOST_WIDE_INT reg_save_offset;
|
||||
- HOST_WIDE_INT sse_reg_save_offset;
|
||||
-
|
||||
- /* When save_regs_using_mov is set, emit prologue using
|
||||
- move instead of push instructions. */
|
||||
- bool save_regs_using_mov;
|
||||
-};
|
||||
-
|
||||
/* Which cpu are we scheduling for. */
|
||||
enum attr_cpu ix86_schedule;
|
||||
|
||||
@@ -2572,7 +2525,7 @@ static unsigned int ix86_function_arg_boundary (machine_mode,
|
||||
const_tree);
|
||||
static rtx ix86_static_chain (const_tree, bool);
|
||||
static int ix86_function_regparm (const_tree, const_tree);
|
||||
-static void ix86_compute_frame_layout (struct ix86_frame *);
|
||||
+static void ix86_compute_frame_layout (void);
|
||||
static bool ix86_expand_vector_init_one_nonzero (bool, machine_mode,
|
||||
rtx, rtx, int);
|
||||
static void ix86_add_new_builtins (HOST_WIDE_INT);
|
||||
@@ -10944,7 +10897,8 @@ ix86_can_use_return_insn_p (void)
|
||||
if (crtl->args.pops_args && crtl->args.size >= 32768)
|
||||
return 0;
|
||||
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = cfun->machine->frame;
|
||||
return (frame.stack_pointer_offset == UNITS_PER_WORD
|
||||
&& (frame.nregs + frame.nsseregs) == 0);
|
||||
}
|
||||
@@ -11355,8 +11309,8 @@ ix86_can_eliminate (const int from, const int to)
|
||||
HOST_WIDE_INT
|
||||
ix86_initial_elimination_offset (int from, int to)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ struct ix86_frame frame = cfun->machine->frame;
|
||||
|
||||
if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
|
||||
return frame.hard_frame_pointer_offset;
|
||||
@@ -11395,8 +11349,9 @@ ix86_builtin_setjmp_frame_value (void)
|
||||
/* Fill structure ix86_frame about frame of currently computed function. */
|
||||
|
||||
static void
|
||||
-ix86_compute_frame_layout (struct ix86_frame *frame)
|
||||
+ix86_compute_frame_layout (void)
|
||||
{
|
||||
+ struct ix86_frame *frame = &cfun->machine->frame;
|
||||
unsigned HOST_WIDE_INT stack_alignment_needed;
|
||||
HOST_WIDE_INT offset;
|
||||
unsigned HOST_WIDE_INT preferred_alignment;
|
||||
@@ -12702,7 +12657,8 @@ ix86_expand_prologue (void)
|
||||
m->fs.sp_offset = INCOMING_FRAME_SP_OFFSET;
|
||||
m->fs.sp_valid = true;
|
||||
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = m->frame;
|
||||
|
||||
if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
|
||||
{
|
||||
@@ -13379,7 +13335,8 @@ ix86_expand_epilogue (int style)
|
||||
bool using_drap;
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = m->frame;
|
||||
|
||||
m->fs.sp_valid = (!frame_pointer_needed
|
||||
|| (crtl->sp_is_unchanging
|
||||
@@ -13876,7 +13833,8 @@ ix86_expand_split_stack_prologue (void)
|
||||
gcc_assert (flag_split_stack && reload_completed);
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
- ix86_compute_frame_layout (&frame);
|
||||
+ ix86_compute_frame_layout ();
|
||||
+ frame = cfun->machine->frame;
|
||||
allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
|
||||
|
||||
/* This is the label we will branch to if we have enough stack
|
||||
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
|
||||
index 8113f83c7fd..54144166172 100644
|
||||
--- a/gcc/config/i386/i386.h
|
||||
+++ b/gcc/config/i386/i386.h
|
||||
@@ -2427,9 +2427,56 @@ enum avx_u128_state
|
||||
|
||||
#define FASTCALL_PREFIX '@'
|
||||
|
||||
+#ifndef USED_FOR_TARGET
|
||||
+/* Structure describing stack frame layout.
|
||||
+ Stack grows downward:
|
||||
+
|
||||
+ [arguments]
|
||||
+ <- ARG_POINTER
|
||||
+ saved pc
|
||||
+
|
||||
+ saved static chain if ix86_static_chain_on_stack
|
||||
+
|
||||
+ saved frame pointer if frame_pointer_needed
|
||||
+ <- HARD_FRAME_POINTER
|
||||
+ [saved regs]
|
||||
+ <- regs_save_offset
|
||||
+ [padding0]
|
||||
+
|
||||
+ [saved SSE regs]
|
||||
+ <- sse_regs_save_offset
|
||||
+ [padding1] |
|
||||
+ | <- FRAME_POINTER
|
||||
+ [va_arg registers] |
|
||||
+ |
|
||||
+ [frame] |
|
||||
+ |
|
||||
+ [padding2] | = to_allocate
|
||||
+ <- STACK_POINTER
|
||||
+ */
|
||||
+struct GTY(()) ix86_frame
|
||||
+{
|
||||
+ int nsseregs;
|
||||
+ int nregs;
|
||||
+ int va_arg_size;
|
||||
+ int red_zone_size;
|
||||
+ int outgoing_arguments_size;
|
||||
+
|
||||
+ /* The offsets relative to ARG_POINTER. */
|
||||
+ HOST_WIDE_INT frame_pointer_offset;
|
||||
+ HOST_WIDE_INT hard_frame_pointer_offset;
|
||||
+ HOST_WIDE_INT stack_pointer_offset;
|
||||
+ HOST_WIDE_INT hfp_save_offset;
|
||||
+ HOST_WIDE_INT reg_save_offset;
|
||||
+ HOST_WIDE_INT sse_reg_save_offset;
|
||||
+
|
||||
+ /* When save_regs_using_mov is set, emit prologue using
|
||||
+ move instead of push instructions. */
|
||||
+ bool save_regs_using_mov;
|
||||
+};
|
||||
+
|
||||
/* Machine specific frame tracking during prologue/epilogue generation. */
|
||||
|
||||
-#ifndef USED_FOR_TARGET
|
||||
struct GTY(()) machine_frame_state
|
||||
{
|
||||
/* This pair tracks the currently active CFA as reg+offset. When reg
|
||||
@@ -2475,6 +2522,9 @@ struct GTY(()) machine_function {
|
||||
int varargs_fpr_size;
|
||||
int optimize_mode_switching[MAX_386_ENTITIES];
|
||||
|
||||
+ /* Cached initial frame layout for the current function. */
|
||||
+ struct ix86_frame frame;
|
||||
+
|
||||
/* Number of saved registers USE_FAST_PROLOGUE_EPILOGUE
|
||||
has been computed for. */
|
||||
int use_fast_prologue_epilogue_nregs;
|
||||
@@ -2554,6 +2604,7 @@ struct GTY(()) machine_function {
|
||||
#define ix86_current_function_calls_tls_descriptor \
|
||||
(ix86_tls_descriptor_calls_expanded_in_cfun && df_regs_ever_live_p (SP_REG))
|
||||
#define ix86_static_chain_on_stack (cfun->machine->static_chain_on_stack)
|
||||
+#define ix86_red_zone_size (cfun->machine->frame.red_zone_size)
|
||||
|
||||
/* Control behavior of x86_file_start. */
|
||||
#define X86_FILE_START_VERSION_DIRECTIVE false
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
From b1fc91cda7c15264116f3dde6944ead149123653 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 15 Jan 2018 11:28:44 +0000
|
||||
Subject: [PATCH 02/13] i386: Use reference of struct ix86_frame to avoid copy
|
||||
|
||||
When there is no need to make a copy of ix86_frame, we can use reference
|
||||
of struct ix86_frame to avoid copy.
|
||||
|
||||
Backport from mainline
|
||||
2017-11-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_can_use_return_insn_p): Use reference
|
||||
of struct ix86_frame.
|
||||
(ix86_initial_elimination_offset): Likewise.
|
||||
(ix86_expand_split_stack_prologue): Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 8 +++-----
|
||||
1 file changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index a1ff32b648b..13ebf107e90 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -10887,7 +10887,6 @@ symbolic_reference_mentioned_p (rtx op)
|
||||
bool
|
||||
ix86_can_use_return_insn_p (void)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
|
||||
if (! reload_completed || frame_pointer_needed)
|
||||
return 0;
|
||||
@@ -10898,7 +10897,7 @@ ix86_can_use_return_insn_p (void)
|
||||
return 0;
|
||||
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
return (frame.stack_pointer_offset == UNITS_PER_WORD
|
||||
&& (frame.nregs + frame.nsseregs) == 0);
|
||||
}
|
||||
@@ -11310,7 +11309,7 @@ HOST_WIDE_INT
|
||||
ix86_initial_elimination_offset (int from, int to)
|
||||
{
|
||||
ix86_compute_frame_layout ();
|
||||
- struct ix86_frame frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
|
||||
return frame.hard_frame_pointer_offset;
|
||||
@@ -13821,7 +13820,6 @@ static GTY(()) rtx split_stack_fn_large;
|
||||
void
|
||||
ix86_expand_split_stack_prologue (void)
|
||||
{
|
||||
- struct ix86_frame frame;
|
||||
HOST_WIDE_INT allocate;
|
||||
unsigned HOST_WIDE_INT args_size;
|
||||
rtx_code_label *label;
|
||||
@@ -13834,7 +13832,7 @@ ix86_expand_split_stack_prologue (void)
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = cfun->machine->frame;
|
||||
+ struct ix86_frame &frame = cfun->machine->frame;
|
||||
allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
|
||||
|
||||
/* This is the label we will branch to if we have enough stack
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
From 3e39c0a8053b3e960cf4c3aea3c814e7dc97cfd6 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Sat, 27 Jan 2018 13:10:24 +0000
|
||||
Subject: [PATCH 03/13] i386: Use const reference of struct ix86_frame to avoid
|
||||
copy
|
||||
|
||||
We can use const reference of struct ix86_frame to avoid making a local
|
||||
copy of ix86_frame. ix86_expand_epilogue makes a local copy of struct
|
||||
ix86_frame and uses the reg_save_offset field as a local variable. This
|
||||
patch uses a separate local variable for reg_save_offset.
|
||||
|
||||
Tested on x86-64 with ada.
|
||||
|
||||
Backport from mainline
|
||||
PR target/83905
|
||||
* config/i386/i386.c (ix86_expand_prologue): Use cost reference
|
||||
of struct ix86_frame.
|
||||
(ix86_expand_epilogue): Likewise. Add a local variable for
|
||||
the reg_save_offset field in struct ix86_frame.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257123 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 24 ++++++++++++------------
|
||||
1 file changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 13ebf107e90..6c98f7581e2 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -12633,7 +12633,6 @@ ix86_expand_prologue (void)
|
||||
{
|
||||
struct machine_function *m = cfun->machine;
|
||||
rtx insn, t;
|
||||
- struct ix86_frame frame;
|
||||
HOST_WIDE_INT allocate;
|
||||
bool int_registers_saved;
|
||||
bool sse_registers_saved;
|
||||
@@ -12657,7 +12656,7 @@ ix86_expand_prologue (void)
|
||||
m->fs.sp_valid = true;
|
||||
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = m->frame;
|
||||
+ const struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
|
||||
{
|
||||
@@ -13329,13 +13328,12 @@ ix86_expand_epilogue (int style)
|
||||
{
|
||||
struct machine_function *m = cfun->machine;
|
||||
struct machine_frame_state frame_state_save = m->fs;
|
||||
- struct ix86_frame frame;
|
||||
bool restore_regs_via_mov;
|
||||
bool using_drap;
|
||||
|
||||
ix86_finalize_stack_realign_flags ();
|
||||
ix86_compute_frame_layout ();
|
||||
- frame = m->frame;
|
||||
+ const struct ix86_frame &frame = cfun->machine->frame;
|
||||
|
||||
m->fs.sp_valid = (!frame_pointer_needed
|
||||
|| (crtl->sp_is_unchanging
|
||||
@@ -13377,11 +13375,13 @@ ix86_expand_epilogue (int style)
|
||||
+ UNITS_PER_WORD);
|
||||
}
|
||||
|
||||
+ HOST_WIDE_INT reg_save_offset = frame.reg_save_offset;
|
||||
+
|
||||
/* Special care must be taken for the normal return case of a function
|
||||
using eh_return: the eax and edx registers are marked as saved, but
|
||||
not restored along this path. Adjust the save location to match. */
|
||||
if (crtl->calls_eh_return && style != 2)
|
||||
- frame.reg_save_offset -= 2 * UNITS_PER_WORD;
|
||||
+ reg_save_offset -= 2 * UNITS_PER_WORD;
|
||||
|
||||
/* EH_RETURN requires the use of moves to function properly. */
|
||||
if (crtl->calls_eh_return)
|
||||
@@ -13397,11 +13397,11 @@ ix86_expand_epilogue (int style)
|
||||
else if (TARGET_EPILOGUE_USING_MOVE
|
||||
&& cfun->machine->use_fast_prologue_epilogue
|
||||
&& (frame.nregs > 1
|
||||
- || m->fs.sp_offset != frame.reg_save_offset))
|
||||
+ || m->fs.sp_offset != reg_save_offset))
|
||||
restore_regs_via_mov = true;
|
||||
else if (frame_pointer_needed
|
||||
&& !frame.nregs
|
||||
- && m->fs.sp_offset != frame.reg_save_offset)
|
||||
+ && m->fs.sp_offset != reg_save_offset)
|
||||
restore_regs_via_mov = true;
|
||||
else if (frame_pointer_needed
|
||||
&& TARGET_USE_LEAVE
|
||||
@@ -13439,7 +13439,7 @@ ix86_expand_epilogue (int style)
|
||||
rtx t;
|
||||
|
||||
if (frame.nregs)
|
||||
- ix86_emit_restore_regs_using_mov (frame.reg_save_offset, style == 2);
|
||||
+ ix86_emit_restore_regs_using_mov (reg_save_offset, style == 2);
|
||||
|
||||
/* eh_return epilogues need %ecx added to the stack pointer. */
|
||||
if (style == 2)
|
||||
@@ -13529,19 +13529,19 @@ ix86_expand_epilogue (int style)
|
||||
epilogues. */
|
||||
if (!m->fs.sp_valid
|
||||
|| (TARGET_SEH
|
||||
- && (m->fs.sp_offset - frame.reg_save_offset
|
||||
+ && (m->fs.sp_offset - reg_save_offset
|
||||
>= SEH_MAX_FRAME_SIZE)))
|
||||
{
|
||||
pro_epilogue_adjust_stack (stack_pointer_rtx, hard_frame_pointer_rtx,
|
||||
GEN_INT (m->fs.fp_offset
|
||||
- - frame.reg_save_offset),
|
||||
+ - reg_save_offset),
|
||||
style, false);
|
||||
}
|
||||
- else if (m->fs.sp_offset != frame.reg_save_offset)
|
||||
+ else if (m->fs.sp_offset != reg_save_offset)
|
||||
{
|
||||
pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
|
||||
GEN_INT (m->fs.sp_offset
|
||||
- - frame.reg_save_offset),
|
||||
+ - reg_save_offset),
|
||||
style,
|
||||
m->fs.cfa_reg == stack_pointer_rtx);
|
||||
}
|
||||
--
|
||||
2.16.3
|
||||
|
2149
cross/gcc-x86_64/0004-x86-Add-mindirect-branch.patch
Normal file
2149
cross/gcc-x86_64/0004-x86-Add-mindirect-branch.patch
Normal file
File diff suppressed because it is too large
Load diff
1565
cross/gcc-x86_64/0005-x86-Add-mfunction-return.patch
Normal file
1565
cross/gcc-x86_64/0005-x86-Add-mfunction-return.patch
Normal file
File diff suppressed because it is too large
Load diff
941
cross/gcc-x86_64/0006-x86-Add-mindirect-branch-register.patch
Normal file
941
cross/gcc-x86_64/0006-x86-Add-mindirect-branch-register.patch
Normal file
|
@ -0,0 +1,941 @@
|
|||
From 61bb7f0e152ce5be700a44007d036ea0de4b254d Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 6 Jan 2018 22:29:56 -0800
|
||||
Subject: [PATCH 06/13] x86: Add -mindirect-branch-register
|
||||
|
||||
Add -mindirect-branch-register to force indirect branch via register.
|
||||
This is implemented by disabling patterns of indirect branch via memory,
|
||||
similar to TARGET_X32.
|
||||
|
||||
-mindirect-branch= and -mfunction-return= tests are updated with
|
||||
-mno-indirect-branch-register to avoid false test failures when
|
||||
-mindirect-branch-register is added to RUNTESTFLAGS for "make check".
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Disallow memory operand for
|
||||
-mindirect-branch-register.
|
||||
(Bw): Likewise.
|
||||
* config/i386/predicates.md (indirect_branch_operand): Likewise.
|
||||
(GOT_memory_operand): Likewise.
|
||||
(call_insn_operand): Likewise.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
* config/i386/i386.md (indirect_jump): Call convert_memory_address
|
||||
for -mindirect-branch-register.
|
||||
(tablejump): Likewise.
|
||||
(*sibcall_memory): Likewise.
|
||||
(*sibcall_value_memory): Likewise.
|
||||
Disallow peepholes of indirect call and jump via memory for
|
||||
-mindirect-branch-register.
|
||||
(*call_pop): Replace m with Bw.
|
||||
(*call_value_pop): Likewise.
|
||||
(*sibcall_pop_memory): Replace m with Bs.
|
||||
* config/i386/i386.opt (mindirect-branch-register): New option.
|
||||
* doc/invoke.texi: Document -mindirect-branch-register option.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-1.c (dg-options): Add
|
||||
-mno-indirect-branch-register.
|
||||
* gcc.target/i386/indirect-thunk-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-bnd-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-extern-7.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-1.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-3.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-4.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-5.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-6.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-inline-7.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-10.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-11.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-12.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-13.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-14.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-15.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-9.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-register-1.c: New test.
|
||||
* gcc.target/i386/indirect-thunk-register-2.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-register-3.c: Likewise.
|
||||
|
||||
i386: Rename to ix86_indirect_branch_register
|
||||
|
||||
Rename the variable for -mindirect-branch-register to
|
||||
ix86_indirect_branch_register to match the command-line option name.
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Replace
|
||||
ix86_indirect_branch_thunk_register with
|
||||
ix86_indirect_branch_register.
|
||||
(Bw): Likewise.
|
||||
* config/i386/i386.md (indirect_jump): Likewise.
|
||||
(tablejump): Likewise.
|
||||
(*sibcall_memory): Likewise.
|
||||
(*sibcall_value_memory): Likewise.
|
||||
Peepholes of indirect call and jump via memory: Likewise.
|
||||
* config/i386/i386.opt: Likewise.
|
||||
* config/i386/predicates.md (indirect_branch_operand): Likewise.
|
||||
(GOT_memory_operand): Likewise.
|
||||
(call_insn_operand): Likewise.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
|
||||
x86: Rewrite ix86_indirect_branch_register logic
|
||||
|
||||
Rewrite ix86_indirect_branch_register logic with
|
||||
|
||||
(and (not (match_test "ix86_indirect_branch_register"))
|
||||
(original condition before r256662))
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/predicates.md (constant_call_address_operand):
|
||||
Rewrite ix86_indirect_branch_register logic.
|
||||
(sibcall_insn_operand): Likewise.
|
||||
|
||||
Don't check ix86_indirect_branch_register for GOT operand
|
||||
|
||||
Since GOT_memory_operand and GOT32_symbol_operand are simple pattern
|
||||
matches, don't check ix86_indirect_branch_register here. If needed,
|
||||
-mindirect-branch= will convert indirect branch via GOT slot to a call
|
||||
and return thunk.
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/constraints.md (Bs): Update
|
||||
ix86_indirect_branch_register check. Don't check
|
||||
ix86_indirect_branch_register with GOT_memory_operand.
|
||||
(Bw): Likewise.
|
||||
* config/i386/predicates.md (GOT_memory_operand): Don't check
|
||||
ix86_indirect_branch_register here.
|
||||
(GOT32_symbol_operand): Likewise.
|
||||
|
||||
i386: Rewrite indirect_branch_operand logic
|
||||
|
||||
Backport from mainline
|
||||
2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/predicates.md (indirect_branch_operand): Rewrite
|
||||
ix86_indirect_branch_register logic.
|
||||
---
|
||||
gcc/config/i386/constraints.md | 6 ++--
|
||||
gcc/config/i386/i386.md | 34 ++++++++++++++--------
|
||||
gcc/config/i386/i386.opt | 4 +++
|
||||
gcc/config/i386/predicates.md | 21 +++++++------
|
||||
gcc/doc/invoke.texi | 6 +++-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-1.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-2.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-3.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-4.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-5.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-6.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-attr-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-bnd-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-extern-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-1.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-2.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-3.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-4.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-5.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-6.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-inline-7.c | 2 +-
|
||||
.../gcc.target/i386/indirect-thunk-register-1.c | 22 ++++++++++++++
|
||||
.../gcc.target/i386/indirect-thunk-register-2.c | 20 +++++++++++++
|
||||
.../gcc.target/i386/indirect-thunk-register-3.c | 19 ++++++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-10.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-11.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-12.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-13.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-14.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-15.c | 2 +-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 2 +-
|
||||
47 files changed, 147 insertions(+), 63 deletions(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
|
||||
diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
|
||||
index 1a4c701ad13..9204c8e8487 100644
|
||||
--- a/gcc/config/i386/constraints.md
|
||||
+++ b/gcc/config/i386/constraints.md
|
||||
@@ -172,14 +172,16 @@
|
||||
|
||||
(define_constraint "Bs"
|
||||
"@internal Sibcall memory operand."
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (ior (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "sibcall_memory_operand"))
|
||||
(and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
(match_operand 0 "GOT_memory_operand"))))
|
||||
|
||||
(define_constraint "Bw"
|
||||
"@internal Call memory operand."
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (ior (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "memory_operand"))
|
||||
(and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
(match_operand 0 "GOT_memory_operand"))))
|
||||
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
||||
index 2da671e9f2d..05a88fff356 100644
|
||||
--- a/gcc/config/i386/i386.md
|
||||
+++ b/gcc/config/i386/i386.md
|
||||
@@ -11805,7 +11805,7 @@
|
||||
[(set (pc) (match_operand 0 "indirect_branch_operand"))]
|
||||
""
|
||||
{
|
||||
- if (TARGET_X32)
|
||||
+ if (TARGET_X32 || ix86_indirect_branch_register)
|
||||
operands[0] = convert_memory_address (word_mode, operands[0]);
|
||||
cfun->machine->has_local_indirect_jump = true;
|
||||
})
|
||||
@@ -11859,7 +11859,7 @@
|
||||
OPTAB_DIRECT);
|
||||
}
|
||||
|
||||
- if (TARGET_X32)
|
||||
+ if (TARGET_X32 || ix86_indirect_branch_register)
|
||||
operands[0] = convert_memory_address (word_mode, operands[0]);
|
||||
cfun->machine->has_local_indirect_jump = true;
|
||||
})
|
||||
@@ -12048,7 +12048,7 @@
|
||||
[(call (mem:QI (match_operand:W 0 "memory_operand" "m"))
|
||||
(match_operand 1))
|
||||
(unspec [(const_int 0)] UNSPEC_PEEPSIB)]
|
||||
- "!TARGET_X32"
|
||||
+ "!TARGET_X32 && !ix86_indirect_branch_register"
|
||||
"* return ix86_output_call_insn (insn, operands[0]);"
|
||||
[(set_attr "type" "call")])
|
||||
|
||||
@@ -12057,7 +12057,9 @@
|
||||
(match_operand:W 1 "memory_operand"))
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
|
||||
[(parallel [(call (mem:QI (match_dup 1))
|
||||
@@ -12070,7 +12072,9 @@
|
||||
(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
|
||||
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
@@ -12092,7 +12096,7 @@
|
||||
})
|
||||
|
||||
(define_insn "*call_pop"
|
||||
- [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lmBz"))
|
||||
+ [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lBwBz"))
|
||||
(match_operand 1))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
@@ -12112,7 +12116,7 @@
|
||||
[(set_attr "type" "call")])
|
||||
|
||||
(define_insn "*sibcall_pop_memory"
|
||||
- [(call (mem:QI (match_operand:SI 0 "memory_operand" "m"))
|
||||
+ [(call (mem:QI (match_operand:SI 0 "memory_operand" "Bs"))
|
||||
(match_operand 1))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
@@ -12166,7 +12170,9 @@
|
||||
[(set (match_operand:W 0 "register_operand")
|
||||
(match_operand:W 1 "memory_operand"))
|
||||
(set (pc) (match_dup 0))]
|
||||
- "!TARGET_X32 && peep2_reg_dead_p (2, operands[0])"
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && peep2_reg_dead_p (2, operands[0])"
|
||||
[(set (pc) (match_dup 1))])
|
||||
|
||||
;; Call subroutine, returning value in operand 0
|
||||
@@ -12244,7 +12250,7 @@
|
||||
(call (mem:QI (match_operand:W 1 "memory_operand" "m"))
|
||||
(match_operand 2)))
|
||||
(unspec [(const_int 0)] UNSPEC_PEEPSIB)]
|
||||
- "!TARGET_X32"
|
||||
+ "!TARGET_X32 && !ix86_indirect_branch_register"
|
||||
"* return ix86_output_call_insn (insn, operands[1]);"
|
||||
[(set_attr "type" "callv")])
|
||||
|
||||
@@ -12254,7 +12260,9 @@
|
||||
(set (match_operand 2)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3)))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (1))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
|
||||
[(parallel [(set (match_dup 2)
|
||||
@@ -12269,7 +12277,9 @@
|
||||
(set (match_operand 2)
|
||||
(call (mem:QI (match_dup 0))
|
||||
(match_operand 3)))]
|
||||
- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
+ "!TARGET_X32
|
||||
+ && !ix86_indirect_branch_register
|
||||
+ && SIBLING_CALL_P (peep2_next_insn (2))
|
||||
&& !reg_mentioned_p (operands[0],
|
||||
CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
|
||||
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
|
||||
@@ -12294,7 +12304,7 @@
|
||||
|
||||
(define_insn "*call_value_pop"
|
||||
[(set (match_operand 0)
|
||||
- (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lmBz"))
|
||||
+ (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lBwBz"))
|
||||
(match_operand 2)))
|
||||
(set (reg:SI SP_REG)
|
||||
(plus:SI (reg:SI SP_REG)
|
||||
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
|
||||
index ad5916fb643..a97f84f68f2 100644
|
||||
--- a/gcc/config/i386/i386.opt
|
||||
+++ b/gcc/config/i386/i386.opt
|
||||
@@ -921,3 +921,7 @@ Enum(indirect_branch) String(thunk-inline) Value(indirect_branch_thunk_inline)
|
||||
|
||||
EnumValue
|
||||
Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
|
||||
+
|
||||
+mindirect-branch-register
|
||||
+Target Report Var(ix86_indirect_branch_register) Init(0)
|
||||
+Force indirect call and jump via register.
|
||||
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
|
||||
index 93dda7bb0e7..d1f0a7dbf61 100644
|
||||
--- a/gcc/config/i386/predicates.md
|
||||
+++ b/gcc/config/i386/predicates.md
|
||||
@@ -593,7 +593,8 @@
|
||||
;; Test for a valid operand for indirect branch.
|
||||
(define_predicate "indirect_branch_operand"
|
||||
(ior (match_operand 0 "register_operand")
|
||||
- (and (not (match_test "TARGET_X32"))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (not (match_test "TARGET_X32"))
|
||||
(match_operand 0 "memory_operand"))))
|
||||
|
||||
;; Return true if OP is a memory operands that can be used in sibcalls.
|
||||
@@ -636,20 +637,22 @@
|
||||
(ior (match_test "constant_call_address_operand
|
||||
(op, mode == VOIDmode ? mode : Pmode)")
|
||||
(match_operand 0 "call_register_no_elim_operand")
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
- (match_operand 0 "memory_operand"))
|
||||
- (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
- (match_operand 0 "GOT_memory_operand")))))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (match_operand 0 "memory_operand"))
|
||||
+ (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
+ (match_operand 0 "GOT_memory_operand"))))))
|
||||
|
||||
;; Similarly, but for tail calls, in which we cannot allow memory references.
|
||||
(define_special_predicate "sibcall_insn_operand"
|
||||
(ior (match_test "constant_call_address_operand
|
||||
(op, mode == VOIDmode ? mode : Pmode)")
|
||||
(match_operand 0 "register_no_elim_operand")
|
||||
- (ior (and (not (match_test "TARGET_X32"))
|
||||
- (match_operand 0 "sibcall_memory_operand"))
|
||||
- (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
- (match_operand 0 "GOT_memory_operand")))))
|
||||
+ (and (not (match_test "ix86_indirect_branch_register"))
|
||||
+ (ior (and (not (match_test "TARGET_X32"))
|
||||
+ (match_operand 0 "sibcall_memory_operand"))
|
||||
+ (and (match_test "TARGET_X32 && Pmode == DImode")
|
||||
+ (match_operand 0 "GOT_memory_operand"))))))
|
||||
|
||||
;; Return true if OP is a 32-bit GOT symbol operand.
|
||||
(define_predicate "GOT32_symbol_operand"
|
||||
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
|
||||
index 337a761015a..94374661f2d 100644
|
||||
--- a/gcc/doc/invoke.texi
|
||||
+++ b/gcc/doc/invoke.texi
|
||||
@@ -1170,7 +1170,7 @@ See RS/6000 and PowerPC Options.
|
||||
-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
|
||||
-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
|
||||
-mmitigate-rop -mindirect-branch=@var{choice} @gol
|
||||
--mfunction-return=@var{choice}}
|
||||
+-mfunction-return=@var{choice} -mindirect-branch-register}
|
||||
|
||||
@emph{x86 Windows Options}
|
||||
@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
|
||||
@@ -24253,6 +24253,10 @@ object file. You can control this behavior for a specific function by
|
||||
using the function attribute @code{function_return}.
|
||||
@xref{Function Attributes}.
|
||||
|
||||
+@item -mindirect-branch-register
|
||||
+@opindex -mindirect-branch-register
|
||||
+Force indirect call and jump via register.
|
||||
+
|
||||
@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 e365ef5698a..60d09881a99 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 05a51ad9157..aac75163794 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 3c0d4c39f0b..9e24a385387 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -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 14d4ef6dd98..127b5d94523 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
typedef void (*dispatch_t)(long offset);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
index b4836c38d6c..fcaa18d10b7 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
index 1f06bd1af74..e4649283d10 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
|
||||
index bc6b47a636e..17c2d0faf88 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 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 2257be3affa..9194ccf3cbc 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 e9cfdc5879e..e51f261a612 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 f938db050f7..4aeec1833cd 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 4e58599692a..ac0e5999f63 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 b8d50249d8b..573cf1ef09e 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 455adabfe0e..b2b37fc6e2e 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 4595b841ec0..4a43e199931 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 -mfunction-return=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
|
||||
|
||||
void func0 (void);
|
||||
void func1 (void);
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
index 5e3e118e9bd..ac84ab623fa 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { ! x32 } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
|
||||
void (*dispatch) (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
index 2801aa4192e..ce655e8be1c 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { ! x32 } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
|
||||
void (*dispatch) (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
index 70b4fb36eea..d34485a0010 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
|
||||
void bar (char *);
|
||||
char buf[10];
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
index 3baf03ee77c..0e19830de4d 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */
|
||||
|
||||
void bar (char *);
|
||||
char buf[10];
|
||||
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 edeb264218c..579441f250e 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 1d00413a76a..c92e6f2b02d 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 06ebf1c9063..d9964c25bbd 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 1c8f9446636..d4dca4dc5fe 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
index 21740ac5b7f..5c07e02df6a 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
index a77c1f470b8..3eb440693a0 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
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 86e9fd1f1e4..aece9383697 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 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 3ecde878867..3aba5e8c81f 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 df32a19a2b5..0f0181d6672 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 9540996de01..2eef6f35a75 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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 f3db6e2441f..e825a10f14c 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -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-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
index 0f687c3b027..c6d77e10352 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
index b27c6fc96a2..6454827b780 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile { target *-*-linux* } } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */
|
||||
|
||||
extern void bar (void);
|
||||
|
||||
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 764a375fc37..c67066cf197 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 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
|
||||
void func0 (void);
|
||||
void func1 (void);
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
new file mode 100644
|
||||
index 00000000000..7d396a31953
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
|
||||
@@ -0,0 +1,22 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */
|
||||
+/* { dg-final { scan-assembler {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk\n" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk_bnd\n" } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
new file mode 100644
|
||||
index 00000000000..e7e616bb271
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
|
||||
@@ -0,0 +1,20 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */
|
||||
+/* { dg-final { scan-assembler {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
new file mode 100644
|
||||
index 00000000000..5320e923be2
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
|
||||
@@ -0,0 +1,19 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mindirect-branch-register -fno-pic" } */
|
||||
+
|
||||
+typedef void (*dispatch_t)(long offset);
|
||||
+
|
||||
+dispatch_t dispatch;
|
||||
+
|
||||
+void
|
||||
+male_indirect_jump (long offset)
|
||||
+{
|
||||
+ dispatch(offset);
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */
|
||||
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */
|
||||
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
|
||||
+/* { dg-final { scan-assembler-not {\t(pause|pause|nop)} } } */
|
||||
+/* { 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-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
index 3a6727b5c54..e6fea84a4d9 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
index b8f68188313..e239ec4542f 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
index 01b0a02f80b..fa3181303c9 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
index 4b497b5f8af..fd5b41fdd3f 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
extern int foo (void) __attribute__ ((function_return("thunk")));
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
index 4ae4c44a3fd..d606373ead1 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
index 5b5bc765a7e..75e45e226b8 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
index fa24a1f7365..d1db41cc128 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
-/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
|
||||
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
|
||||
|
||||
extern void (*bar) (void);
|
||||
|
||||
--
|
||||
2.16.3
|
||||
|
134
cross/gcc-x86_64/0007-x86-Add-V-register-operand-modifier.patch
Normal file
134
cross/gcc-x86_64/0007-x86-Add-V-register-operand-modifier.patch
Normal file
|
@ -0,0 +1,134 @@
|
|||
From 92308185917678406afee3c165ea5e71b53b3cc1 Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 6 Jan 2018 22:29:56 -0800
|
||||
Subject: [PATCH 07/13] x86: Add 'V' register operand modifier
|
||||
|
||||
Add 'V', a special modifier which prints the name of the full integer
|
||||
register without '%'. For
|
||||
|
||||
extern void (*func_p) (void);
|
||||
|
||||
void
|
||||
foo (void)
|
||||
{
|
||||
asm ("call __x86_indirect_thunk_%V0" : : "a" (func_p));
|
||||
}
|
||||
|
||||
it generates:
|
||||
|
||||
foo:
|
||||
movq func_p(%rip), %rax
|
||||
call __x86_indirect_thunk_rax
|
||||
ret
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (print_reg): Print the name of the full
|
||||
integer register without '%'.
|
||||
(ix86_print_operand): Handle 'V'.
|
||||
* doc/extend.texi: Document 'V' modifier.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-register-4.c: New test.
|
||||
---
|
||||
gcc/config/i386/i386.c | 13 ++++++++++++-
|
||||
gcc/doc/extend.texi | 3 +++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c | 13 +++++++++++++
|
||||
3 files changed, 28 insertions(+), 1 deletion(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 34e26a3a3c7..eeca7e5e490 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -16869,6 +16869,7 @@ put_condition_code (enum rtx_code code, machine_mode mode, bool reverse,
|
||||
If CODE is 'h', pretend the reg is the 'high' byte register.
|
||||
If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.
|
||||
If CODE is 'd', duplicate the operand for AVX instruction.
|
||||
+ If CODE is 'V', print naked full integer register name without %.
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -16879,7 +16880,7 @@ print_reg (rtx x, int code, FILE *file)
|
||||
unsigned int regno;
|
||||
bool duplicated;
|
||||
|
||||
- if (ASSEMBLER_DIALECT == ASM_ATT)
|
||||
+ if (ASSEMBLER_DIALECT == ASM_ATT && code != 'V')
|
||||
putc ('%', file);
|
||||
|
||||
if (x == pc_rtx)
|
||||
@@ -16922,6 +16923,14 @@ print_reg (rtx x, int code, FILE *file)
|
||||
&& regno != FPSR_REG
|
||||
&& regno != FPCR_REG);
|
||||
|
||||
+ if (code == 'V')
|
||||
+ {
|
||||
+ if (GENERAL_REGNO_P (regno))
|
||||
+ msize = GET_MODE_SIZE (word_mode);
|
||||
+ else
|
||||
+ error ("'V' modifier on non-integer register");
|
||||
+ }
|
||||
+
|
||||
duplicated = code == 'd' && TARGET_AVX;
|
||||
|
||||
switch (msize)
|
||||
@@ -17035,6 +17044,7 @@ print_reg (rtx x, int code, FILE *file)
|
||||
& -- print some in-use local-dynamic symbol name.
|
||||
H -- print a memory address offset by 8; used for sse high-parts
|
||||
Y -- print condition for XOP pcom* instruction.
|
||||
+ V -- print naked full integer register name without %.
|
||||
+ -- print a branch hint as 'cs' or 'ds' prefix
|
||||
; -- print a semicolon (after prefixes due to bug in older gas).
|
||||
~ -- print "i" if TARGET_AVX2, "f" otherwise.
|
||||
@@ -17259,6 +17269,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
|
||||
case 'X':
|
||||
case 'P':
|
||||
case 'p':
|
||||
+ case 'V':
|
||||
break;
|
||||
|
||||
case 's':
|
||||
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
|
||||
index 2cb6bd1ef3e..76ba1d4f913 100644
|
||||
--- a/gcc/doc/extend.texi
|
||||
+++ b/gcc/doc/extend.texi
|
||||
@@ -8511,6 +8511,9 @@ The table below shows the list of supported modifiers and their effects.
|
||||
@tab @code{2}
|
||||
@end multitable
|
||||
|
||||
+@code{V} is a special modifier which prints the name of the full integer
|
||||
+register without @code{%}.
|
||||
+
|
||||
@anchor{x86floatingpointasmoperands}
|
||||
@subsubsection x86 Floating-Point @code{asm} Operands
|
||||
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
new file mode 100644
|
||||
index 00000000000..f0cd9b75be8
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
|
||||
@@ -0,0 +1,13 @@
|
||||
+/* { dg-do compile } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -fno-pic" } */
|
||||
+
|
||||
+extern void (*func_p) (void);
|
||||
+
|
||||
+void
|
||||
+foo (void)
|
||||
+{
|
||||
+ asm("call __x86_indirect_thunk_%V0" : : "a" (func_p));
|
||||
+}
|
||||
+
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_eax" { target ia32 } } } */
|
||||
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_rax" { target { ! ia32 } } } } */
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,299 @@
|
|||
From 087b12213a5b4b8654c70320c671bb05c1b1b012 Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hjl.tools@gmail.com>
|
||||
Date: Sat, 13 Jan 2018 18:01:54 -0800
|
||||
Subject: [PATCH 08/13] x86: Disallow -mindirect-branch=/-mfunction-return=
|
||||
with -mcmodel=large
|
||||
|
||||
Since the thunk function may not be reachable in large code model,
|
||||
-mcmodel=large is incompatible with -mindirect-branch=thunk,
|
||||
-mindirect-branch=thunk-extern, -mfunction-return=thunk and
|
||||
-mfunction-return=thunk-extern. Issue an error when they are used with
|
||||
-mcmodel=large.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_set_indirect_branch_type): Disallow
|
||||
-mcmodel=large with -mindirect-branch=thunk,
|
||||
-mindirect-branch=thunk-extern, -mfunction-return=thunk and
|
||||
-mfunction-return=thunk-extern.
|
||||
* doc/invoke.texi: Document -mcmodel=large is incompatible with
|
||||
-mindirect-branch=thunk, -mindirect-branch=thunk-extern,
|
||||
-mfunction-return=thunk and -mfunction-return=thunk-extern.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* gcc.target/i386/indirect-thunk-10.c: New test.
|
||||
* gcc.target/i386/indirect-thunk-8.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-9.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-10.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-11.c: Likewise.
|
||||
* gcc.target/i386/indirect-thunk-attr-9.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-17.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-18.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-19.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-20.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-21.c: Likewise.
|
||||
---
|
||||
gcc/config/i386/i386.c | 26 ++++++++++++++++++++++
|
||||
gcc/doc/invoke.texi | 11 +++++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-10.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-8.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/indirect-thunk-9.c | 7 ++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-10.c | 9 ++++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-11.c | 9 ++++++++
|
||||
.../gcc.target/i386/indirect-thunk-attr-9.c | 9 ++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-17.c | 7 ++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-18.c | 8 +++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-19.c | 8 +++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-20.c | 9 ++++++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-21.c | 9 ++++++++
|
||||
13 files changed, 126 insertions(+)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index eeca7e5e490..9c038bee000 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -6389,6 +6389,19 @@ ix86_set_indirect_branch_type (tree fndecl)
|
||||
}
|
||||
else
|
||||
cfun->machine->indirect_branch_type = ix86_indirect_branch;
|
||||
+
|
||||
+ /* -mcmodel=large is not compatible with -mindirect-branch=thunk
|
||||
+ nor -mindirect-branch=thunk-extern. */
|
||||
+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
|
||||
+ && ((cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ || (cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk)))
|
||||
+ error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
|
||||
+ "compatible",
|
||||
+ ((cfun->machine->indirect_branch_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ ? "thunk-extern" : "thunk"));
|
||||
}
|
||||
|
||||
if (cfun->machine->function_return_type == indirect_branch_unset)
|
||||
@@ -6414,6 +6427,19 @@ ix86_set_indirect_branch_type (tree fndecl)
|
||||
}
|
||||
else
|
||||
cfun->machine->function_return_type = ix86_function_return;
|
||||
+
|
||||
+ /* -mcmodel=large is not compatible with -mfunction-return=thunk
|
||||
+ nor -mfunction-return=thunk-extern. */
|
||||
+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
|
||||
+ && ((cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ || (cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk)))
|
||||
+ error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
|
||||
+ "compatible",
|
||||
+ ((cfun->machine->function_return_type
|
||||
+ == indirect_branch_thunk_extern)
|
||||
+ ? "thunk-extern" : "thunk"));
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
|
||||
index 94374661f2d..1dee495c86b 100644
|
||||
--- a/gcc/doc/invoke.texi
|
||||
+++ b/gcc/doc/invoke.texi
|
||||
@@ -24242,6 +24242,11 @@ 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}.
|
||||
|
||||
+Note that @option{-mcmodel=large} is incompatible with
|
||||
+@option{-mindirect-branch=thunk} nor
|
||||
+@option{-mindirect-branch=thunk-extern} since the thunk function may
|
||||
+not be reachable in large code model.
|
||||
+
|
||||
@item -mfunction-return=@var{choice}
|
||||
@opindex -mfunction-return
|
||||
Convert function return with @var{choice}. The default is @samp{keep},
|
||||
@@ -24253,6 +24258,12 @@ object file. You can control this behavior for a specific function by
|
||||
using the function attribute @code{function_return}.
|
||||
@xref{Function Attributes}.
|
||||
|
||||
+Note that @option{-mcmodel=large} is incompatible with
|
||||
+@option{-mfunction-return=thunk} nor
|
||||
+@option{-mfunction-return=thunk-extern} since the thunk function may
|
||||
+not be reachable in large code model.
|
||||
+
|
||||
+
|
||||
@item -mindirect-branch-register
|
||||
@opindex -mindirect-branch-register
|
||||
Force indirect call and jump via register.
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
new file mode 100644
|
||||
index 00000000000..a0674bd2363
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
new file mode 100644
|
||||
index 00000000000..7a80a8986e8
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
new file mode 100644
|
||||
index 00000000000..d4d45c5114d
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mfunction-return=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
new file mode 100644
|
||||
index 00000000000..3a2aeaddbc5
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk-extern")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
new file mode 100644
|
||||
index 00000000000..8e52f032b6c
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk-inline")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
new file mode 100644
|
||||
index 00000000000..bdaa4f6911b
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((indirect_branch("thunk")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-17.c b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
new file mode 100644
|
||||
index 00000000000..0605e2c6542
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=keep -mcmodel=large" } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-18.c b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
new file mode 100644
|
||||
index 00000000000..307019dc242
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c
|
||||
@@ -0,0 +1,8 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-19.c b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
new file mode 100644
|
||||
index 00000000000..772617f4010
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c
|
||||
@@ -0,0 +1,8 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-20.c b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
new file mode 100644
|
||||
index 00000000000..1e9f9bd5a66
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk-extern")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */
|
||||
+}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-21.c b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
new file mode 100644
|
||||
index 00000000000..eea07f7abe1
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c
|
||||
@@ -0,0 +1,9 @@
|
||||
+/* { dg-do compile { target { lp64 } } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
|
||||
+/* { dg-additional-options "-fPIC" { target fpic } } */
|
||||
+
|
||||
+__attribute__ ((function_return("thunk-inline")))
|
||||
+void
|
||||
+bar (void)
|
||||
+{
|
||||
+}
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
From 07857bd9fb9ccab67a932ad9df3e53f3f0c2c617 Mon Sep 17 00:00:00 2001
|
||||
From: uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Thu, 25 Jan 2018 19:39:01 +0000
|
||||
Subject: [PATCH 09/13] Use INVALID_REGNUM in indirect thunk processing
|
||||
|
||||
Backport from mainline
|
||||
2018-01-17 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
* config/i386/i386.c (indirect_thunk_name): Declare regno
|
||||
as unsigned int. Compare regno with INVALID_REGNUM.
|
||||
(output_indirect_thunk): Ditto.
|
||||
(output_indirect_thunk_function): Ditto.
|
||||
(ix86_code_end): Declare regno as unsigned int. Use INVALID_REGNUM
|
||||
in the call to output_indirect_thunk_function.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257067 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 30 +++++++++++++++---------------
|
||||
1 file changed, 15 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 9c038bee000..40126579c22 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11087,16 +11087,16 @@ static int indirect_thunks_bnd_used;
|
||||
/* Fills in the label name that should be used for the indirect thunk. */
|
||||
|
||||
static void
|
||||
-indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
- bool ret_p)
|
||||
+indirect_thunk_name (char name[32], unsigned int regno,
|
||||
+ bool need_bnd_p, bool ret_p)
|
||||
{
|
||||
- if (regno >= 0 && ret_p)
|
||||
+ if (regno != INVALID_REGNUM && ret_p)
|
||||
gcc_unreachable ();
|
||||
|
||||
if (USE_HIDDEN_LINKONCE)
|
||||
{
|
||||
const char *bnd = need_bnd_p ? "_bnd" : "";
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
const char *reg_prefix;
|
||||
if (LEGACY_INT_REGNO_P (regno))
|
||||
@@ -11114,7 +11114,7 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
}
|
||||
else
|
||||
{
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
if (need_bnd_p)
|
||||
ASM_GENERATE_INTERNAL_LABEL (name, "LITBR", regno);
|
||||
@@ -11166,7 +11166,7 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
|
||||
*/
|
||||
|
||||
static void
|
||||
-output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
+output_indirect_thunk (bool need_bnd_p, unsigned int regno)
|
||||
{
|
||||
char indirectlabel1[32];
|
||||
char indirectlabel2[32];
|
||||
@@ -11196,7 +11196,7 @@ output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
|
||||
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
|
||||
|
||||
- if (regno >= 0)
|
||||
+ if (regno != INVALID_REGNUM)
|
||||
{
|
||||
/* MOV. */
|
||||
rtx xops[2];
|
||||
@@ -11220,12 +11220,12 @@ output_indirect_thunk (bool need_bnd_p, int regno)
|
||||
}
|
||||
|
||||
/* Output a funtion with a call and return thunk for indirect branch.
|
||||
- If BND_P is true, the BND prefix is needed. If REGNO != -1, the
|
||||
- function address is in REGNO. Otherwise, the function address is
|
||||
+ If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM,
|
||||
+ the function address is in REGNO. Otherwise, the function address is
|
||||
on the top of stack. */
|
||||
|
||||
static void
|
||||
-output_indirect_thunk_function (bool need_bnd_p, int regno)
|
||||
+output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
{
|
||||
char name[32];
|
||||
tree decl;
|
||||
@@ -11274,7 +11274,7 @@ output_indirect_thunk_function (bool need_bnd_p, int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
- if (regno < 0)
|
||||
+ if (regno == INVALID_REGNUM)
|
||||
{
|
||||
/* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
|
||||
char alias[32];
|
||||
@@ -11348,16 +11348,16 @@ static void
|
||||
ix86_code_end (void)
|
||||
{
|
||||
rtx xops[2];
|
||||
- int regno;
|
||||
+ unsigned int regno;
|
||||
|
||||
if (indirect_thunk_needed)
|
||||
- output_indirect_thunk_function (false, -1);
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM);
|
||||
if (indirect_thunk_bnd_needed)
|
||||
- output_indirect_thunk_function (true, -1);
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM);
|
||||
|
||||
for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
|
||||
{
|
||||
- int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
+ unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
if ((indirect_thunks_used & (1 << i)))
|
||||
output_indirect_thunk_function (false, regno);
|
||||
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 3815e98f0f46b6c4c41e6810bad987bd083691aa Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Fri, 2 Feb 2018 16:47:02 +0000
|
||||
Subject: [PATCH 10/13] i386: Pass INVALID_REGNUM as invalid register number
|
||||
|
||||
Backport from mainline
|
||||
* config/i386/i386.c (ix86_output_function_return): Pass
|
||||
INVALID_REGNUM, instead of -1, as invalid register number to
|
||||
indirect_thunk_name and output_indirect_thunk.
|
||||
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257341 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
---
|
||||
gcc/config/i386/i386.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 40126579c22..66502ee6da6 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -28056,7 +28056,8 @@ ix86_output_function_return (bool long_p)
|
||||
{
|
||||
bool need_thunk = (cfun->machine->function_return_type
|
||||
== indirect_branch_thunk);
|
||||
- indirect_thunk_name (thunk_name, -1, need_bnd_p, true);
|
||||
+ indirect_thunk_name (thunk_name, INVALID_REGNUM, need_bnd_p,
|
||||
+ true);
|
||||
if (need_bnd_p)
|
||||
{
|
||||
indirect_thunk_bnd_needed |= need_thunk;
|
||||
@@ -28069,7 +28070,7 @@ ix86_output_function_return (bool long_p)
|
||||
}
|
||||
}
|
||||
else
|
||||
- output_indirect_thunk (need_bnd_p, -1);
|
||||
+ output_indirect_thunk (need_bnd_p, INVALID_REGNUM);
|
||||
|
||||
return "";
|
||||
}
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -0,0 +1,456 @@
|
|||
From 771535dec733e4b85924f00a3a94c29683d614e5 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Mon, 26 Feb 2018 15:29:30 +0000
|
||||
Subject: [PATCH 11/13] i386: Update -mfunction-return= for return with pop
|
||||
|
||||
When -mfunction-return= is used, simple_return_pop_internal should pop
|
||||
return address into ECX register, adjust stack by bytes to pop from stack
|
||||
and jump to the return thunk via ECX register.
|
||||
|
||||
Revision 257992 removed the bool argument from ix86_output_indirect_jmp.
|
||||
Update comments to reflect it.
|
||||
|
||||
Tested on i686 and x86-64.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* config/i386/i386.c (ix86_output_indirect_jmp): Update comments.
|
||||
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/84530
|
||||
* config/i386/i386-protos.h (ix86_output_indirect_jmp): Remove
|
||||
the bool argument.
|
||||
(ix86_output_indirect_function_return): New prototype.
|
||||
(ix86_split_simple_return_pop_internal): Likewise.
|
||||
* config/i386/i386.c (indirect_return_via_cx): New.
|
||||
(indirect_return_via_cx_bnd): Likewise.
|
||||
(indirect_thunk_name): Handle return va CX_REG.
|
||||
(output_indirect_thunk_function): Create alias for
|
||||
__x86_return_thunk_[re]cx and __x86_return_thunk_[re]cx_bnd.
|
||||
(ix86_output_indirect_jmp): Remove the bool argument.
|
||||
(ix86_output_indirect_function_return): New function.
|
||||
(ix86_split_simple_return_pop_internal): Likewise.
|
||||
* config/i386/i386.md (*indirect_jump): Don't pass false
|
||||
to ix86_output_indirect_jmp.
|
||||
(*tablejump_1): Likewise.
|
||||
(simple_return_pop_internal): Change it to define_insn_and_split.
|
||||
Call ix86_split_simple_return_pop_internal to split it for
|
||||
-mfunction-return=.
|
||||
(simple_return_indirect_internal): Call
|
||||
ix86_output_indirect_function_return instead of
|
||||
ix86_output_indirect_jmp.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
2018-02-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/84530
|
||||
* gcc.target/i386/ret-thunk-22.c: New test.
|
||||
* gcc.target/i386/ret-thunk-23.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-24.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-25.c: Likewise.
|
||||
* gcc.target/i386/ret-thunk-26.c: Likewise.
|
||||
---
|
||||
gcc/config/i386/i386-protos.h | 4 +-
|
||||
gcc/config/i386/i386.c | 127 +++++++++++++++++++++++----
|
||||
gcc/config/i386/i386.md | 11 ++-
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-22.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-23.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-24.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-25.c | 15 ++++
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-26.c | 40 +++++++++
|
||||
8 files changed, 222 insertions(+), 20 deletions(-)
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
|
||||
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
|
||||
index 620d70ef9f6..c7a0ccb58d3 100644
|
||||
--- a/gcc/config/i386/i386-protos.h
|
||||
+++ b/gcc/config/i386/i386-protos.h
|
||||
@@ -311,8 +311,10 @@ extern enum attr_cpu ix86_schedule;
|
||||
#endif
|
||||
|
||||
extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
|
||||
-extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
|
||||
+extern const char * ix86_output_indirect_jmp (rtx call_op);
|
||||
extern const char * ix86_output_function_return (bool long_p);
|
||||
+extern const char * ix86_output_indirect_function_return (rtx ret_op);
|
||||
+extern void ix86_split_simple_return_pop_internal (rtx);
|
||||
extern bool ix86_operands_ok_for_move_multiple (rtx *operands, bool load,
|
||||
enum machine_mode mode);
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 66502ee6da6..21c3c18bd3c 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11080,6 +11080,12 @@ static int indirect_thunks_used;
|
||||
by call and return thunks functions with the BND prefix. */
|
||||
static int indirect_thunks_bnd_used;
|
||||
|
||||
+/* True if return thunk function via CX is needed. */
|
||||
+static bool indirect_return_via_cx;
|
||||
+/* True if return thunk function via CX with the BND prefix is
|
||||
+ needed. */
|
||||
+static bool indirect_return_via_cx_bnd;
|
||||
+
|
||||
#ifndef INDIRECT_LABEL
|
||||
# define INDIRECT_LABEL "LIND"
|
||||
#endif
|
||||
@@ -11090,12 +11096,13 @@ static void
|
||||
indirect_thunk_name (char name[32], unsigned int regno,
|
||||
bool need_bnd_p, bool ret_p)
|
||||
{
|
||||
- if (regno != INVALID_REGNUM && ret_p)
|
||||
+ if (regno != INVALID_REGNUM && regno != CX_REG && ret_p)
|
||||
gcc_unreachable ();
|
||||
|
||||
if (USE_HIDDEN_LINKONCE)
|
||||
{
|
||||
const char *bnd = need_bnd_p ? "_bnd" : "";
|
||||
+ const char *ret = ret_p ? "return" : "indirect";
|
||||
if (regno != INVALID_REGNUM)
|
||||
{
|
||||
const char *reg_prefix;
|
||||
@@ -11103,14 +11110,11 @@ indirect_thunk_name (char name[32], unsigned int regno,
|
||||
reg_prefix = TARGET_64BIT ? "r" : "e";
|
||||
else
|
||||
reg_prefix = "";
|
||||
- sprintf (name, "__x86_indirect_thunk%s_%s%s",
|
||||
- bnd, reg_prefix, reg_names[regno]);
|
||||
+ sprintf (name, "__x86_%s_thunk%s_%s%s",
|
||||
+ ret, bnd, reg_prefix, reg_names[regno]);
|
||||
}
|
||||
else
|
||||
- {
|
||||
- const char *ret = ret_p ? "return" : "indirect";
|
||||
- sprintf (name, "__x86_%s_thunk%s", ret, bnd);
|
||||
- }
|
||||
+ sprintf (name, "__x86_%s_thunk%s", ret, bnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -11274,9 +11278,23 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
+ /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or
|
||||
+ __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */
|
||||
+ bool need_alias;
|
||||
if (regno == INVALID_REGNUM)
|
||||
+ need_alias = true;
|
||||
+ else if (regno == CX_REG)
|
||||
+ {
|
||||
+ if (need_bnd_p)
|
||||
+ need_alias = indirect_return_via_cx_bnd;
|
||||
+ else
|
||||
+ need_alias = indirect_return_via_cx;
|
||||
+ }
|
||||
+ else
|
||||
+ need_alias = false;
|
||||
+
|
||||
+ if (need_alias)
|
||||
{
|
||||
- /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
|
||||
char alias[32];
|
||||
|
||||
indirect_thunk_name (alias, regno, need_bnd_p, true);
|
||||
@@ -28019,18 +28037,17 @@ ix86_output_indirect_branch (rtx call_op, const char *xasm,
|
||||
else
|
||||
ix86_output_indirect_branch_via_push (call_op, xasm, sibcall_p);
|
||||
}
|
||||
-/* Output indirect jump. CALL_OP is the jump target. Jump is a
|
||||
- function return if RET_P is true. */
|
||||
+
|
||||
+/* Output indirect jump. CALL_OP is the jump target. */
|
||||
|
||||
const char *
|
||||
-ix86_output_indirect_jmp (rtx call_op, bool ret_p)
|
||||
+ix86_output_indirect_jmp (rtx call_op)
|
||||
{
|
||||
if (cfun->machine->indirect_branch_type != indirect_branch_keep)
|
||||
{
|
||||
- /* We can't have red-zone if this isn't a function return since
|
||||
- "call" in the indirect thunk pushes the return address onto
|
||||
- stack, destroying red-zone. */
|
||||
- if (!ret_p && ix86_red_zone_size != 0)
|
||||
+ /* We can't have red-zone since "call" in the indirect thunk
|
||||
+ pushes the return address onto stack, destroying red-zone. */
|
||||
+ if (ix86_red_zone_size != 0)
|
||||
gcc_unreachable ();
|
||||
|
||||
ix86_output_indirect_branch (call_op, "%0", true);
|
||||
@@ -28081,6 +28098,86 @@ ix86_output_function_return (bool long_p)
|
||||
return "rep%; ret";
|
||||
}
|
||||
|
||||
+/* Output indirect function return. RET_OP is the function return
|
||||
+ target. */
|
||||
+
|
||||
+const char *
|
||||
+ix86_output_indirect_function_return (rtx ret_op)
|
||||
+{
|
||||
+ if (cfun->machine->function_return_type != indirect_branch_keep)
|
||||
+ {
|
||||
+ char thunk_name[32];
|
||||
+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
|
||||
+ unsigned int regno = REGNO (ret_op);
|
||||
+ gcc_assert (regno == CX_REG);
|
||||
+
|
||||
+ 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, regno, need_bnd_p, true);
|
||||
+ if (need_bnd_p)
|
||||
+ {
|
||||
+ if (need_thunk)
|
||||
+ {
|
||||
+ indirect_return_via_cx_bnd = true;
|
||||
+ indirect_thunks_bnd_used |= 1 << CX_REG;
|
||||
+ }
|
||||
+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if (need_thunk)
|
||||
+ {
|
||||
+ indirect_return_via_cx = true;
|
||||
+ indirect_thunks_used |= 1 << CX_REG;
|
||||
+ }
|
||||
+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ output_indirect_thunk (need_bnd_p, regno);
|
||||
+
|
||||
+ return "";
|
||||
+ }
|
||||
+ else
|
||||
+ return "%!jmp\t%A0";
|
||||
+}
|
||||
+
|
||||
+/* Split simple return with popping POPC bytes from stack to indirect
|
||||
+ branch with stack adjustment . */
|
||||
+
|
||||
+void
|
||||
+ix86_split_simple_return_pop_internal (rtx popc)
|
||||
+{
|
||||
+ struct machine_function *m = cfun->machine;
|
||||
+ rtx ecx = gen_rtx_REG (SImode, CX_REG);
|
||||
+ rtx_insn *insn;
|
||||
+
|
||||
+ /* There is no "pascal" calling convention in any 64bit ABI. */
|
||||
+ gcc_assert (!TARGET_64BIT);
|
||||
+
|
||||
+ insn = emit_insn (gen_pop (ecx));
|
||||
+ m->fs.cfa_offset -= UNITS_PER_WORD;
|
||||
+ m->fs.sp_offset -= UNITS_PER_WORD;
|
||||
+
|
||||
+ rtx x = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD);
|
||||
+ x = gen_rtx_SET (stack_pointer_rtx, x);
|
||||
+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x);
|
||||
+ add_reg_note (insn, REG_CFA_REGISTER, gen_rtx_SET (ecx, pc_rtx));
|
||||
+ RTX_FRAME_RELATED_P (insn) = 1;
|
||||
+
|
||||
+ x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, popc);
|
||||
+ x = gen_rtx_SET (stack_pointer_rtx, x);
|
||||
+ insn = emit_insn (x);
|
||||
+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x);
|
||||
+ RTX_FRAME_RELATED_P (insn) = 1;
|
||||
+
|
||||
+ /* Now return address is in ECX. */
|
||||
+ emit_jump_insn (gen_simple_return_indirect_internal (ecx));
|
||||
+}
|
||||
+
|
||||
/* Output the assembly for a call instruction. */
|
||||
|
||||
const char *
|
||||
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
||||
index 05a88fff356..857466a6361 100644
|
||||
--- a/gcc/config/i386/i386.md
|
||||
+++ b/gcc/config/i386/i386.md
|
||||
@@ -11813,7 +11813,7 @@
|
||||
(define_insn "*indirect_jump"
|
||||
[(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))]
|
||||
""
|
||||
- "* return ix86_output_indirect_jmp (operands[0], false);"
|
||||
+ "* return ix86_output_indirect_jmp (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
@@ -11868,7 +11868,7 @@
|
||||
[(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))
|
||||
(use (label_ref (match_operand 1)))]
|
||||
""
|
||||
- "* return ix86_output_indirect_jmp (operands[0], false);"
|
||||
+ "* return ix86_output_indirect_jmp (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
@@ -12520,11 +12520,14 @@
|
||||
(set_attr "prefix_rep" "1")
|
||||
(set_attr "modrm" "0")])
|
||||
|
||||
-(define_insn "simple_return_pop_internal"
|
||||
+(define_insn_and_split "simple_return_pop_internal"
|
||||
[(simple_return)
|
||||
(use (match_operand:SI 0 "const_int_operand"))]
|
||||
"reload_completed"
|
||||
"%!ret\t%0"
|
||||
+ "&& cfun->machine->function_return_type != indirect_branch_keep"
|
||||
+ [(const_int 0)]
|
||||
+ "ix86_split_simple_return_pop_internal (operands[0]); DONE;"
|
||||
[(set_attr "length" "3")
|
||||
(set_attr "atom_unit" "jeu")
|
||||
(set_attr "length_immediate" "2")
|
||||
@@ -12535,7 +12538,7 @@
|
||||
[(simple_return)
|
||||
(use (match_operand:SI 0 "register_operand" "r"))]
|
||||
"reload_completed"
|
||||
- "* return ix86_output_indirect_jmp (operands[0], true);"
|
||||
+ "* return ix86_output_indirect_function_return (operands[0]);"
|
||||
[(set (attr "type")
|
||||
(if_then_else (match_test "(cfun->machine->indirect_branch_type
|
||||
!= indirect_branch_keep)")
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-22.c b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
new file mode 100644
|
||||
index 00000000000..89e086de97b
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { 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-23.c b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
new file mode 100644
|
||||
index 00000000000..43f0ccaa854
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-extern" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
|
||||
+/* { dg-final { scan-assembler-not {\tpause} } } */
|
||||
+/* { dg-final { scan-assembler-not {\tlfence} } } */
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-24.c b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
new file mode 100644
|
||||
index 00000000000..8729e35147e
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk_ecx" } } */
|
||||
+/* { 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-25.c b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
new file mode 100644
|
||||
index 00000000000..f73553c9a9f
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do compile { target ia32 } } */
|
||||
+/* { dg-options "-O2 -mfunction-return=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */
|
||||
+
|
||||
+struct s { _Complex unsigned short x; };
|
||||
+struct s gs = { 100 + 200i };
|
||||
+struct s __attribute__((noinline)) foo (void) { return gs; }
|
||||
+
|
||||
+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */
|
||||
+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */
|
||||
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_bnd_ecx" } } */
|
||||
+/* { 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-26.c b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
new file mode 100644
|
||||
index 00000000000..9144e988735
|
||||
--- /dev/null
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c
|
||||
@@ -0,0 +1,40 @@
|
||||
+/* PR target/r84530 */
|
||||
+/* { dg-do run } */
|
||||
+/* { dg-options "-Os -mfunction-return=thunk" } */
|
||||
+
|
||||
+struct S { int i; };
|
||||
+__attribute__((const, noinline, noclone))
|
||||
+struct S foo (int x)
|
||||
+{
|
||||
+ struct S s;
|
||||
+ s.i = x;
|
||||
+ return s;
|
||||
+}
|
||||
+
|
||||
+int a[2048], b[2048], c[2048], d[2048];
|
||||
+struct S e[2048];
|
||||
+
|
||||
+__attribute__((noinline, noclone)) void
|
||||
+bar (void)
|
||||
+{
|
||||
+ int i;
|
||||
+ for (i = 0; i < 1024; i++)
|
||||
+ {
|
||||
+ e[i] = foo (i);
|
||||
+ a[i+2] = a[i] + a[i+1];
|
||||
+ b[10] = b[10] + i;
|
||||
+ c[i] = c[2047 - i];
|
||||
+ d[i] = d[i + 1];
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+main ()
|
||||
+{
|
||||
+ int i;
|
||||
+ bar ();
|
||||
+ for (i = 0; i < 1024; i++)
|
||||
+ if (e[i].i != i)
|
||||
+ __builtin_abort ();
|
||||
+ return 0;
|
||||
+}
|
||||
--
|
||||
2.16.3
|
||||
|
1003
cross/gcc-x86_64/0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
Normal file
1003
cross/gcc-x86_64/0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,225 @@
|
|||
From e7fbaebc8ff650df76f43e92cb9ca59d5174ebe7 Mon Sep 17 00:00:00 2001
|
||||
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Thu, 15 Mar 2018 17:54:40 +0000
|
||||
Subject: [PATCH 13/13] i386: Don't generate alias for function return thunk
|
||||
|
||||
Function return thunks shouldn't be aliased to indirect branch thunks
|
||||
since indirect branch thunks are placed in COMDAT section and a COMDAT
|
||||
section with indirect branch may not have function return thunk. This
|
||||
patch generates function return thunks directly.
|
||||
|
||||
gcc/
|
||||
|
||||
Backport from mainline
|
||||
PR target/84574
|
||||
* config/i386/i386.c (indirect_thunk_needed): Update comments.
|
||||
(indirect_thunk_bnd_needed): Likewise.
|
||||
(indirect_thunks_used): Likewise.
|
||||
(indirect_thunks_bnd_used): Likewise.
|
||||
(indirect_return_needed): New.
|
||||
(indirect_return_bnd_needed): Likewise.
|
||||
(output_indirect_thunk_function): Add a bool argument for
|
||||
function return.
|
||||
(output_indirect_thunk_function): Don't generate alias for
|
||||
function return thunk.
|
||||
(ix86_code_end): Call output_indirect_thunk_function to generate
|
||||
function return thunks.
|
||||
(ix86_output_function_return): Set indirect_return_bnd_needed
|
||||
and indirect_return_needed instead of indirect_thunk_bnd_needed
|
||||
and indirect_thunk_needed.
|
||||
|
||||
gcc/testsuite/
|
||||
|
||||
Backport from mainline
|
||||
PR target/84574
|
||||
* gcc.target/i386/ret-thunk-9.c: Expect __x86_return_thunk
|
||||
label instead of __x86_indirect_thunk label.
|
||||
---
|
||||
gcc/config/i386/i386.c | 92 ++++++++++-------------------
|
||||
gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 2 +-
|
||||
2 files changed, 33 insertions(+), 61 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
|
||||
index 21c3c18bd3c..f4cd1c6f4e9 100644
|
||||
--- a/gcc/config/i386/i386.c
|
||||
+++ b/gcc/config/i386/i386.c
|
||||
@@ -11067,19 +11067,23 @@ ix86_setup_frame_addresses (void)
|
||||
labels in call and return thunks. */
|
||||
static int indirectlabelno;
|
||||
|
||||
-/* True if call and return thunk functions are needed. */
|
||||
+/* True if call thunk function is needed. */
|
||||
static bool indirect_thunk_needed = false;
|
||||
-/* True if call and return thunk functions with the BND prefix are
|
||||
- needed. */
|
||||
+/* True if call thunk function with the BND prefix is needed. */
|
||||
static bool indirect_thunk_bnd_needed = false;
|
||||
|
||||
/* Bit masks of integer registers, which contain branch target, used
|
||||
- by call and return thunks functions. */
|
||||
+ by call thunk functions. */
|
||||
static int indirect_thunks_used;
|
||||
/* Bit masks of integer registers, which contain branch target, used
|
||||
- by call and return thunks functions with the BND prefix. */
|
||||
+ by call thunk functions with the BND prefix. */
|
||||
static int indirect_thunks_bnd_used;
|
||||
|
||||
+/* True if return thunk function is needed. */
|
||||
+static bool indirect_return_needed = false;
|
||||
+/* True if return thunk function with the BND prefix is needed. */
|
||||
+static bool indirect_return_bnd_needed = false;
|
||||
+
|
||||
/* True if return thunk function via CX is needed. */
|
||||
static bool indirect_return_via_cx;
|
||||
/* True if return thunk function via CX with the BND prefix is
|
||||
@@ -11226,16 +11230,18 @@ output_indirect_thunk (bool need_bnd_p, unsigned int regno)
|
||||
/* Output a funtion with a call and return thunk for indirect branch.
|
||||
If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM,
|
||||
the function address is in REGNO. Otherwise, the function address is
|
||||
- on the top of stack. */
|
||||
+ on the top of stack. Thunk is used for function return if RET_P is
|
||||
+ true. */
|
||||
|
||||
static void
|
||||
-output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
+output_indirect_thunk_function (bool need_bnd_p, unsigned int regno,
|
||||
+ bool ret_p)
|
||||
{
|
||||
char name[32];
|
||||
tree decl;
|
||||
|
||||
/* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */
|
||||
- indirect_thunk_name (name, regno, need_bnd_p, false);
|
||||
+ indirect_thunk_name (name, regno, need_bnd_p, ret_p);
|
||||
decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
|
||||
get_identifier (name),
|
||||
build_function_type_list (void_type_node, NULL_TREE));
|
||||
@@ -11278,50 +11284,6 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno)
|
||||
ASM_OUTPUT_LABEL (asm_out_file, name);
|
||||
}
|
||||
|
||||
- /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or
|
||||
- __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */
|
||||
- bool need_alias;
|
||||
- if (regno == INVALID_REGNUM)
|
||||
- need_alias = true;
|
||||
- else if (regno == CX_REG)
|
||||
- {
|
||||
- if (need_bnd_p)
|
||||
- need_alias = indirect_return_via_cx_bnd;
|
||||
- else
|
||||
- need_alias = indirect_return_via_cx;
|
||||
- }
|
||||
- else
|
||||
- need_alias = false;
|
||||
-
|
||||
- if (need_alias)
|
||||
- {
|
||||
- char alias[32];
|
||||
-
|
||||
- indirect_thunk_name (alias, regno, need_bnd_p, 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);
|
||||
@@ -11368,19 +11330,29 @@ ix86_code_end (void)
|
||||
rtx xops[2];
|
||||
unsigned int regno;
|
||||
|
||||
+ if (indirect_return_needed)
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM, true);
|
||||
+ if (indirect_return_bnd_needed)
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM, true);
|
||||
+
|
||||
+ if (indirect_return_via_cx)
|
||||
+ output_indirect_thunk_function (false, CX_REG, true);
|
||||
+ if (indirect_return_via_cx_bnd)
|
||||
+ output_indirect_thunk_function (true, CX_REG, true);
|
||||
+
|
||||
if (indirect_thunk_needed)
|
||||
- output_indirect_thunk_function (false, INVALID_REGNUM);
|
||||
+ output_indirect_thunk_function (false, INVALID_REGNUM, false);
|
||||
if (indirect_thunk_bnd_needed)
|
||||
- output_indirect_thunk_function (true, INVALID_REGNUM);
|
||||
+ output_indirect_thunk_function (true, INVALID_REGNUM, false);
|
||||
|
||||
for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
|
||||
{
|
||||
unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
|
||||
if ((indirect_thunks_used & (1 << i)))
|
||||
- output_indirect_thunk_function (false, regno);
|
||||
+ output_indirect_thunk_function (false, regno, false);
|
||||
|
||||
if ((indirect_thunks_bnd_used & (1 << i)))
|
||||
- output_indirect_thunk_function (true, regno);
|
||||
+ output_indirect_thunk_function (true, regno, false);
|
||||
}
|
||||
|
||||
for (regno = AX_REG; regno <= SP_REG; regno++)
|
||||
@@ -11389,10 +11361,10 @@ ix86_code_end (void)
|
||||
tree decl;
|
||||
|
||||
if ((indirect_thunks_used & (1 << regno)))
|
||||
- output_indirect_thunk_function (false, regno);
|
||||
+ output_indirect_thunk_function (false, regno, false);
|
||||
|
||||
if ((indirect_thunks_bnd_used & (1 << regno)))
|
||||
- output_indirect_thunk_function (true, regno);
|
||||
+ output_indirect_thunk_function (true, regno, false);
|
||||
|
||||
if (!(pic_labels_used & (1 << regno)))
|
||||
continue;
|
||||
@@ -28077,12 +28049,12 @@ ix86_output_function_return (bool long_p)
|
||||
true);
|
||||
if (need_bnd_p)
|
||||
{
|
||||
- indirect_thunk_bnd_needed |= need_thunk;
|
||||
+ indirect_return_bnd_needed |= need_thunk;
|
||||
fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
- indirect_thunk_needed |= need_thunk;
|
||||
+ indirect_return_needed |= need_thunk;
|
||||
fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
|
||||
}
|
||||
}
|
||||
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
index d2df8b874e0..eee230ca2f6 100644
|
||||
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
|
||||
@@ -13,7 +13,7 @@ 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 "__x86_indirect_thunk:" } } */
|
||||
+/* { dg-final { scan-assembler "__x86_return_thunk:" } } */
|
||||
/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */
|
||||
/* { dg-final { scan-assembler-times {\tpause} 2 } } */
|
||||
/* { dg-final { scan-assembler-times {\tlfence} 2 } } */
|
||||
--
|
||||
2.16.3
|
||||
|
|
@ -54,7 +54,7 @@ pkgver=6.4.0
|
|||
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""
|
||||
|
||||
pkgname="gcc-x86_64"
|
||||
pkgrel=7
|
||||
pkgrel=8
|
||||
pkgdesc="Stage2 cross-compiler for x86_64"
|
||||
url="http://gcc.gnu.org"
|
||||
arch="armhf aarch64 x86"
|
||||
|
@ -236,6 +236,20 @@ source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgba
|
|||
fix-linux-header-use-in-libgcc.patch
|
||||
gcc-pure64-mips.patch
|
||||
ada-mips64.patch
|
||||
|
||||
0001-i386-Move-struct-ix86_frame-to-machine_function.patch
|
||||
0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch
|
||||
0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch
|
||||
0004-x86-Add-mindirect-branch.patch
|
||||
0005-x86-Add-mfunction-return.patch
|
||||
0006-x86-Add-mindirect-branch-register.patch
|
||||
0007-x86-Add-V-register-operand-modifier.patch
|
||||
0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch
|
||||
0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch
|
||||
0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch
|
||||
0011-i386-Update-mfunction-return-for-return-with-pop.patch
|
||||
0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
|
||||
0013-i386-Don-t-generate-alias-for-function-return-thunk.patch
|
||||
"
|
||||
|
||||
# we build out-of-tree
|
||||
|
@ -715,4 +729,17 @@ f4ef08454e28c8732db69115e4998ec153399e8d229dd27f923dbdcf57b68128a65640d026cc7f45
|
|||
01c71cd5881fc07ea3b9b980697e89b3ca0fe98502958ceafc3fca18b2604c844e2f457feab711baf8e03f00a5383b0e38aac7eb954034e306f43d4a37f165ed fix-rs6000-pie.patch
|
||||
34a818d5be67eb1f34e44a80b83c28a9b9c17d37fc9fac639f490d6bb5b53ebe3318140d09c236a17d7c98f5a7792ae3d6cefccda8067a5e942d6305b9d1f87c fix-linux-header-use-in-libgcc.patch
|
||||
86be3338cc9c33089608bc4c5e3b7918c4e500a345c338f361b18c342119a6ed69af5495d72950de7106d760f003528b46ad14795e805f8a3331e206dcb234e3 gcc-pure64-mips.patch
|
||||
508f3bca214d88531d739d761d07affc953689b1540905c73420b34c246e1e6b72588cf89f0e1462752633f8ddc88da8c0238be2a1b6e1c213829cecee7924cf ada-mips64.patch"
|
||||
508f3bca214d88531d739d761d07affc953689b1540905c73420b34c246e1e6b72588cf89f0e1462752633f8ddc88da8c0238be2a1b6e1c213829cecee7924cf ada-mips64.patch
|
||||
7912964bf3a985e9f870250d6e068f715582a4fb04270849d697a50e6aad0cf50df3d483ff80a0eb777d9940fd85526dd8d0b85da9bc71a5f2fbc07616263866 0001-i386-Move-struct-ix86_frame-to-machine_function.patch
|
||||
baa27a4b912d8e27cd65a556b09cf45289a0e00e86dae3925f2923d1f3752080e80d80e159c996ef4156c4df1dfc3069114810a846672170ef3ae461ae0ab7e1 0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch
|
||||
6701d15000bdd7c4c98a8fece8c814f5e4e73603eecf84fe4dc5ac10f79b3074afba7c2cc9e51d08b2abade1c34cb0c944c08ead7a85db94e97158c752fd1aac 0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch
|
||||
4e7e71ae57e232b29a6455ec977f60b47df1356eca0e85976ae2b4567c4c39541be9f10c30fe0085d69be5acdb61dff51d3e9d7af587c95d9cd2cb9ee307bd13 0004-x86-Add-mindirect-branch.patch
|
||||
07f7fdbd9b4876f36ed7715a35a369dbaf1016f46c42a8935930cfcc9ea250de2dbe8113f077373ccce3c39cd728f957b6c4c7c6a7da299f160a4109f0bbe88d 0005-x86-Add-mfunction-return.patch
|
||||
76ea947591e5241f8e6216ce337baaf1b5dfe3f02d8251f77a4acd70e2a5e7798e2867d70f452027f51a2e3baf1b5c94c3bffe9ef8e0a5ce24dc5d509adaf414 0006-x86-Add-mindirect-branch-register.patch
|
||||
1c33c5cd34efb44d4fa0ace56e3d27ec802a66e03b08a29ab6122cbc70edbbe22313a34114437a41e09e0a6869af3cea3fb18f5bcb49db2f8e3f155026fe15f0 0007-x86-Add-V-register-operand-modifier.patch
|
||||
5366e2cff0629304394bf35e9417c7faea6b6f3fc565d0410a17fdafcb2b30c9a218f8ca098274c09ca4c982ff5b178ad6df5bf464ec541aa086966915c7fe11 0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch
|
||||
67c738b1f6afb09b6f0469c9cb282ab4d51fc8dd8e39df1cfdff8831788c1022081fccd446a482623f649898733aeaaa205cba0aa41162cdbdc74e57de9bb6eb 0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch
|
||||
b7b59f3203bf53168de2170b91738cd456f6ae205b3fe5bf8aacbaa8cc5624dd09c941ad8f1071d1ab8ab4fb5f69068a4bc792c0486fdec1ee2eb9c83688bb78 0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch
|
||||
c53d4c5968865abb709ee8a9af9d57917d43ea3ba31ee8312f9e8f338e9b1b44babf5aa3414848da7267e5cf13a9261815eb9185dc153cbd41ee7ce5ea23d2d0 0011-i386-Update-mfunction-return-for-return-with-pop.patch
|
||||
955080ba3e42cfe2f604e5dcef46aa6fca7c899c7808398947af655ff3b7954e30807ef85246986a5cc7db36dbc870db151e9fa8d8bc967b89ea56efdf64614c 0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch
|
||||
3aae3a9cef8e8afe5a5433db8d9f410e1a2882481af01bb1d33232f987dbb74d7780c32be70b868bb391b3601b65ed3a16d777afea946f5eeaff72aa1e7fa3a9 0013-i386-Don-t-generate-alias-for-function-return-thunk.patch"
|
||||
|
|
Loading…
Add table
Reference in a new issue