@@ -20554,6 +20554,17 @@ aarch64_option_valid_attribute_p (tree fndecl, tree, tree args, int)
return ret;
}
+/* Implement TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P. Use an opt-out
+ rather than an opt-in list. */
+
+static bool
+aarch64_function_attribute_inlinable_p (const_tree fndecl)
+{
+ /* A function that has local ZA state cannot be inlined into its caller,
+ since we only support managing ZA switches at function scope. */
+ return !aarch64_fndecl_has_new_za_state (fndecl);
+}
+
/* Helper for aarch64_can_inline_p. In the case where CALLER and CALLEE are
tri-bool options (yes, no, don't care) and the default value is
DEF, determine whether to reject inlining. */
@@ -20597,12 +20608,20 @@ aarch64_can_inline_p (tree caller, tree callee)
: target_option_default_node);
/* Callee's ISA flags should be a subset of the caller's. */
- if ((caller_opts->x_aarch64_asm_isa_flags
- & callee_opts->x_aarch64_asm_isa_flags)
- != callee_opts->x_aarch64_asm_isa_flags)
+ auto caller_asm_isa = (caller_opts->x_aarch64_isa_flags
+ & ~AARCH64_FL_ISA_MODES);
+ auto callee_asm_isa = (callee_opts->x_aarch64_isa_flags
+ & ~AARCH64_FL_ISA_MODES);
+ if (callee_asm_isa & ~caller_asm_isa)
return false;
- if ((caller_opts->x_aarch64_isa_flags & callee_opts->x_aarch64_isa_flags)
- != callee_opts->x_aarch64_isa_flags)
+
+ auto caller_isa = ((caller_opts->x_aarch64_isa_flags
+ & ~AARCH64_FL_ISA_MODES)
+ | aarch64_fndecl_isa_mode (caller));
+ auto callee_isa = ((callee_opts->x_aarch64_isa_flags
+ & ~AARCH64_FL_ISA_MODES)
+ | aarch64_fndecl_isa_mode (callee));
+ if (callee_isa & ~caller_isa)
return false;
/* Allow non-strict aligned functions inlining into strict
@@ -29150,6 +29169,10 @@ aarch64_run_selftests (void)
#undef TARGET_CAN_ELIMINATE
#define TARGET_CAN_ELIMINATE aarch64_can_eliminate
+#undef TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P
+#define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P \
+ aarch64_function_attribute_inlinable_p
+
#undef TARGET_CAN_INLINE_P
#define TARGET_CAN_INLINE_P aarch64_can_inline_p
new file mode 100644
@@ -0,0 +1,26 @@
+/* { dg-options "" } */
+
+inline void __attribute__((always_inline, arm_streaming_compatible))
+sc_callee () {}
+
+inline void __attribute__((always_inline, arm_streaming))
+s_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline))
+n_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline, arm_streaming_compatible, arm_locally_streaming))
+sc_ls_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline, arm_locally_streaming))
+n_ls_callee () {} // { dg-error "inlining failed" }
+
+void __attribute__((arm_streaming_compatible))
+sc_caller ()
+{
+ sc_callee ();
+ s_callee ();
+ n_callee ();
+ sc_ls_callee ();
+ n_ls_callee ();
+}
new file mode 100644
@@ -0,0 +1,26 @@
+/* { dg-options "" } */
+
+inline void __attribute__((always_inline, arm_streaming_compatible))
+sc_callee () {}
+
+inline void __attribute__((always_inline, arm_streaming))
+s_callee () {}
+
+inline void __attribute__((always_inline))
+n_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline, arm_streaming_compatible, arm_locally_streaming))
+sc_ls_callee () {}
+
+inline void __attribute__((always_inline, arm_locally_streaming))
+n_ls_callee () {}
+
+void __attribute__((arm_streaming))
+s_caller ()
+{
+ sc_callee ();
+ s_callee ();
+ n_callee ();
+ sc_ls_callee ();
+ n_ls_callee ();
+}
new file mode 100644
@@ -0,0 +1,26 @@
+/* { dg-options "" } */
+
+inline void __attribute__((always_inline, arm_streaming_compatible))
+sc_callee () {}
+
+inline void __attribute__((always_inline, arm_streaming))
+s_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline))
+n_callee () {}
+
+inline void __attribute__((always_inline, arm_streaming_compatible, arm_locally_streaming))
+sc_ls_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline, arm_locally_streaming))
+n_ls_callee () {} // { dg-error "inlining failed" }
+
+void
+n_caller ()
+{
+ sc_callee ();
+ s_callee ();
+ n_callee ();
+ sc_ls_callee ();
+ n_ls_callee ();
+}
new file mode 100644
@@ -0,0 +1,26 @@
+/* { dg-options "" } */
+
+inline void __attribute__((always_inline, arm_streaming_compatible))
+sc_callee () {}
+
+inline void __attribute__((always_inline, arm_streaming))
+s_callee () {}
+
+inline void __attribute__((always_inline))
+n_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline, arm_streaming_compatible, arm_locally_streaming))
+sc_ls_callee () {}
+
+inline void __attribute__((always_inline, arm_locally_streaming))
+n_ls_callee () {}
+
+void __attribute__((arm_streaming_compatible, arm_locally_streaming))
+sc_ls_caller ()
+{
+ sc_callee ();
+ s_callee ();
+ n_callee ();
+ sc_ls_callee ();
+ n_ls_callee ();
+}
new file mode 100644
@@ -0,0 +1,26 @@
+/* { dg-options "" } */
+
+inline void __attribute__((always_inline, arm_streaming_compatible))
+sc_callee () {}
+
+inline void __attribute__((always_inline, arm_streaming))
+s_callee () {}
+
+inline void __attribute__((always_inline))
+n_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline, arm_streaming_compatible, arm_locally_streaming))
+sc_ls_callee () {}
+
+inline void __attribute__((always_inline, arm_locally_streaming))
+n_ls_callee () {}
+
+void __attribute__((arm_locally_streaming))
+n_ls_caller ()
+{
+ sc_callee ();
+ s_callee ();
+ n_callee ();
+ sc_ls_callee ();
+ n_ls_callee ();
+}
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-options "" } */
+
+inline void __attribute__((always_inline, arm_shared_za))
+shared_callee () {}
+
+inline void __attribute__((always_inline, arm_new_za))
+new_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline))
+normal_callee () {}
+
+void __attribute__((arm_shared_za))
+shared_caller ()
+{
+ shared_callee ();
+ new_callee ();
+ normal_callee ();
+}
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-options "" } */
+
+inline void __attribute__((always_inline, arm_shared_za))
+shared_callee () {}
+
+inline void __attribute__((always_inline, arm_new_za))
+new_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline))
+normal_callee () {}
+
+void __attribute__((arm_new_za))
+new_caller ()
+{
+ shared_callee ();
+ new_callee ();
+ normal_callee ();
+}
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-options "" } */
+
+inline void __attribute__((always_inline, arm_shared_za))
+shared_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline, arm_new_za))
+new_callee () {} // { dg-error "inlining failed" }
+
+inline void __attribute__((always_inline))
+normal_callee () {}
+
+void
+normal_caller ()
+{
+ shared_callee ();
+ new_callee ();
+ normal_callee ();
+}