[clang] [RISCV] Check if v extension is enabled by the function features for the builtins not in Zve64*. (PR #112827)
Jim Lin via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 17 20:51:17 PDT 2024
https://github.com/tclin914 updated https://github.com/llvm/llvm-project/pull/112827
>From a1b6a764dd93ecb33b493c14c396c5c040be0412 Mon Sep 17 00:00:00 2001
From: Jim Lin <jim at andestech.com>
Date: Fri, 18 Oct 2024 11:11:02 +0800
Subject: [PATCH 1/2] [RISCV] Check if v extension is enabled by the function
features for the builtins not in Zve64*.
Fixes: https://github.com/llvm/llvm-project/issues/109694
---
clang/lib/Sema/SemaRISCV.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp
index 3da4b515b1b114..3f1c2999286f3f 100644
--- a/clang/lib/Sema/SemaRISCV.cpp
+++ b/clang/lib/Sema/SemaRISCV.cpp
@@ -623,7 +623,12 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(
TheCall->getType()->castAs<BuiltinType>());
- if (Context.getTypeSize(Info.ElementType) == 64 && !TI.hasFeature("v"))
+ const FunctionDecl *FD = SemaRef.getCurFunctionDecl();
+ llvm::StringMap<bool> FunctionFeatureMap;
+ Context.getFunctionFeatureMap(FunctionFeatureMap, FD);
+
+ if (Context.getTypeSize(Info.ElementType) == 64 && !TI.hasFeature("v")
+ && !FunctionFeatureMap.lookup("v"))
return Diag(TheCall->getBeginLoc(),
diag::err_riscv_builtin_requires_extension)
<< /* IsExtension */ true << TheCall->getSourceRange() << "v";
>From ef6850dc40ad19fead0b8eecac8a0676d66df292 Mon Sep 17 00:00:00 2001
From: Jim Lin <jim at andestech.com>
Date: Fri, 18 Oct 2024 11:43:55 +0800
Subject: [PATCH 2/2] clang-format
---
clang/lib/Sema/SemaRISCV.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp
index 3f1c2999286f3f..d1ccc2774152b1 100644
--- a/clang/lib/Sema/SemaRISCV.cpp
+++ b/clang/lib/Sema/SemaRISCV.cpp
@@ -627,8 +627,8 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
llvm::StringMap<bool> FunctionFeatureMap;
Context.getFunctionFeatureMap(FunctionFeatureMap, FD);
- if (Context.getTypeSize(Info.ElementType) == 64 && !TI.hasFeature("v")
- && !FunctionFeatureMap.lookup("v"))
+ if (Context.getTypeSize(Info.ElementType) == 64 && !TI.hasFeature("v") &&
+ !FunctionFeatureMap.lookup("v"))
return Diag(TheCall->getBeginLoc(),
diag::err_riscv_builtin_requires_extension)
<< /* IsExtension */ true << TheCall->getSourceRange() << "v";
More information about the cfe-commits
mailing list