Skip to content
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][FMV] Support target_version #99040

Merged
merged 13 commits into from
Oct 4, 2024
Merged

Conversation

BeMg
Copy link
Contributor

@BeMg BeMg commented Jul 16, 2024

This patch enable target_version attribute for RISC-V target.

The proposal of target_version syntax can be found at the riscv-non-isa/riscv-c-api-doc#48 (which has landed), as modified by the proposed riscv-non-isa/riscv-c-api-doc#85 (which adds the priority syntax).

target_version attribute will trigger the function multi-versioning feature and act like target_clones attribute. See #85786 for the implementation of target_clones.

@BeMg BeMg requested review from preames, kito-cheng and topperc July 16, 2024 13:34
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:RISC-V clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen labels Jul 16, 2024
@BeMg
Copy link
Contributor Author

BeMg commented Jul 16, 2024

Stack on #94440 and #85786

@llvmbot
Copy link
Member

llvmbot commented Jul 16, 2024

@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-backend-risc-v

Author: Piyou Chen (BeMg)

Changes

This patch enable target_version attribute for RISC-V target.

The proposal of target_version syntax can be found at the riscv-non-isa/riscv-c-api-doc#48.

target_version attribute will trigger the function multi-versioning feature and act like target_clones attribute.


Patch is 91.18 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/99040.diff

22 Files Affected:

  • (modified) clang/include/clang/Basic/DiagnosticFrontendKinds.td (+4)
  • (modified) clang/include/clang/Basic/TargetInfo.h (+2-1)
  • (modified) clang/lib/AST/ASTContext.cpp (+22-3)
  • (modified) clang/lib/CodeGen/CGBuiltin.cpp (+78)
  • (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+90-1)
  • (modified) clang/lib/CodeGen/CodeGenFunction.h (+7)
  • (modified) clang/lib/CodeGen/CodeGenModule.cpp (+12-2)
  • (modified) clang/lib/CodeGen/Targets/RISCV.cpp (+23)
  • (modified) clang/lib/Sema/SemaDecl.cpp (+31-12)
  • (modified) clang/lib/Sema/SemaDeclAttr.cpp (+41)
  • (added) clang/test/CodeGen/attr-target-clones-riscv-invaild.c (+8)
  • (added) clang/test/CodeGen/attr-target-clones-riscv.c (+205)
  • (added) clang/test/CodeGen/attr-target-version-riscv.c (+141)
  • (added) clang/test/CodeGenCXX/attr-target-clones-riscv.cpp (+204)
  • (added) clang/test/CodeGenCXX/attr-target-version-riscv.cpp (+140)
  • (added) clang/test/SemaCXX/attr-target-clones-riscv.cpp (+32)
  • (added) clang/test/SemaCXX/attr-target-version-riscv.cpp (+32)
  • (modified) llvm/include/llvm/TargetParser/RISCVTargetParser.h (+12)
  • (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+92-42)
  • (modified) llvm/lib/TargetParser/RISCVTargetParser.cpp (+46)
  • (modified) llvm/test/TableGen/riscv-target-def.td (+16-2)
  • (modified) llvm/utils/TableGen/RISCVTargetDefEmitter.cpp (+37)
diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 12a4617c64d87..b2b63674ecc07 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -375,4 +375,8 @@ def warn_missing_symbol_graph_dir : Warning<
 def err_ast_action_on_llvm_ir : Error<
   "cannot apply AST actions to LLVM IR file '%0'">,
   DefaultFatal;
+
+def err_os_unsupport_riscv_target_clones : Error<
+  "target_clones is currently only supported on Linux">;
+
 }
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index cf7628553647c..40fbc3a1116cb 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1519,7 +1519,8 @@ class TargetInfo : public TransferrableTargetInfo,
   /// Identify whether this target supports multiversioning of functions,
   /// which requires support for cpu_supports and cpu_is functionality.
   bool supportsMultiVersioning() const {
-    return getTriple().isX86() || getTriple().isAArch64();
+    return getTriple().isX86() || getTriple().isAArch64() ||
+           getTriple().isRISCV();
   }
 
   /// Identify whether this target supports IFuncs.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 8e35e71d4a23e..e0d3fa514a049 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -13839,6 +13839,18 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
                       Target->getTargetOpts().FeaturesAsWritten.begin(),
                       Target->getTargetOpts().FeaturesAsWritten.end());
       Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
