+2020-04-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/94417
+ * config/i386/i386-features.c (rest_of_insert_endbranch): Insert
+ ENDBR at function entry if function will be called indirectly.
+
2020-04-08 Jakub Jelinek <jakub@redhat.com>
PR target/94438
&& (!flag_manual_endbr
|| lookup_attribute ("cf_check",
DECL_ATTRIBUTES (cfun->decl)))
- && !cgraph_node::get (cfun->decl)->only_called_directly_p ())
+ && (!cgraph_node::get (cfun->decl)->only_called_directly_p ()
+ || ix86_cmodel == CM_LARGE
+ || ix86_cmodel == CM_LARGE_PIC
+ || flag_force_indirect_call
+ || (TARGET_DLLIMPORT_DECL_ATTRIBUTES
+ && DECL_DLLIMPORT_P (cfun->decl))))
{
/* Queue ENDBR insertion to x86_function_profiler. */
if (crtl->profile && flag_fentry)
+2020-04-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/94417
+ * gcc.target/i386/pr94417-1.c: New test.
+ * gcc.target/i386/pr94417-2.c: Likewise.
+ * gcc.target/i386/pr94417-3.c: Likewise.
+
2020-04-08 Jakub Jelinek <jakub@redhat.com>
PR target/94438
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -fcf-protection -mcmodel=large" } */
+/* { dg-final { scan-assembler-times {\mendbr} 2 } } */
+
+extern void ext (void);
+
+__attribute((noclone, noinline))
+static
+void
+foo (void)
+{
+ ext ();
+}
+
+void
+bar (void)
+{
+ foo ();
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-O2 -fpic -mcmodel=large -fcf-protection" } */
+/* { dg-final { scan-assembler-times {\mendbr} 2 } } */
+
+extern void ext (void);
+
+__attribute((noclone, noinline))
+static
+void
+foo (void)
+{
+ ext ();
+}
+
+void
+bar (void)
+{
+ foo ();
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcf-protection -mforce-indirect-call" } */
+/* { dg-final { scan-assembler-times {\mendbr} 2 } } */
+
+extern void ext (void);
+
+__attribute((noclone, noinline))
+static
+void
+foo (void)
+{
+ ext ();
+}
+
+void
+bar (void)
+{
+ foo ();
+}