https://gcc.gnu.org/g:3a533e006d9c81b0b26a95729647911f3c0c2113

commit 3a533e006d9c81b0b26a95729647911f3c0c2113
Author: Yangyu Chen <c...@cyyself.name>
Date:   Thu Oct 24 15:12:45 2024 +0800

    RISC-V: Do not inline when callee is versioned but caller is not
    
    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.
    
    (cherry picked from commit eb828a1e380e7bb5a708c899081541ee9130ff87)

Diff:
---
 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 912ae3ac0129..2ea91e1fc138 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -7692,6 +7692,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);

Reply via email to