[gcc/devel/omp/gcc-9] i386: Skip ENDBR32 at the target function entry

Tobias Burnus burnus@gcc.gnu.org
Thu Mar 5 14:51:00 GMT 2020


https://gcc.gnu.org/g:f55bf4ddbfac3c7360cb00f3200b663c19baf504

commit f55bf4ddbfac3c7360cb00f3200b663c19baf504
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 20 03:05:27 2020 -0800

    i386: Skip ENDBR32 at the target function entry
    
    Skip ENDBR32 at the target function entry when initializing trampoline.
    
    Tested on Linux/x86-64 CET machine with and without -m32.
    
    gcc/
    
    	Backport from master
    	PR target/93656
    	* config/i386/i386.c (ix86_trampoline_init): Skip ENDBR32 at
    	the target function entry.
    
    gcc/testsuite/
    
    	Backport from master
    	PR target/93656
    	* gcc.target/i386/pr93656.c: New test.
    
    (cherry picked from commit 1d69147af203d4dcd2270429f90c93f1a37ddfff)

Diff:
---
 gcc/ChangeLog                           | 9 +++++++++
 gcc/config/i386/i386.c                  | 7 ++++++-
 gcc/testsuite/ChangeLog                 | 8 ++++++++
 gcc/testsuite/gcc.target/i386/pr93656.c | 4 ++++
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5cad283..9680a1a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+	Backport from master
+	2020-02-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/93656
+	* config/i386/i386.c (ix86_trampoline_init): Skip ENDBR32 at
+	the target function entry.
+
 2020-02-18  Richard Sandiford  <richard.sandiford@arm.com>
 
 	Backport from mainline
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 779e811..1bca5a7 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -30289,9 +30289,14 @@ ix86_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
 	 the stack, we need to skip the first insn which pushes the
 	 (call-saved) register static chain; this push is 1 byte.  */
       offset += 5;
+      int skip = MEM_P (chain) ? 1 : 0;
+      /* Skip ENDBR32 at the entry of the target function.  */
+      if (need_endbr
+	  && !cgraph_node::get (fndecl)->only_called_directly_p ())
+	skip += 4;
       disp = expand_binop (SImode, sub_optab, fnaddr,
 			   plus_constant (Pmode, XEXP (m_tramp, 0),
-					  offset - (MEM_P (chain) ? 1 : 0)),
+					  offset - skip),
 			   NULL_RTX, 1, OPTAB_DIRECT);
       emit_move_insn (mem, disp);
     }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8c1ce95..9344d00 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2020-02-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+	Backport from master
+	2020-02-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/93656
+	* gcc.target/i386/pr93656.c: New test.
+
 2020-02-19  Mark Eggleston <markeggleston@gcc.gnu.org>
 
 	* typebound_call_22.d03 : Remove xfail clause.
diff --git a/gcc/testsuite/gcc.target/i386/pr93656.c b/gcc/testsuite/gcc.target/i386/pr93656.c
new file mode 100644
index 0000000..f0ac8c8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr93656.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target { ia32 && cet } } } */
+/* { dg-options "-O2 -fcf-protection" } */
+
+#include "pr67770.c"



More information about the Gcc-cvs mailing list