<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/114117>114117</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [RISCV] Function calls from `__attribute__((target("arch=+zvl512b")))` give fatal error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dzaima
      </td>
    </tr>
</table>

<pre>
    
The code:

```c
#include <riscv_vector.h>

int ext(int x);

__attribute__((target("arch=+zvl512b")))
int foo(int x) {
 return ext(x);
}
```

(https://godbolt.org/z/Tbhh7vnd6) compiled with `-march=rv64gcv` gives this error:

```
fatal error: error in backend: riscv-v-vector-bits-min specified is lower than the Zvl*b limitation
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: /opt/compiler-explorer/clang-trunk/bin/clang -g -o /app/output.s -fno-verbose-asm -S -target riscv64-unknown-linux-gnu -march=rv64gc -mabi=lp64d --gcc-toolchain=/opt/compiler-explorer/riscv64/gcc-8.2.0/riscv64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/riscv64/gcc-8.2.0/riscv64-unknown-linux-gnu/riscv64-unknown-linux-gnu/sysroot -fcolor-diagnostics -fno-crash-diagnostics -march=rv64gcv -O3 <source>
1.      <eof> parser at end of file
2.      Optimizer
3.      Running pass "function<eager-inv>(ee-instrument<>,lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,sroa<modify-cfg>,early-cse<>,callsite-splitting)" on module "<source>"
4.      Running pass "simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>" on function "foo"
 #0 0x000000000396c6d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x396c6d8)
 #1 0x000000000396a814 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x396a814)
 #2 0x00000000038bb7d3 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38bb7d3)
 #3 0x000000000396227e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x396227e)
 #4 0x0000000000ce9a1b LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x00000000038c5823 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38c5823)
 #6 0x00000000038c5988 (/opt/compiler-explorer/clang-trunk/bin/clang+0x38c5988)
 #7 0x0000000001f9e757 (/opt/compiler-explorer/clang-trunk/bin/clang+0x1f9e757)
 #8 0x00000000020acda0 llvm::RISCVTargetLowering::RISCVTargetLowering(llvm::TargetMachine const&, llvm::RISCVSubtarget const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x20acda0)
 #9 0x0000000001f9e5d0 llvm::RISCVSubtarget::RISCVSubtarget(llvm::Triple const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::StringRef, unsigned int, unsigned int, llvm::TargetMachine const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x1f9e5d0)
#10 0x0000000001fa7839 llvm::RISCVTargetMachine::getSubtargetImpl(llvm::Function const&) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x1fa7839)
#11 0x0000000001fa161c llvm::RISCVTargetMachine::getTargetTransformInfo(llvm::Function const&) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x1fa161c)
#12 0x0000000005054720 std::_Function_handler<llvm::TargetTransformInfo (llvm::Function const&), llvm::TargetMachine::getTargetIRAnalysis() const::'lambda'(llvm::Function const&)>::_M_invoke(std::_Any_data const&, llvm::Function const&) TargetMachine.cpp:0:0
#13 0x0000000002b2240f llvm::TargetIRAnalysis::run(llvm::Function const&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2b2240f)
#14 0x0000000004f36a21 llvm::detail::AnalysisPassModel<llvm::Function, llvm::TargetIRAnalysis, llvm::AnalysisManager<llvm::Function>::Invalidator>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4f36a21)
#15 0x00000000033363aa llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x33363aa)
#16 0x000000000385dff9 llvm::SimplifyCFGPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x385dff9)
#17 0x00000000018d93de llvm::detail::PassModel<llvm::Function, llvm::SimplifyCFGPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x18d93de)
#18 0x000000000333b1e7 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x333b1e7)
#19 0x00000000010a357e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x10a357e)
#20 0x000000000333b9c6 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x333b9c6)
#21 0x00000000010a2cae llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x10a2cae)
#22 0x000000000333d9a7 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x333d9a7)
#23 0x0000000003c0379b (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#24 0x0000000003c06827 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c06827)
#25 0x00000000042b28a3 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x42b28a3)
#26 0x00000000062a678c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x62a678c)
#27 0x00000000042b2fa5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x42b2fa5)
#28 0x000000000457a7d1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x457a7d1)
#29 0x00000000044fa8bb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x44fa8bb)
#30 0x000000000465ed83 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x465ed83)
#31 0x0000000000cebbbc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xcebbbc)
#32 0x0000000000ce463d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#33 0x00000000042fadc9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#34 0x00000000038bb6d3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38bb6d3)
#35 0x00000000042fafe9 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#36 0x00000000042c297d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x42c297d)
#37 0x00000000042c397d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x42c397d)
#38 0x00000000042ccf6c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x42ccf6c)
#39 0x0000000000ce8921 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xce8921)
#40 0x0000000000bba334 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xbba334)
#41 0x000071feb0829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#42 0x000071feb0829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#43 0x0000000000ce40de _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xce40de)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW01z2zjS_jX0BUUVCVIkdfBBka2ZzJtUUpZnDu9FBYKghDUIcAFQtvPrtwBCMkFLtsfWzszObspJJBBEP_10o7vxYaQU3XBCLoPpp2B6dYE6vRXysvqBaIMuSlE9XgbRVRDNb7cEYFGRIJn3De7fLOp_sPsOE8ox6yoCgmQhqcK79Y5gLeRkGyTXw1cp14A86AAW5tNDAGdB8mnYYb1GWktadpqs1wEsAlhoJDdE288QSbwNkqsAfvqxY9MYlgGEZpD-5yCiFmIgAgS5kwEk0Z3kDoIvPr8aaeepDIut1q0yTMBlAJcbUZWC6YmQmwAufwRweVtut_mOV5mRiEXTUkYqcE_1FgRZFDYOutxl6QbvgiwCG7ojCugtVYBIKeQpmvuvNdKIHTr2HwDloET4jvDKtFnqw13Ykx-WVKuwoRyolmBaU1IBqgAT90QCvUUc6C0B_79jAZyXgNGGaqSp4L2471-u56troLqyoRogUHYbIEkrpAZagBEZVG-7coJFE8AlY7v9f2ErxT8I1gFcUqU6ogK4BIhXYO8uBgCWSG2tFloiTAK4AK0krRSYKEUqoEQn-2bzJlJKYIo0qYDsOFBY0lZPesgrjfAdqLqmPTAZTYJo9l2KjUQNQHLTNYRrAxwEcClag8yZSobkoWVCEmnaGOKbUMuO3wVwWVK-bwPhBoTCvIza1gzR6bbTEwXCmotwR2QpFAmRakC4AmHvub1ZsjTs-B0X9zxklHcP4YZ3YOQV5ntJg-SKtVlagTDcYBxqIRjeIsqt378A2okx9sA4LCZ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