diff options
author | Piyou Chen <piyou.chen@sifive.com> | 2024-10-08 16:26:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-08 16:26:55 +0800 |
commit | f658c1bf4a9d74518ff55a37184b76ec5dec9a8b (patch) | |
tree | 1bfecea3ca5c58ab4bd326b0a69d91b0860f0c70 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 634c57d738e07754b63160b38e3639467c902cdb (diff) | |
download | llvm-f658c1bf4a9d74518ff55a37184b76ec5dec9a8b.zip llvm-f658c1bf4a9d74518ff55a37184b76ec5dec9a8b.tar.gz llvm-f658c1bf4a9d74518ff55a37184b76ec5dec9a8b.tar.bz2 |
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`.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
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<TargetVersionAttr>()) { 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<TargetClonesAttr>()) { if (IsDefined) |