From f658c1bf4a9d74518ff55a37184b76ec5dec9a8b Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Tue, 8 Oct 2024 16:26:55 +0800 Subject: Recommit "[RISCV][FMV] Support target_version" (#111096)" (#111333) Fix the buildbot failure caused by heap use-after-free error. Origin message: This patch enable `target_version` attribute for RISC-V target. The proposal of `target_version` syntax can be found at the https://github.com/riscv-non-isa/riscv-c-api-doc/pull/48 (which has landed), as modified by the proposed https://github.com/riscv-non-isa/riscv-c-api-doc/pull/85 (which adds the priority syntax). `target_version` attribute will trigger the function multi-versioning feature and act like `target_clones` attribute. See https://github.com/llvm/llvm-project/pull/85786 for the implementation of `target_clones`. --- clang/lib/CodeGen/CodeGenModule.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 25c1c49..5ba0981 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4287,8 +4287,13 @@ void CodeGenModule::emitMultiVersionFunctions() { } else if (const auto *TVA = CurFD->getAttr()) { if (TVA->isDefaultVersion() && IsDefined) ShouldEmitResolver = true; - TVA->getFeatures(Feats); llvm::Function *Func = createFunction(CurFD); + if (getTarget().getTriple().isRISCV()) { + Feats.push_back(TVA->getName()); + } else { + assert(getTarget().getTriple().isAArch64()); + TVA->getFeatures(Feats); + } Options.emplace_back(Func, /*Architecture*/ "", Feats); } else if (const auto *TC = CurFD->getAttr()) { if (IsDefined) -- cgit v1.1