<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96789>96789</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
fatal error: error in backend: Cannot select: intrinsic %llvm.writecmrelease
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nidhinmullakkal
</td>
</tr>
</table>
<pre>
I'm using LLVM18.1 and When I add the following code am getting the following error:
redefine.h
```
static inline __attribute__((always_inline, overloadable)) void __writeCM(
__CMAddr a, int v, const re_MemoryOrder mo) {
switch(mo) {
case memory_order_release:
__builtin_writecm_release((const void *)a, v);
break;
default:
__builtin_writecm_release((const void *)a, v);
}
}
```
clang/include/clang/Basic/Builtins.def
`BUILTIN(__builtin_writecm_release ,"vvC*i" , "Fnc")
`
clang/lib/CodeGen/CGBuiltin.cpp
```
case Builtin::BI__builtin_writecm_release: {
Address arg0 = EmitPointerWithAlignment(E->getArg(0));
EmitNonNullArgCheck(RValue::get(arg0.getPointer()),
E->getArg(0)->getType(), E->getArg(0)->getExprLoc(), FD, 0);
Value *arg1 = EmitScalarExpr(E->getArg(1));
return RValue::get(Builder.CreateWriteCMRelease(arg0.getPointer(), arg1));
}
```
llvm/include/llvm/IR/Intrinsics.td
```
CallInst *IRBuilderBase::CreateWriteCMRelease(Value *arg0, Value* arg1) {
Module *M = BB->getParent()->getParent();
Value *Ops[] = { arg0, arg1 };
Type *Tys[] = { arg0->getType() };
Function *Fn = Intrinsic::getDeclaration(M, Intrinsic::writecmrelease, Tys);
CallInst *CI = CreateCall(Fn, Ops);
return CI;
}
```
fatal error: error in backend: Cannot select: intrinsic %llvm.writecmrelease
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: /home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang -I/home/nidhin/redefine_sdk/redefine/REDEFINE/riscv-gnu-toolchain-install/riscv32-unknown-elf/include -I/home/nidhin/redefine_sdk/redefine/include -Wall -target riscv32-unknown-elf -ffunction-sections -fdata-sections -Wuninitialized -fno-builtin -ffreestanding -march=rv32imf -fno-addrsig -O3 -c -o fib.o fib.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'fib.c'.
4. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@__REDEFINE_main'
#0 0x000055b1db53cfcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x20eefcf)
#1 0x000055b1db53b01c llvm::sys::CleanupOnSignal(unsigned long) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x20ed01c)
#2 0x000055b1db487f27 llvm::CrashRecoveryContext::HandleExit(int) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x2039f27)
#3 0x000055b1db532492 llvm::sys::Process::Exit(int, bool) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x20e4492)
#4 0x000055b1da12c0b6 (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0xcde0b6)
#5 0x000055b1db48f27a llvm::report_fatal_error(llvm::Twine const&, bool) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x204127a)
#6 0x000055b1dc5ef400 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x31a1400)
#7 0x000055b1dc5f4df5 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x31a6df5)
#8 0x000055b1da5d9d21 llvm::RISCVDAGToDAGISel::Select(llvm::SDNode*) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x118bd21)
#9 0x000055b1dc5eba87 llvm::SelectionDAGISel::DoInstructionSelection() (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x319da87)
#10 0x000055b1dc5f97a9 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x31ab7a9)
#11 0x000055b1dc5fc5fc llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x31ae5fc)
#12 0x000055b1dc5feb36 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x000055b1daa541a0 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#14 0x000055b1dafec8da llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x1b9e8da)
#15 0x000055b1dafeca69 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x1b9ea69)
#16 0x000055b1dafedf30 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x1b9ff30)
#17 0x000055b1db79ea39 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*) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x2350a39)
#18 0x000055b1dbd7a36e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x292c36e)
#19 0x000055b1dd980b79 clang::ParseAST(clang::Sema&, bool, bool) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x4532b79)
#20 0x000055b1dbd79745 clang::CodeGenAction::ExecuteAction() (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x292b745)
#21 0x000055b1dc00cb21 clang::FrontendAction::Execute() (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x2bbeb21)
#22 0x000055b1dbf87a5b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x2b39a5b)
#23 0x000055b1dc0ecc7b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x2c9ec7b)
#24 0x000055b1da12dd8d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0xcdfd8d)
#25 0x000055b1da12686d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x000055b1dbdc27ed 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
#27 0x000055b1db487e17 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x2039e17)
#28 0x000055b1dbdc2c8c 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
#29 0x000055b1dbd8939e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x293b39e)
#30 0x000055b1dbd89d6d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x293bd6d)
#31 0x000055b1dbd9423c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0x294623c)
#32 0x000055b1da12b171 clang_main(int, char**, llvm::ToolContext const&) (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0xcdd171)
#33 0x000055b1da072ecb main (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0xc24ecb)
#34 0x00007f6f26dcd083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#35 0x000055b1da12602e _start (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/build/bin/clang+0xcd802e)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 18.1.0rc (/home/nidhin/redefine_sdk/llvm-project-18.1.0.src/clang cfd63ba87bdda87f23e2cf920bcbc8c10acd4359)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWk9zo7qW_zRko7ILhG1gkQWx436-lXSnkrzumpVLSAdbEyE8knCS-fRTEthGxOncO_N8Z_FS3Rj09_zO_yMgWvONBLgOpjfBdHFFGrOt1bXkbMtl1QhBXl6IuCpq9n69CnBSoUZzuUF3dz_vo3QcISIZ-rUFiVaIMIbMFlBZC1G_2lG0ZoBIhTZgjH32e0GpWgVxHoSLIMwVMCi5hPG2fe6us7D75x61IYZTxKXgEtB6TYxRvGgMrNcBTgOcEvFK3vW6HRDgO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