+2018-09-24 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/82699
+ * config/i386/i386.c (rest_of_insert_endbranch): Set
+ endbr_queued_at_entrance to true and don't insert ENDBR if
+ x86_function_profiler will be called.
+ (x86_function_profiler): Insert ENDBR if endbr_queued_at_entrance
+ is true.
+ * config/i386/i386.h (machine_function): Add
+ endbr_queued_at_entrance.
+
2018-09-24 Ilya Leoshkevich <iii@linux.ibm.com>
* genattrtab.c (mk_attr_alt): Use alternative_mask.
TYPE_ATTRIBUTES (TREE_TYPE (cfun->decl)))
&& !cgraph_node::get (cfun->decl)->only_called_directly_p ())
{
- cet_eb = gen_nop_endbr ();
+ /* Queue ENDBR insertion to x86_function_profiler. */
+ if (crtl->profile && flag_fentry)
+ cfun->machine->endbr_queued_at_entrance = true;
+ else
+ {
+ cet_eb = gen_nop_endbr ();
- bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb;
- insn = BB_HEAD (bb);
- emit_insn_before (cet_eb, insn);
+ bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb;
+ insn = BB_HEAD (bb);
+ emit_insn_before (cet_eb, insn);
+ }
}
bb = 0;
{
const char *mcount_name = (flag_fentry ? MCOUNT_NAME_BEFORE_PROLOGUE
: MCOUNT_NAME);
+
+ if (cfun->machine->endbr_queued_at_entrance)
+ fprintf (file, "\t%s\n", TARGET_64BIT ? "endbr64" : "endbr32");
+
if (TARGET_64BIT)
{
#ifndef NO_PROFILE_COUNTERS
/* Nonzero if the function places outgoing arguments on stack. */
BOOL_BITFIELD outgoing_args_on_stack : 1;
+ /* If true, ENDBR is queued at function entrance. */
+ BOOL_BITFIELD endbr_queued_at_entrance : 1;
+
/* The largest alignment, in bytes, of stack slot actually used. */
unsigned int max_used_stack_alignment;
+2018-09-24 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/82699
+ * gcc.target/i386/pr82699-1.c: New file.
+ * gcc.target/i386/pr82699-2.c: Likewise.
+ * gcc.target/i386/pr82699-3.c: Likewise.
+ * gcc.target/i386/pr82699-4.c: Likewise.
+ * gcc.target/i386/pr82699-5.c: Likewise.
+ * gcc.target/i386/pr82699-6.c: Likewise.
+
2018-09-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/87401
--- /dev/null
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fcf-protection -pg -fasynchronous-unwind-tables" } */
+/* { dg-final { scan-assembler-times {\t\.cfi_startproc\n\tendbr} 1 } } */
+
+extern int bar (int);
+
+int
+foo (int i)
+{
+ return bar (i);
+}
--- /dev/null
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fcf-protection -pg -mfentry -fasynchronous-unwind-tables" } */
+/* { dg-final { scan-assembler-times {\t\.cfi_startproc\n\tendbr} 1 } } */
+
+extern int bar (int);
+
+int
+foo (int i)
+{
+ return bar (i);
+}
--- /dev/null
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fcf-protection -pg -fasynchronous-unwind-tables" } */
+/* { dg-final { scan-assembler-times {\t\.cfi_startproc\n\tendbr} 1 } } */
+
+extern int bar (int);
+
+int
+foo (int i)
+{
+ return bar (i);
+}
--- /dev/null
+/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-options "-O2 -fpic -fcf-protection -pg -mfentry -fasynchronous-unwind-tables" } */
+/* { dg-final { scan-assembler-times {\t\.cfi_startproc\n\tendbr} 1 } } */
+
+extern int bar (int);
+
+int
+foo (int i)
+{
+ return bar (i);
+}
--- /dev/null
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fcf-protection -mfentry -fasynchronous-unwind-tables" } */
+/* { dg-final { scan-assembler-times {\t\.cfi_startproc\n\tendbr} 1 } } */
+
+extern int bar (int);
+
+int
+foo (int i)
+{
+ return bar (i);
+}
--- /dev/null
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fcf-protection -pg -mfentry -mrecord-mcount -mnop-mcount -fasynchronous-unwind-tables" } */
+/* { dg-final { scan-assembler-times {\t\.cfi_startproc\n\tendbr} 1 } } */
+
+extern int bar (int);
+
+int
+foo (int i)
+{
+ return bar (i);
+}