diff mbox series

[v3,08/11] RISC-V: Do not inline when callee is versioned but caller is not

Message ID tencent_C3E091F688A317EE7F4C5B087B2338DF8006@qq.com
State New
Headers show
Series RISC-V: Add Function Multi-Versioning support | expand

Commit Message

Yangyu Chen Oct. 24, 2024, 7:12 a.m. UTC
When the callee is versioned but the caller is not, we should not inline
the callee into the caller, to prevent the default version of the callee
from being inlined into a not versioned caller.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_can_inline_p): Refuse to inline
	when callee is versioned but caller is not.
---
 gcc/config/riscv/riscv.cc | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kito Cheng Oct. 31, 2024, 10:37 a.m. UTC | #1
Good catch, I think it makes sense since a user using FMV means they
care about the performance of that function, so we should keep the
call and not inline here.

This should be committed after the FMV is implemented, but I think
this is simple enough, so I committed this to trunk :)


On Thu, Oct 24, 2024 at 3:16 PM Yangyu Chen <cyy@cyyself.name> wrote:
>
> When the callee is versioned but the caller is not, we should not inline
> the callee into the caller, to prevent the default version of the callee
> from being inlined into a not versioned caller.
>
> gcc/ChangeLog:
>
>         * config/riscv/riscv.cc (riscv_can_inline_p): Refuse to inline
>         when callee is versioned but caller is not.
> ---
>  gcc/config/riscv/riscv.cc | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index f7082df22ef..46961360096 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -7666,6 +7666,10 @@ riscv_compute_frame_info (void)
>  static bool
>  riscv_can_inline_p (tree caller, tree callee)
>  {
> +  /* Do not inline when callee is versioned but caller is not.  */
> +  if (DECL_FUNCTION_VERSIONED (callee) && ! DECL_FUNCTION_VERSIONED (caller))
> +    return false;
> +
>    tree callee_tree = DECL_FUNCTION_SPECIFIC_TARGET (callee);
>    tree caller_tree = DECL_FUNCTION_SPECIFIC_TARGET (caller);
>
> --
> 2.45.2
>
diff mbox series

Patch

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index f7082df22ef..46961360096 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -7666,6 +7666,10 @@  riscv_compute_frame_info (void)
 static bool
 riscv_can_inline_p (tree caller, tree callee)
 {
+  /* Do not inline when callee is versioned but caller is not.  */
+  if (DECL_FUNCTION_VERSIONED (callee) && ! DECL_FUNCTION_VERSIONED (caller))
+    return false;
+
   tree callee_tree = DECL_FUNCTION_SPECIFIC_TARGET (callee);
   tree caller_tree = DECL_FUNCTION_SPECIFIC_TARGET (caller);