-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISCV] Disallow target attribute use in multiversioning #85899
Conversation
@llvm/pr-subscribers-backend-risc-v @llvm/pr-subscribers-clang Author: Piyou Chen (BeMg) ChangesFor RISC-V target only 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:
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()) {
|
The proposal could be found here riscv-non-isa/riscv-c-api-doc#48. |
Add a testcase like AArch64 https://reviews.llvm.org/D150867 ? |
clang/lib/Sema/SemaDecl.cpp
Outdated
@@ -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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we share S.getASTContext().getTargetInfo().getTriple()
with AArch64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
6757bf5
to
b9a2a5e
Compare
For RISC-V target only
target_clones
andtarget_version
can enable function multiversion(FMV).This patch make target attribute trigger redefinition instead of emit FMV.
Here is spec https://github.com/riscv-non-isa/riscv-c-api-doc/blob/master/riscv-c-api.md#__attribute__targetattr-string