]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Do not inline when callee is versioned but caller is not
authorYangyu Chen <cyy@cyyself.name>
Thu, 24 Oct 2024 07:12:45 +0000 (15:12 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 31 Oct 2024 10:37:51 +0000 (18:37 +0800)
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

index 8443b29fb8f59489092eeeceb25b4b0a71fff489..0b3b2c4cba91c3b60efdefcd482470dee9aacf03 100644 (file)
@@ -7693,6 +7693,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);