Author: Jim Lin
Date: 2024-10-18T14:39:54+08:00
New Revision: e8509a43acb286181aa84f8035ece3b59562cd10

URL: 
https://github.com/llvm/llvm-project/commit/e8509a43acb286181aa84f8035ece3b59562cd10
DIFF: 
https://github.com/llvm/llvm-project/commit/e8509a43acb286181aa84f8035ece3b59562cd10.diff

LOG: [RISCV] Check if v extension is enabled by the function features for the 
builtins not in Zve64*. (#112827)

Fixes: https://github.com/llvm/llvm-project/issues/109694

Added: 
    

Modified: 
    clang/lib/Sema/SemaRISCV.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp
index 3da4b515b1b114..d1ccc2774152b1 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";


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to