<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54117>54117</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: coroutine program triggers "error in backend: Cannot select: intrinsic %llvm.coro.size"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
avelanarius
</td>
</tr>
</table>
<pre>
The following C++ coroutine program triggers `fatal error: error in backend: Cannot select: intrinsic %llvm.coro.size` with Clang 15:
```cpp
#include <coroutine>
struct task {
struct promise_type {
task get_return_object() { return {}; }
std::suspend_never initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void unhandled_exception() {}
};
bool await_ready() { return false; }
void await_suspend(std::coroutine_handle<> h) {}
void await_resume() {}
};
template <typename Func>
void call(Func func) { func(); }
class foo {
void f();
task g();
};
void foo::f() {
auto lambda = [this]() noexcept -> task {
co_await g();
};
(void)call<decltype(lambda)>;
}
int main() {}
```
C++ file (source above): [repro.cpp.txt](https://github.com/llvm/llvm-project/files/8154315/repro.cpp.txt)
Reproduced with `Ubuntu clang version 15.0.0-++20220226042310+9d7001eba9c4-1~exp1~20220226042411.12` and compiled with `clang++-15 repro.cpp -o repro -std=c++20` prints error:
```
fatal error: error in backend: Cannot select: intrinsic %llvm.coro.size
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Ubuntu clang version 15.0.0-++20220226042310+9d7001eba9c4-1~exp1~20220226042411.12
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/repro-8b993e.cpp
clang: note: diagnostic msg: /tmp/repro-8b993e.sh
clang: note: diagnostic msg:
********************
```
[repro-8b993e.sh.txt](https://github.com/llvm/llvm-project/files/8154309/repro-8b993e.sh.txt)
[repro-8b993e.cpp.txt](https://github.com/llvm/llvm-project/files/8154310/repro-8b993e.cpp.txt)
Reproduced with "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 69297cf639044acf48dd5d9b39b95c54dd50561d)" on Compiler Explorer (https://godbolt.org/z/Eds5GnrWe) fails with:
```
fatal error: error in backend: Cannot select: intrinsic %llvm.coro.size
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 -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'X86 DAG->DAG Instruction Selection' on function '@"_ZZN3foo1fEvENK3$_0clEv"'
#0 0x0000560eecbc1c8f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x0000560eecbbfb60 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35bfb60)
#2 0x0000560eecaf9ff2 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x34f9ff2)
#3 0x0000560eecbb872e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35b872e)
#4 0x0000560eea7aee56 (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11aee56)
#5 0x0000560eecb0151f llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x350151f)
#6 0x0000560eeda60846 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4460846)
#7 0x0000560eeda63922 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4463922)
#8 0x0000560eeb7ff7f7 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
#9 0x0000560eeda5f3a4 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x445f3a4)
#10 0x0000560eeda66f96 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4466f96)
#11 0x0000560eeda6a5dc llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x446a5dc)
#12 0x0000560eeda6c7a2 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.890) SelectionDAGISel.cpp:0:0
#13 0x0000560eeb807750 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#14 0x0000560eebeb5238 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x28b5238)
#15 0x0000560eec327089 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d27089)
#16 0x0000560eec327321 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d27321)
#17 0x0000560eec327dc7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d27dc7)
#18 0x0000560eecef9529 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x38f9529)
#19 0x0000560eedb77c1f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4577c1f)
#20 0x0000560eee9f0909 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x53f0909)
#21 0x0000560eedb77df2 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4577df2)
#22 0x0000560eed573041 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f73041)
#23 0x0000560eed50d062 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f0d062)
#24 0x0000560eed6400b3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40400b3)
#25 0x0000560eea7b0994 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11b0994)
#26 0x0000560eea7ac94d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x0000560eed3a9085 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x0000560eecaf9e83 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x34f9e83)
#29 0x0000560eed3ab158 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dab158)
#30 0x0000560eed37e58a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d7e58a)
#31 0x0000560eed37f0cf clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d7f0cf)
#32 0x0000560eed387a95 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d87a95)
#33 0x0000560eea6bc0c2 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0x10bc0c2)
#34 0x00007f07a6b3f0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#35 0x0000560eea7ac4ca _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11ac4ca)
clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation)
ASM generation compiler returned: 70
fatal error: error in backend: Cannot select: intrinsic %llvm.coro.size
clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Execution build compiler returned: 70
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWlt3mzoW_jXOi5a9uBp4yIPjOG1n2iYrTufMnBeWEMJmioFBkDjn18_eEtgIO2na0s7DZDm-6La_vbWvElERP18-bDlJiiwrntJ8Q5YT6wpehBVV0dRpzklZFZuK7khdpZsNrwSZzI2E1jQjvKqKamIv1BeS5iSi7CvPY2xb0jwvaiJ4xlmNDWkOK-QiZWRiuVn2uJshjZlI_-KwInlK6y1ZZhQwmC6MnxjXE6N7nxvqxcqybbHsNGdZE3MysZcHsBN71Z8n6qphNamp-Eom3pVqJKRtBsZ2qeBh_VzyfjdREza8DiteN1UeFtG_kQnLn1gBjiSqXU7yrif2FcGPw3RRowTgJRpRgjjCnD9ylE9apzQL29afXS5J85PF8oLvGS_rN6z6WKQxafItzeOMx6Galxb5EVZvuFqg-xUVRUboE01RQDR-PuUkoZngA5KSoJp1BH3g7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