+    } else if (Target->getTriple().isRISCV()) {
+      StringRef VersionStr = TC->getFeatureStr(GD.getMultiVersionIndex());
+      std::vector<std::string> Features;
+      if (VersionStr != "default") {
+        ParsedTargetAttr ParsedAttr = Target->parseTargetAttr(VersionStr);
+        Features.insert(Features.begin(), ParsedAttr.Features.begin(),
+                        ParsedAttr.Features.end());
+      }
+      Features.insert(Features.begin(),
+                      Target->getTargetOpts().FeaturesAsWritten.begin(),
+                      Target->getTargetOpts().FeaturesAsWritten.end());
+      Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
     } else {
       std::vector<std::string> Features;
       StringRef VersionStr = TC->getFeatureStr(GD.getMultiVersionIndex());
@@ -13849,9 +13861,16 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
       Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
     }
   } else if (const auto *TV = FD->getAttr<TargetVersionAttr>()) {
-    llvm::SmallVector<StringRef, 8> Feats;
-    TV->getFeatures(Feats);
-    std::vector<std::string> Features = getFMVBackendFeaturesFor(Feats);
+    std::vector<std::string> Features;
+    if (Target->getTriple().isRISCV()) {
+      ParsedTargetAttr ParsedAttr = Target->parseTargetAttr(TV->getName());
+      Features.insert(Features.begin(), ParsedAttr.Features.begin(),
+                      ParsedAttr.Features.end());
+    } else {
+      llvm::SmallVector<StringRef, 8> Feats;
+      TV->getFeatures(Feats);
+      Features = getFMVBackendFeaturesFor(Feats);
+    }
     Features.insert(Features.begin(),
                     Target->getTargetOpts().FeaturesAsWritten.begin(),
                     Target->getTargetOpts().FeaturesAsWritten.end());
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 6cc0d9485720c..83ad64cb1cc3c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -62,6 +62,7 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/TargetParser/AArch64TargetParser.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 #include "llvm/TargetParser/X86TargetParser.h"
 #include <optional>
 #include <sstream>
@@ -14214,6 +14215,16 @@ Value *CodeGenFunction::EmitAArch64CpuInit() {
   return Builder.CreateCall(Func);
 }
 
+Value *CodeGenFunction::EmitRISCVCpuInit() {
+  llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
+  llvm::FunctionCallee Func =
+      CGM.CreateRuntimeFunction(FTy, "__init_riscv_features_bits");
+  cast<llvm::GlobalValue>(Func.getCallee())->setDSOLocal(true);
+  cast<llvm::GlobalValue>(Func.getCallee())
+      ->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
+  return Builder.CreateCall(Func);
+}
+
 Value *CodeGenFunction::EmitX86CpuInit() {
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
                                                     /*Variadic*/ false);
@@ -14266,6 +14277,73 @@ CodeGenFunction::EmitAArch64CpuSupports(ArrayRef<StringRef> FeaturesStrs) {
   return Result;
 }
 
+Value *CodeGenFunction::EmitRISCVCpuSupports(ArrayRef<StringRef> FeaturesStrs,
+                                             unsigned &MaxGroupIDUsed) {
+
+  const unsigned FeatureBitSize = llvm::RISCV::RISCVFeatureBitSize;
+  llvm::ArrayType *ArrayOfInt64Ty =
+      llvm::ArrayType::get(Int64Ty, FeatureBitSize);
+  llvm::Type *StructTy = llvm::StructType::get(Int32Ty, ArrayOfInt64Ty);
+  llvm::Constant *RISCVFeaturesBits =
+      CGM.CreateRuntimeVariable(StructTy, "__riscv_feature_bits");
+  cast<llvm::GlobalValue>(RISCVFeaturesBits)->setDSOLocal(true);
+
+  auto LoadFeatureBit = [&](unsigned Index) {
+    // Create GEP then load.
+    Value *IndexVal = llvm::ConstantInt::get(Int32Ty, Index);
+    std::vector<llvm::Value *> GEPIndices = {llvm::ConstantInt::get(Int32Ty, 0),
+                                             llvm::ConstantInt::get(Int32Ty, 1),
+                                             IndexVal};
+    Value *Ptr =
+        Builder.CreateInBoundsGEP(StructTy, RISCVFeaturesBits, GEPIndices);
+    Value *FeaturesBit =
+        Builder.CreateAlignedLoad(Int64Ty, Ptr, CharUnits::fromQuantity(8));
+    return FeaturesBit;
+  };
+
+  SmallVector<unsigned long long> RequireFeatureBits =
+      llvm::RISCV::getRequireFeatureBitMask(FeaturesStrs);
+  Value *Result = Builder.getTrue();
+  for (unsigned i = 0; i < RequireFeatureBits.size(); i++) {
+    if (!RequireFeatureBits[i])
+      continue;
+    MaxGroupIDUsed = i;
+    Value *Mask = Builder.getInt64(RequireFeatureBits[i]);
+    Value *Bitset = Builder.CreateAnd(LoadFeatureBit(i), Mask);
+    Value *Cmp = Builder.CreateICmpEQ(Bitset, Mask);
+    Result = Builder.CreateAnd(Result, Cmp);
+  }
+
+  return Result;
+}
+
+Value *CodeGenFunction::EmitRISCVFeatureBitsLength(unsigned MaxGroupIDUsed) {
+
+  const unsigned FeatureBitSize = llvm::RISCV::RISCVFeatureBitSize;
+  llvm::ArrayType *ArrayOfInt64Ty =
+      llvm::ArrayType::get(Int64Ty, FeatureBitSize);
+  llvm::Type *StructTy = llvm::StructType::get(Int32Ty, ArrayOfInt64Ty);
+  llvm::Constant *RISCVFeaturesBits =
+      CGM.CreateRuntimeVariable(StructTy, "__riscv_feature_bits");
+  cast<llvm::GlobalValue>(RISCVFeaturesBits)->setDSOLocal(true);
+
+  auto LoadMaxGroupID = [&]() {
+    std::vector<llvm::Value *> GEPIndices = {
+        llvm::ConstantInt::get(Int32Ty, 0), llvm::ConstantInt::get(Int32Ty, 0)};
+    llvm::Value *Ptr =
+        Builder.CreateInBoundsGEP(StructTy, RISCVFeaturesBits, GEPIndices);
+    Value *Length =
+        Builder.CreateAlignedLoad(Int64Ty, Ptr, CharUnits::fromQuantity(8));
+    return Length;
+  };
+
+  Value *UsedMaxGroupID = Builder.getInt64(MaxGroupIDUsed);
+  Value *GroupIDResult =
+      Builder.CreateICmpULT(UsedMaxGroupID, LoadMaxGroupID());
+
+  return GroupIDResult;
+}
+
 Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
                                            const CallExpr *E) {
   if (BuiltinID == Builtin::BI__builtin_cpu_is)
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 26deeca95d326..f2b2915878a90 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2854,12 +2854,101 @@ void CodeGenFunction::EmitMultiVersionResolver(
   case llvm::Triple::aarch64:
     EmitAArch64MultiVersionResolver(Resolver, Options);
     return;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+    EmitRISCVMultiVersionResolver(Resolver, Options);
+    return;
 
   default:
-    assert(false && "Only implemented for x86 and AArch64 targets");
+    assert(false && "Only implemented for x86, AArch64 and RISC-V targets");
   }
 }
 
