[clang] [RISCV] Disallow target attribute use in multiversioning (PR #85899)

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 26 17:44:36 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Piyou Chen (BeMg)

<details>
<summary>Changes</summary>

For RISC-V target only `target_clones` and `target_version` can enable function multiversion(FMV). 

This patch make target attribute trigger redefinition instead of emit FMV.

---
Full diff: https://github.com/llvm/llvm-project/pull/85899.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaDecl.cpp (+4) 


``````````diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5850cd0ab6b9aa..e543aff77e67ea 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11853,6 +11853,10 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD,
   if (NewTA && S.getASTContext().getTargetInfo().getTriple().isAArch64())
     return false;
 
+  // Target attribute on RISCV is not used for multiversioning
+  if (NewTA && S.getASTContext().getTargetInfo().getTriple().isRISCV())
+    return false;
+
   if (!OldDecl || !OldDecl->getAsFunction() ||
       OldDecl->getDeclContext()->getRedeclContext() !=
           NewFD->getDeclContext()->getRedeclContext()) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/85899


More information about the cfe-commits mailing list