[clang] [RISCV][FMV] Support target_clones (PR #85786)
Kito Cheng via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 27 06:42:26 PDT 2024
kito-cheng wrote:
A test case will crash, missing `+` before `zbc`:
```
__attribute__((target_clones("default", "arch=+zbb,zbc;priority=-1", "priority=-2;arch=+zba", "priority=3;arch=+zbb,+zba"))) int foo1(void) { return 2; }
int bar() { return foo1(); }
```
```
$ clang -cc1 -triple riscv64-linux-gnu -target-feature +i -emit-llvm foo.c
clang: /home/kitoc/llvm-workspace/llvm-project/llvm/lib/TargetParser/RISCVISAInfo.cpp:455: static llvm::Expected<std::unique_ptr<llvm::RISCVISAInfo> > llvm::RISCVISAInfo::parseFeatures(unsigned int, const std::vector<std::__cxx11::basic_string<char> >&): Assertion `ExtName.size() > 1 && (ExtName[0] == '+' || ExtName[0] == '-')' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: ./bin/clang -cc1 -triple riscv64-linux-gnu -target-feature +i -emit-llvm attr-target-clones-riscv.c
1. attr-target-clones-riscv.c:7:1: current parser token 'int'
2. attr-target-clones-riscv.c:4:130: LLVM IR generation of declaration 'foo1'
3. attr-target-clones-riscv.c:4:130: Generating code for declaration 'foo1'
#0 0x00007f4ed63e00d0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/kitoc/llvm-workspace/build-upstream/bin/../lib/libLLVMSupport.so.20.0git+0x1e00d0)
...
#11 0x00007f4eda71a854 llvm::RISCVISAInfo::parseFeatures(unsigned int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&) (/scratch/kitoc/llvm-workspace/build-upstream/bin/../lib/libLLVMTargetParser.so.20.0git+0x3d854)
#12 0x00007f4ed825b8e0 clang::targets::RISCVTargetInfo::initFeatureMap(llvm::StringMap<bool, llvm::MallocAllocator>&, clang::DiagnosticsEngine&, llvm::StringRef, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&) const (/scratch/kitoc/llvm-workspace/build-upstream/bin/../lib/libclangBasic.so.20.0git+0x45b8e0)
...
Aborted (core dumped)
```
https://github.com/llvm/llvm-project/pull/85786
More information about the cfe-commits
mailing list