+void CodeGenFunction::EmitRISCVMultiVersionResolver(
+    llvm::Function *Resolver, ArrayRef<MultiVersionResolverOption> Options) {
+
+  if (getContext().getTargetInfo().getTriple().getOS() !=
+      llvm::Triple::OSType::Linux) {
+    CGM.getDiags().Report(diag::err_os_unsupport_riscv_target_clones);
+    return;
+  }
+
+  llvm::BasicBlock *CurBlock = createBasicBlock("resolver_entry", Resolver);
+  Builder.SetInsertPoint(CurBlock);
+  EmitRISCVCpuInit();
+
+  bool SupportsIFunc = getContext().getTargetInfo().supportsIFunc();
+  bool HasDefault = false;
+  int DefaultIndex = 0;
+  // Check the each candidate function.
+  for (unsigned Index = 0; Index < Options.size(); Index++) {
+
+    if (Options[Index].Conditions.Features[0].starts_with("default")) {
+      HasDefault = true;
+      DefaultIndex = Index;
+      continue;
+    }
+
+    Builder.SetInsertPoint(CurBlock);
+
+    std::vector<std::string> TargetAttrFeats =
+        getContext()
+            .getTargetInfo()
+            .parseTargetAttr(Options[Index].Conditions.Features[0])
+            .Features;
+
+    if (!TargetAttrFeats.empty()) {
+
+      llvm::BasicBlock *SecondCond =
+          createBasicBlock("resovler_cond", Resolver);
+
+      Builder.SetInsertPoint(SecondCond);
+      unsigned MaxGroupIDUsed = 0;
+      llvm::SmallVector<StringRef, 8> CurrTargetAttrFeats;
+
+      for (auto Feat : TargetAttrFeats)
+        CurrTargetAttrFeats.push_back(StringRef(Feat).substr(1));
+
+      llvm::Value *SecondCondition =
+          EmitRISCVCpuSupports(CurrTargetAttrFeats, MaxGroupIDUsed);
+
+      Builder.SetInsertPoint(CurBlock);
+      llvm::Value *FirstCondition = EmitRISCVFeatureBitsLength(MaxGroupIDUsed);
+
+      llvm::BasicBlock *RetBlock =
+          createBasicBlock("resolver_return", Resolver);
+      CGBuilderTy RetBuilder(*this, RetBlock);
+      CreateMultiVersionResolverReturn(CGM, Resolver, RetBuilder,
+                                       Options[Index].Function, SupportsIFunc);
+      llvm::BasicBlock *ElseBlock = createBasicBlock("resolver_else", Resolver);
+
+      Builder.SetInsertPoint(CurBlock);
+      Builder.CreateCondBr(FirstCondition, SecondCond, ElseBlock);
+
+      Builder.SetInsertPoint(SecondCond);
+      Builder.CreateCondBr(SecondCondition, RetBlock, ElseBlock);
+
+      CurBlock = ElseBlock;
+    }
+  }
+
+  // Finally, emit the default one.
+  if (HasDefault) {
+    Builder.SetInsertPoint(CurBlock);
+    CreateMultiVersionResolverReturn(
+        CGM, Resolver, Builder, Options[DefaultIndex].Function, SupportsIFunc);
+    return;
+  }
+
+  // If no generic/default, emit an unreachable.
+  Builder.SetInsertPoint(CurBlock);
+  llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
+  TrapCall->setDoesNotReturn();
+  TrapCall->setDoesNotThrow();
+  Builder.CreateUnreachable();
+  Builder.ClearInsertionPoint();
+}
+
 void CodeGenFunction::EmitAArch64MultiVersionResolver(
     llvm::Function *Resolver, ArrayRef<MultiVersionResolverOption> Options) {
   assert(!Options.empty() && "No multiversion resolver options found");
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 13f12b5d878a6..107701d3f1faa 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -5291,6 +5291,9 @@ class CodeGenFunction : public CodeGenTypeCache {
   void
   EmitAArch64MultiVersionResolver(llvm::Function *Resolver,
                                   ArrayRef<MultiVersionResolverOption> Options);
+  void
+  EmitRISCVMultiVersionResolver(llvm::Function *Resolver,
+                                ArrayRef<MultiVersionResolverOption> Options);
 
 private:
   QualType getVarArgType(const Expr *Arg);
@@ -5315,6 +5318,10 @@ class CodeGenFunction : public CodeGenTypeCache {
   FormAArch64ResolverCondition(const MultiVersionResolverOption &RO);
   llvm::Value *EmitAArch64CpuSupports(const CallExpr *E);
   llvm::Value *EmitAArch64CpuSupports(ArrayRef<StringRef> FeatureStrs);
+  llvm::Value *EmitRISCVCpuInit();
+  llvm::Value *EmitRISCVCpuSupports(ArrayRef<StringRef> FeatureStrs,
+                                    unsigned &MaxGroupIDUsed);
+  llvm::Value *EmitRISCVFeatureBitsLength(unsigned MaxGroupIDUsed);
 };
 
 inline DominatingLLVMValue::saved_type
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 5c810cd332185..c65283960fc6e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4243,8 +4243,15 @@ void CodeGenModule::emitMultiVersionFunctions() {
                                  CurFD->doesThisDeclarationHaveABody();
             HasDefaultDecl |= TVA->isDefaultVersion();
             ShouldEmitResolver |= (CurFD->isUsed() || HasDefaultDef);
-            TVA->getFeatures(Feats);
             llvm::Function *Func = createFunction(CurFD);
+            if (getTarget().getTriple().isRISCV()) {
+              llvm::AttrBuilder FuncAttrs(Func->getContext());
+              ParsedTargetAttr PTA =
+                  getTarget().parseTargetAttr(TVA->getName());
+              Feats.push_back(TVA->getName());
+            } else {
+              TVA->getFeatures(Feats);
+            }
             Options.emplace_back(Func, /*Architecture*/ "", Feats);
           } else if (const auto *TC = CurFD->getAttr<TargetClonesAttr>()) {
             ShouldEmitResolver |= CurFD->doesThisDeclarationHaveABody();
@@ -4257,7 +4264,10 @@ void CodeGenModule::emitMultiVersionFunctions() {
               Feats.clear();
               if (getTarget().getTriple().isAArch64())
                 TC->getFeatures(Feats, I);
-              else {
+              else if (getTarget().getTriple().isRISCV()) {
+                StringRef Version = TC->getFeatureStr(I);
+                Feats.push_back(Version);
+              } else {
                 StringRef Version = TC->getFeatureStr(I);
                 if (Version.starts_with("arch="))
                   Architecture = Version.drop_front(sizeof("arch=") - 1);
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp
index f2add9351c03c..ba81bf7d1dd0a 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -63,9 +63,32 @@ class RISCVABIInfo : public DefaultABIInfo {
                                                CharUnits Field2Off) const;
 
   ABIArgInfo coerceVLSVector(QualType Ty) const;
+
+  using ABIInfo::appendAttributeMangling;
+  void appendAttributeMangling(TargetClonesAttr *Attr, unsigned Index,
+                               raw_ostream &Out) const override;
+  void appendAttributeMangling(StringRef AttrStr,
+                               raw_ostream &Out) const override;
 };
 } // end anonymous namespace
 
+void RISCVABIInfo::appendAttributeMangling(TargetClonesAttr *Attr,
+                                           unsigned Index,
+                                           raw_ostream &Out) const {
+  appendAttributeMangling(Attr->getFeatureStr(Index), Out);
+}
+
+void RISCVABIInfo::appendAttributeMangling(StringRef AttrStr,
+                                           raw_ostream &Out) const {
+  if (AttrStr == "default") {
+    Out << ".default";
+    return;
+  }
+
+  Out << '.';
+  Out << AttrStr;
+}
+
 void RISCVABIInfo::computeInfo(CGFunctionInfo &FI) const {
   QualType RetTy = FI.getReturnType();
   if (!getCXXABI().classifyReturnType(FI))
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 66eeaa8e6f777..fd3af45114110 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10259,8 +10259,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
   // Handle attributes.
   ProcessDeclAttributes(S, NewFD, D);
   const auto *NewTVA = NewFD->getAttr<TargetVersionAttr>();
-  if (NewTVA && !NewTVA->isDefaultVersion() &&
-      !Context.getTargetInfo().hasFeature("fmv")) {
+  if (Context.getTargetInfo().getTriple().isRISCV()) {
+    // Go thought anyway.
+  } else if (NewTVA && !NewTVA->isDefaultVersion() &&
+             !Context.getTargetInfo().hasFeature("fmv")) {
     // Don't add to scope fmv functions declarations if fmv disabled
     AddToScope = false;
     return NewFD;
@@ -10967,13 +10969,27 @@ static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD) {
   }
 
   if (TVA) {
-    llvm::SmallVector<StringRef, 8> Feats;
-    TVA->getFeatures(Feats);
-    for (const auto &Feat : Feats) {
-      if (!TargetInfo.validateCpuSupports(Feat)) {
-        S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
-            << Feature << Feat;
-        return true;
+    if (S.getASTContext().getTargetInfo().getTriple().isRISCV()) {
+      ParsedTargetAttr ParseInfo =
+          S.getASTContext().getTargetInfo().parseTargetAttr(TVA->getName());
+      for (const auto &Feat : ParseInfo.Features) {
+        StringRef BareFeat = StringRef{Feat}.substr(1);
+
+        if (!TargetInfo.isValidFeatureName(BareFeat)) {
+          S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+              << Feature << BareFeat;
+          return true;
+        }
+      }
+    } else {
+      llvm::SmallVector<StringRef, 8> Feats;
+      TVA->getFeatures(Feats);
+      for (const auto &Feat : Feats) {
+        if (!TargetInfo.validateCpuSupports(Feat)) {
+          S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+              << Feature << Feat;
+          return true;
+        }
       }
     }
   }
@@ -11238,7 +11254,8 @@ static bool PreviousDeclsHaveMultiVersionAttribute(const FunctionDecl *FD) {
 }
 
 static void patchDefaultTargetVersion(FunctionDecl *From, FunctionDecl *To) {
-  if (!From->getASTContext().getTargetInfo().getTriple().isAArch64())
+  if (!From->getASTContext().getTargetInfo().getTriple().isAArch64() &&
+      !From->getASTContext().getTargetInfo().getTriple().isRISCV())
     return;
 
   MultiVersionKind MVKindFrom = From->getMultiVersionKind();
@@ -15418,8 +15435,10 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
     FD->setInvalidDecl();
   }
   if (const auto *Attr = FD->getAttr<TargetVersionAttr>()) {
-    if (!Context.getTargetInfo().hasFeature("fmv") &&
-        !Attr->isDefaultVersion()) {
+    if (Context.getTargetInfo().getTriple().isRISCV()) {
+      // pass thought anyway.
+    } else if (!Context.getTargetInfo().hasFeature("fmv") &&
+               !Attr->isDefaultVersion()) {
       // If function multi versioning disabled skip parsing function body
       // defined with non-default target_version attribute
       if (SkipBody)
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index f2cd46d1e7c93..d624e69c78084 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3015,6 +3015,21 @@ bool Sema::checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
   enum SecondParam { None };
   enum ThirdParam { Target, TargetClones, TargetVersion };
   llvm::SmallVector<StringRef, 8> Features;
+  if (Context.getTargetInfo().getTriple().isRISCV()) {
+
+    if (AttrStr.starts_with("default"))
+      return false;
+
+    ParsedTargetAttr ParsedAttrs =
+        Context.getTargetInfo().parseTargetAttr(AttrStr);
+
+    if (AttrStr.starts_with("arch=+") &&
+        (!ParsedAttrs.Features.empty() || !ParsedAttrs.Tune.empty()))
+      return false;
+
+    return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+           << Unsupported << None << AttrStr << TargetVersion;
+  }
   AttrStr.split(Features, "+");
   for (auto &CurFeature : Features) {
     CurFeature = CurFeature.trim();
@@ -3127,6 +3142,32 @@ bool Sema::checkTargetClonesAttrString(
                                  /*IncludeLocallyStreaming=*/false))
         return Diag(LiteralLoc,
                     diag::err_sme_streaming_cannot_be_multiversioned);
+    } else if (...
[truncated]

clang/test/CodeGen/attr-target-clones-riscv-invaild.c Outdated Show resolved Hide resolved
clang/lib/CodeGen/CGBuiltin.cpp Outdated Show resolved Hide resolved
clang/lib/CodeGen/CGBuiltin.cpp Outdated Show resolved Hide resolved
clang/lib/CodeGen/CGBuiltin.cpp Outdated Show resolved Hide resolved
clang/lib/CodeGen/CodeGenFunction.cpp Outdated Show resolved Hide resolved
clang/lib/CodeGen/CodeGenFunction.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaDeclAttr.cpp Outdated Show resolved Hide resolved
clang/test/CodeGen/attr-target-clones-riscv.c Outdated Show resolved Hide resolved
llvm/include/llvm/TargetParser/RISCVTargetParser.h Outdated Show resolved Hide resolved
clang/lib/CodeGen/CGBuiltin.cpp Outdated Show resolved Hide resolved
@BeMg BeMg force-pushed the IFUNC/FMV-target-version branch from 32e2a27 to e761914 Compare July 18, 2024 05:29
@BeMg BeMg force-pushed the IFUNC/FMV-target-version branch from 3abf760 to af2ba0f Compare September 4, 2024 07:20
@BeMg
Copy link
Contributor Author

BeMg commented Sep 4, 2024

Support priority syntax for target_version

@BeMg
Copy link
Contributor Author

BeMg commented Sep 4, 2024

stack on #85786

@BeMg BeMg force-pushed the IFUNC/FMV-target-version branch from af2ba0f to 54b5d68 Compare September 13, 2024 10:15
@BeMg
Copy link
Contributor Author

BeMg commented Sep 13, 2024

Rebase to main

@@ -10319,8 +10319,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
// Handle attributes.
ProcessDeclAttributes(S, NewFD, D);
const auto *NewTVA = NewFD->getAttr<TargetVersionAttr>();
if (NewTVA && !NewTVA->isDefaultVersion() &&
!Context.getTargetInfo().hasFeature("fmv")) {
if (Context.getTargetInfo().getTriple().isRISCV()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you happen to know what the "fmv" feature is? I don't have context here. Any docs, or a good starting point in the code to understand what we're leaving out here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understand is the fmv is a aarch64 feature to control the function multi-versioning. They(target_version and fmv) are both be introduced by this commit.

The ACLE spec and review comment can help to understand the context.

Additionally, it is treated as a generic option in the Clang command-line options, and it was also introduced in the same commit.


Do you think it's a good idea to add this similar feature to RISC-V, or should we just skip it?

S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
<< Feature << Feat;
return true;
if (S.getASTContext().getTargetInfo().getTriple().isRISCV()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The need to version all of this by target is unfortunate. Is there a way we can reduce the duplication here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reduce the part of duplication, and the remain part is causing by different syntax between aarch64 and RISC-V.

To reducing the remain part of duplication, we could implement the RISC-V syntax inside clang/include/clang/Basic/Attr.td getFeatures or make Aarch64 using the AArch64TargetInfo::parseTargetAttr for target_version, or make something like parseTargetVersionAttr hook here.

By the way, the parsing of target_clones syntax is controlled by the target. (Reference:

if (TInfo.getTriple().isAArch64()) {
)

@BeMg BeMg requested review from topperc and preames September 19, 2024 14:35
clang/lib/AST/ASTContext.cpp Show resolved Hide resolved
clang/lib/CodeGen/CodeGenModule.cpp Show resolved Hide resolved
clang/lib/Sema/SemaDecl.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaDeclAttr.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaDeclAttr.cpp Show resolved Hide resolved
clang/lib/Sema/SemaDeclAttr.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaDecl.cpp Show resolved Hide resolved
clang/lib/Sema/SemaDeclAttr.cpp Show resolved Hide resolved
clang/lib/Sema/SemaDeclAttr.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BeMg BeMg merged commit 7ab488e into llvm:main Oct 4, 2024
8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 4, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-5 while building clang at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/7052

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: CodeGen/attr-target-version-riscv-invalid.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: not /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/20/include -nostdsysteminc -triple riscv64 -target-feature +i -emit-llvm -o - /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c 2>&1 | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c --check-prefix=CHECK-UNSUPPORT-OS
+ not /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/20/include -nostdsysteminc -triple riscv64 -target-feature +i -emit-llvm -o - /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c --check-prefix=CHECK-UNSUPPORT-OS
�[1m/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:3:24: �[0m�[0;1;31merror: �[0m�[1mCHECK-UNSUPPORT-OS: expected string not found in input
�[0m// CHECK-UNSUPPORT-OS: error: function multiversioning is currently only supported on Linux
�[0;1;32m                       ^
�[0m�[1m<stdin>:1:1: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '9'
�[0;1;32m^
�[0m�[1m<stdin>:1:120: �[0m�[0;1;30mnote: �[0m�[1mpossible intended match here
�[0m/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '9'
�[0;1;32m                                                                                                                       ^
�[0m
Input file: <stdin>
Check file: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
�[1m�[0m�[0;1;30m           1: �[0m�[1m�[0;1;46m/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '9' �[0m
�[0;1;31mcheck:3'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
�[0m�[0;1;35mcheck:3'1                                                                                                                            ?                                                            possible intended match
�[0m�[0;1;30m           2: �[0m�[1m�[0;1;46m 8 | __attribute__((target_version("arch=+c"))) int foo(void) { �[0m
�[0;1;31mcheck:3'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
�[0m�[0;1;30m           3: �[0m�[1m�[0;1;46m | ^ �[0m
�[0;1;31mcheck:3'0     ~~~~~
�[0m�[0;1;30m           4: �[0m�[1m�[0;1;46m1 error generated. �[0m
�[0;1;31mcheck:3'0     ~~~~~~~~~~~~~~~~~~~
�[0m>>>>>>

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 4, 2024

LLVM Buildbot has detected a new failure on builder clang-hexagon-elf running on hexagon-build-02 while building clang at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/40/builds/2132

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'Clang :: CodeGen/attr-target-version-riscv-invalid.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: not /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/stage1/bin/clang -cc1 -internal-isystem /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/stage1/lib/clang/20/include -nostdsysteminc -triple riscv64 -target-feature +i -emit-llvm -o - /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c 2>&1 | /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/stage1/bin/FileCheck /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c --check-prefix=CHECK-UNSUPPORT-OS
+ /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/stage1/bin/FileCheck /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c --check-prefix=CHECK-UNSUPPORT-OS
+ not /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/stage1/bin/clang -cc1 -internal-isystem /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/stage1/lib/clang/20/include -nostdsysteminc -triple riscv64 -target-feature +i -emit-llvm -o - /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c
/local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c:3:24: error: CHECK-UNSUPPORT-OS: expected string not found in input
// CHECK-UNSUPPORT-OS: error: function multiversioning is currently only supported on Linux
                       ^
<stdin>:1:1: note: scanning from here
/local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '<U+0000>'
^
<stdin>:1:128: note: possible intended match here
/local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '<U+0000>'
                                                                                                                               ^

Input file: <stdin>
Check file: /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1: /local/mnt/workspace/bots/hexagon-build-02/clang-hexagon-elf/llvm/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '<U+0000>' 
check:3'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:3'1                                                                                                                                    ?                                                                   possible intended match
           2:  8 | __attribute__((target_version("arch=+c"))) int foo(void) { 
check:3'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           3:  | ^ 
check:3'0     ~~~~~
           4: 1 error generated. 
check:3'0     ~~~~~~~~~~~~~~~~~~~
>>>>>>

--

********************


BeMg added a commit that referenced this pull request Oct 4, 2024
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 4, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-fast running on sanitizer-buildbot3 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/3933

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86068 of 86069 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: Clang :: SemaCXX/attr-target-version-riscv.cpp (86054 of 86068)
******************** TEST 'Clang :: SemaCXX/attr-target-version-riscv.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/SemaCXX/attr-target-version-riscv.cpp -std=c++14
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu -fsyntax-only -verify -fexceptions -fcxx-exceptions /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/SemaCXX/attr-target-version-riscv.cpp -std=c++14
=================================================================
==3823339==ERROR: AddressSanitizer: heap-use-after-free on address 0x5030000089b2 at pc 0x5f3ce727c192 bp 0x7ffcbd9fd0d0 sp 0x7ffcbd9fd0c8
READ of size 1 at 0x5030000089b2 thread T0
    #0 0x5f3ce727c191 in ascii_strncasecmp(char const*, char const*, unsigned long) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/StringRef.cpp:30:33
    #1 0x5f3ce727c073 in llvm::StringRef::compare_insensitive(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/StringRef.cpp:38:17
    #2 0x5f3ce73dca5d in equals_insensitive /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/StringRef.h:176:38
    #3 0x5f3ce73dca5d in llvm::RISCVISAInfo::getRISCVFeaturesBitsInfo(llvm::StringRef) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/TargetParser/RISCVISAInfo.cpp:1063:15
    #4 0x5f3ce87b0dce in clang::targets::RISCVTargetInfo::validateCpuSupports(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:483:16
    #5 0x5f3cee187ddb in CheckMultiVersionValue(clang::Sema&, clang::FunctionDecl const*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11052:23
    #6 0x5f3cee1132a2 in CheckMultiVersionFirstFunction /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11312:22
    #7 0x5f3cee1132a2 in CheckMultiVersionFunction /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11773:12
    #8 0x5f3cee1132a2 in clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11918:7
    #9 0x5f3cee0e9995 in clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:10527:26
    #10 0x5f3cee0dc8a6 in clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:6418:11
    #11 0x5f3cee13aeaa in clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SkipBodyInfo*, clang::Sema::FnBodyKind) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:15279:14
    #12 0x5f3ced9250f5 in clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1444:23
    #13 0x5f3ceda26bb5 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2460:17
    #14 0x5f3ced9228ac in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1244:10
    #15 0x5f3ced9215f6 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1266:12
    #16 0x5f3ced91ed5f in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1069:14
    #17 0x5f3ced91b4c8 in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:758:12
    #18 0x5f3ced90e50e in clang::ParseAST(clang::Sema&, bool, bool) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/ParseAST.cpp:171:20
    #19 0x5f3ce9318e7c in clang::FrontendAction::Execute() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1078:8
    #20 0x5f3ce920ca7d in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1060:33
    #21 0x5f3ce95dabc1 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:25
    #22 0x5f3ce0753f9a in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/cc1_main.cpp:285:15
    #23 0x5f3ce074944b in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/driver.cpp:217:12
    #24 0x5f3ce0747796 in clang_main(int, char**, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/driver.cpp:258:12
    #25 0x5f3ce0771595 in main /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/tools/clang/tools/driver/clang-driver.cpp:17:10
    #26 0x7a234cc2a1c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 6d64b17fbac799e68da7ebd9985ddf9b5cb375e6)
    #27 0x7a234cc2a28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 6d64b17fbac799e68da7ebd9985ddf9b5cb375e6)
Step 9 (stage2/asan_ubsan check) failure: stage2/asan_ubsan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86068 of 86069 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: Clang :: SemaCXX/attr-target-version-riscv.cpp (86054 of 86068)
******************** TEST 'Clang :: SemaCXX/attr-target-version-riscv.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/SemaCXX/attr-target-version-riscv.cpp -std=c++14
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu -fsyntax-only -verify -fexceptions -fcxx-exceptions /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/SemaCXX/attr-target-version-riscv.cpp -std=c++14
=================================================================
==3823339==ERROR: AddressSanitizer: heap-use-after-free on address 0x5030000089b2 at pc 0x5f3ce727c192 bp 0x7ffcbd9fd0d0 sp 0x7ffcbd9fd0c8
READ of size 1 at 0x5030000089b2 thread T0
    #0 0x5f3ce727c191 in ascii_strncasecmp(char const*, char const*, unsigned long) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/StringRef.cpp:30:33
    #1 0x5f3ce727c073 in llvm::StringRef::compare_insensitive(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/StringRef.cpp:38:17
    #2 0x5f3ce73dca5d in equals_insensitive /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/StringRef.h:176:38
    #3 0x5f3ce73dca5d in llvm::RISCVISAInfo::getRISCVFeaturesBitsInfo(llvm::StringRef) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/TargetParser/RISCVISAInfo.cpp:1063:15
    #4 0x5f3ce87b0dce in clang::targets::RISCVTargetInfo::validateCpuSupports(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:483:16
    #5 0x5f3cee187ddb in CheckMultiVersionValue(clang::Sema&, clang::FunctionDecl const*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11052:23
    #6 0x5f3cee1132a2 in CheckMultiVersionFirstFunction /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11312:22
    #7 0x5f3cee1132a2 in CheckMultiVersionFunction /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11773:12
    #8 0x5f3cee1132a2 in clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11918:7
    #9 0x5f3cee0e9995 in clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:10527:26
    #10 0x5f3cee0dc8a6 in clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:6418:11
    #11 0x5f3cee13aeaa in clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SkipBodyInfo*, clang::Sema::FnBodyKind) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:15279:14
    #12 0x5f3ced9250f5 in clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1444:23
    #13 0x5f3ceda26bb5 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2460:17
    #14 0x5f3ced9228ac in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1244:10
    #15 0x5f3ced9215f6 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1266:12
    #16 0x5f3ced91ed5f in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1069:14
    #17 0x5f3ced91b4c8 in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:758:12
    #18 0x5f3ced90e50e in clang::ParseAST(clang::Sema&, bool, bool) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/ParseAST.cpp:171:20
    #19 0x5f3ce9318e7c in clang::FrontendAction::Execute() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1078:8
    #20 0x5f3ce920ca7d in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1060:33
    #21 0x5f3ce95dabc1 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:25
    #22 0x5f3ce0753f9a in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/cc1_main.cpp:285:15
    #23 0x5f3ce074944b in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/driver.cpp:217:12
    #24 0x5f3ce0747796 in clang_main(int, char**, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/driver.cpp:258:12
    #25 0x5f3ce0771595 in main /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/tools/clang/tools/driver/clang-driver.cpp:17:10
    #26 0x7a234cc2a1c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 6d64b17fbac799e68da7ebd9985ddf9b5cb375e6)
    #27 0x7a234cc2a28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 6d64b17fbac799e68da7ebd9985ddf9b5cb375e6)
Step 12 (stage2/msan check) failure: stage2/msan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86067 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: Clang :: SemaCXX/attr-target-version-riscv.cpp (86053 of 86067)
******************** TEST 'Clang :: SemaCXX/attr-target-version-riscv.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/SemaCXX/attr-target-version-riscv.cpp -std=c++14
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu -fsyntax-only -verify -fexceptions -fcxx-exceptions /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/SemaCXX/attr-target-version-riscv.cpp -std=c++14
==595528==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55555ea9dc41 in ascii_strncasecmp(char const*, char const*, unsigned long) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/StringRef.cpp
    #1 0x55555ea9db0e in llvm::StringRef::compare_insensitive(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/StringRef.cpp:38:17
    #2 0x55555b42efb1 in llvm::StringRef::equals_insensitive(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/StringRef.h:176:38
    #3 0x55555eb47908 in llvm::RISCVISAInfo::getRISCVFeaturesBitsInfo(llvm::StringRef) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/TargetParser/RISCVISAInfo.cpp:1063:15
    #4 0x55555f5c7bb1 in clang::targets::RISCVTargetInfo::validateCpuSupports(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:483:16
    #5 0x5555621158f9 in CheckMultiVersionValue(clang::Sema&, clang::FunctionDecl const*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11052:23
    #6 0x5555620cf8e4 in CheckMultiVersionFirstFunction /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11312:22
    #7 0x5555620cf8e4 in CheckMultiVersionFunction /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11773:12
    #8 0x5555620cf8e4 in clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11918:7
    #9 0x5555620b9719 in clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:10527:26
    #10 0x5555620b075f in clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:6418:11
    #11 0x5555620e6eb5 in clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SkipBodyInfo*, clang::Sema::FnBodyKind) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:15279:14
    #12 0x555561c76147 in clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1444:23
    #13 0x555561d13b31 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/ParseDecl.cpp
    #14 0x555561c749b8 in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1244:10
    #15 0x555561c73c5b in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1266:12
    #16 0x555561c72a9d in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:1069:14
    #17 0x555561c70084 in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/Parser.cpp:758:12
    #18 0x555561c69fa7 in clang::ParseAST(clang::Sema&, bool, bool) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Parse/ParseAST.cpp:171:20
    #19 0x55555fbb9ed7 in clang::FrontendAction::Execute() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1078:8
    #20 0x55555fb0a790 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1060:33
    #21 0x55555fcc596d in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:25
    #22 0x55555b433045 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/cc1_main.cpp:285:15
    #23 0x55555b42d7bf in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/driver.cpp:217:12
    #24 0x55555b42b4b8 in clang_main(int, char**, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/driver/driver.cpp:258:12
    #25 0x55555b447678 in main /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/tools/driver/clang-driver.cpp:17:10
    #26 0x7ffff7a2a1c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 6d64b17fbac799e68da7ebd9985ddf9b5cb375e6)
    #27 0x7ffff7a2a28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 6d64b17fbac799e68da7ebd9985ddf9b5cb375e6)
    #28 0x55555b390e64 in _start (/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-20+0x5e3ce64)


@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 4, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-bootstrap-ubsan running on sanitizer-buildbot4 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/25/builds/3046

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86069 tests, 88 workers --
Testing:  0.
FAIL: Clang :: CodeGen/attr-target-version-riscv-invalid.c (6616 of 86069)
******************** TEST 'Clang :: CodeGen/attr-target-version-riscv-invalid.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: not /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/20/include -nostdsysteminc -triple riscv64 -target-feature +i -emit-llvm -o - /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c 2>&1 | /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c --check-prefix=CHECK-UNSUPPORT-OS
+ not /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/20/include -nostdsysteminc -triple riscv64 -target-feature +i -emit-llvm -o - /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c
+ /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c --check-prefix=CHECK-UNSUPPORT-OS
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:3:24: error: CHECK-UNSUPPORT-OS: expected string not found in input
// CHECK-UNSUPPORT-OS: error: function multiversioning is currently only supported on Linux
                       ^
<stdin>:1:1: note: scanning from here
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '|'
^
<stdin>:1:128: note: possible intended match here
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '|'
                                                                                                                               ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '|' 
check:3'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:3'1                                                                                                                                    ?                                                            possible intended match
           2:  8 | __attribute__((target_version("arch=+c"))) int foo(void) { 
check:3'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           3:  | ^ 
check:3'0     ~~~~~
           4: 1 error generated. 
check:3'0     ~~~~~~~~~~~~~~~~~~~
>>>>>>

--

Step 10 (stage2/ubsan check) failure: stage2/ubsan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86069 tests, 88 workers --
Testing:  0.
FAIL: Clang :: CodeGen/attr-target-version-riscv-invalid.c (6616 of 86069)
******************** TEST 'Clang :: CodeGen/attr-target-version-riscv-invalid.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: not /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/20/include -nostdsysteminc -triple riscv64 -target-feature +i -emit-llvm -o - /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c 2>&1 | /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c --check-prefix=CHECK-UNSUPPORT-OS
+ not /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/20/include -nostdsysteminc -triple riscv64 -target-feature +i -emit-llvm -o - /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c
+ /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c --check-prefix=CHECK-UNSUPPORT-OS
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:3:24: error: CHECK-UNSUPPORT-OS: expected string not found in input
// CHECK-UNSUPPORT-OS: error: function multiversioning is currently only supported on Linux
                       ^
<stdin>:1:1: note: scanning from here
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '|'
^
<stdin>:1:128: note: possible intended match here
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '|'
                                                                                                                               ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1: /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv-invalid.c:8:48: error: function multiversioning doesn't support feature '|' 
check:3'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:3'1                                                                                                                                    ?                                                            possible intended match
           2:  8 | __attribute__((target_version("arch=+c"))) int foo(void) { 
check:3'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           3:  | ^ 
check:3'0     ~~~~~
           4: 1 error generated. 
check:3'0     ~~~~~~~~~~~~~~~~~~~
>>>>>>

--


@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 4, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-bootstrap-asan running on sanitizer-buildbot2 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/52/builds/2670

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86068 of 86069 tests, 88 workers --
Testing:  0.
FAIL: Clang :: CodeGen/attr-target-version-riscv.c (6772 of 86068)
******************** TEST 'Clang :: CodeGen/attr-target-version-riscv.c' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 2: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu -target-feature +i -emit-llvm -o - /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv.c | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv.c
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu -target-feature +i -emit-llvm -o - /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv.c
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv.c
=================================================================
==856967==ERROR: AddressSanitizer: heap-use-after-free on address 0x6c706d6290a2 at pc 0x60a5a52d007d bp 0x7ffe112f6770 sp 0x7ffe112f6768
READ of size 1 at 0x6c706d6290a2 thread T0
    #0 0x60a5a52d007c in ascii_strncasecmp /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/StringRef.cpp:30:33
    #1 0x60a5a52d007c in llvm::StringRef::compare_insensitive(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/StringRef.cpp:38:17
    #2 0x60a5a5418dcd in equals_insensitive /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/StringRef.h:176:38
    #3 0x60a5a5418dcd in llvm::RISCVISAInfo::getRISCVFeaturesBitsInfo(llvm::StringRef) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TargetParser/RISCVISAInfo.cpp:1063:15
    #4 0x60a5a654391e in clang::targets::RISCVTargetInfo::validateCpuSupports(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:483:16
    #5 0x60a5ab7d1e6f in CheckMultiVersionValue(clang::Sema&, clang::FunctionDecl const*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11052:23
    #6 0x60a5ab7662e1 in CheckMultiVersionFirstFunction /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11312:22
    #7 0x60a5ab7662e1 in CheckMultiVersionFunction /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11773:12
    #8 0x60a5ab7662e1 in clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11918:7
    #9 0x60a5ab73eff2 in clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:10362:26
    #10 0x60a5ab733e93 in clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:6418:11
    #11 0x60a5ab78dab9 in clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SkipBodyInfo*, clang::Sema::FnBodyKind) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:15279:14
    #12 0x60a5aaf7251a in clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:1444:23
    #13 0x60a5ab0a8736 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2460:17
    #14 0x60a5aaf70163 in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:1244:10
    #15 0x60a5aaf6ec6f in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:1266:12
    #16 0x60a5aaf6ba69 in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:1069:14
    #17 0x60a5aaf66c2b in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:758:12
    #18 0x60a5aaf657c9 in clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:608:26
    #19 0x60a5aaf58a89 in clang::ParseAST(clang::Sema&, bool, bool) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/ParseAST.cpp:170:25
    #20 0x60a5a67365c2 in clang::CodeGenAction::ExecuteAction() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1142:30
    #21 0x60a5a70e73dc in clang::FrontendAction::Execute() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1078:8
    #22 0x60a5a6fe750f in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1060:33
    #23 0x60a5a732b805 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:25
    #24 0x60a59e800169 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/cc1_main.cpp:285:15
    #25 0x60a59e7f788f in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/driver.cpp:217:12
    #26 0x60a59e7f5dc5 in clang_main(int, char**, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/driver.cpp:258:12
Step 10 (stage2/asan check) failure: stage2/asan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86068 of 86069 tests, 88 workers --
Testing:  0.
FAIL: Clang :: CodeGen/attr-target-version-riscv.c (6772 of 86068)
******************** TEST 'Clang :: CodeGen/attr-target-version-riscv.c' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 2: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu -target-feature +i -emit-llvm -o - /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv.c | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv.c
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang -cc1 -internal-isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/lib/clang/20/include -nostdsysteminc -triple riscv64-linux-gnu -target-feature +i -emit-llvm -o - /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv.c
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGen/attr-target-version-riscv.c
=================================================================
==856967==ERROR: AddressSanitizer: heap-use-after-free on address 0x6c706d6290a2 at pc 0x60a5a52d007d bp 0x7ffe112f6770 sp 0x7ffe112f6768
READ of size 1 at 0x6c706d6290a2 thread T0
    #0 0x60a5a52d007c in ascii_strncasecmp /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/StringRef.cpp:30:33
    #1 0x60a5a52d007c in llvm::StringRef::compare_insensitive(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/StringRef.cpp:38:17
    #2 0x60a5a5418dcd in equals_insensitive /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/StringRef.h:176:38
    #3 0x60a5a5418dcd in llvm::RISCVISAInfo::getRISCVFeaturesBitsInfo(llvm::StringRef) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TargetParser/RISCVISAInfo.cpp:1063:15
    #4 0x60a5a654391e in clang::targets::RISCVTargetInfo::validateCpuSupports(llvm::StringRef) const /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:483:16
    #5 0x60a5ab7d1e6f in CheckMultiVersionValue(clang::Sema&, clang::FunctionDecl const*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11052:23
    #6 0x60a5ab7662e1 in CheckMultiVersionFirstFunction /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11312:22
    #7 0x60a5ab7662e1 in CheckMultiVersionFunction /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11773:12
    #8 0x60a5ab7662e1 in clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11918:7
    #9 0x60a5ab73eff2 in clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:10362:26
    #10 0x60a5ab733e93 in clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:6418:11
    #11 0x60a5ab78dab9 in clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SkipBodyInfo*, clang::Sema::FnBodyKind) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:15279:14
    #12 0x60a5aaf7251a in clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:1444:23
    #13 0x60a5ab0a8736 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2460:17
    #14 0x60a5aaf70163 in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:1244:10
    #15 0x60a5aaf6ec6f in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:1266:12
    #16 0x60a5aaf6ba69 in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:1069:14
    #17 0x60a5aaf66c2b in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:758:12
    #18 0x60a5aaf657c9 in clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:608:26
    #19 0x60a5aaf58a89 in clang::ParseAST(clang::Sema&, bool, bool) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/ParseAST.cpp:170:25
    #20 0x60a5a67365c2 in clang::CodeGenAction::ExecuteAction() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1142:30
    #21 0x60a5a70e73dc in clang::FrontendAction::Execute() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1078:8
    #22 0x60a5a6fe750f in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1060:33
    #23 0x60a5a732b805 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:25
    #24 0x60a59e800169 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/cc1_main.cpp:285:15
    #25 0x60a59e7f788f in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/driver.cpp:217:12
    #26 0x60a59e7f5dc5 in clang_main(int, char**, llvm::ToolContext const&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/driver.cpp:258:12

xgupta pushed a commit to xgupta/llvm-project that referenced this pull request Oct 4, 2024
This patch enable `target_version` attribute for RISC-V target.

The proposal of `target_version` syntax can be found at the
riscv-non-isa/riscv-c-api-doc#48 (which has
landed), as modified by the proposed
riscv-non-isa/riscv-c-api-doc#85 (which adds the
priority syntax).

`target_version` attribute will trigger the function multi-versioning
feature and act like `target_clones` attribute. See
llvm#85786 for the implementation
of `target_clones`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V clang:codegen clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants