Open
Description
I tried core
compilation with llvm-cbe, but the following problem occurs.
Missing intrinsics
-
freeze
Add support for thefreeze
instruction JuliaHubOSS/llvm-cbe#175 -
llvm.fshl.i64
Code generator does not support intrinsic functionllvm.fshl.i32
JuliaHubOSS/llvm-cbe#111 -
is.class.fpclass
Code generator does not support intrinsic function 'llvm.is.fpclass.f32' JuliaHubOSS/llvm-cbe#195
Support LLVM-19 JuliaHubOSS/llvm-cbe#211
Originally, whenno_fp_fmt_parse
cfg is used, the instruction associated with the floating point should not be appeared, but something seems to be wrong in rust versionnightly-2024-02-13
.
Resolved with rust nightly with LLVM-19 -
llvm.uadd.sat.i32
,llvm.usub.sat.i16
Add support for the Saturation Arithmetic Intrinsics (llvm.uadd.sat.*
and others) JuliaHubOSS/llvm-cbe#207
Implementllvm.*.sat.*
intrinsics JuliaHubOSS/llvm-cbe#210
u128/i128 (in core::{fmt, num, slice}
)
llvm-cbe does not support data types that exceed 64 bits, and of course SDCC does, so it must be removed before compilation.
There is already a function to turn off floating point fmt as a cfg option (no_fp_fmt_parse
), so I'm going to make similar function and contribute to Rust. (like no_128_fmt_parse
)
I think It can be solved by removing the 128bits parts that don't used with llvm-link.
LLVM-CBE error 1
- (In progress)
When hiding all the above issues by editing llvm-ir, I get an llvm-cbe error.
This error occured in CBackend.cpp#L4558
I think it's caused by an unsupported instruction, but I'm not sure exactly where it happened.
elemT == funT->getParamType(i) in: ret void @
elemT == funT->getParamType(i)
UNREACHABLE executed at /home/zlfn/rust-z80/llvm-project/llvm/projects/llvm-cbe/lib/Target/CBackend/CBackend.cpp:5754!
#0 0x000056109454cd72 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/zlfn/rust-z80/llvm-project/llvm/lib/Support/Unix/Signals.inc:602:22
#1 0x000056109454d143 PrintStackTraceSignalHandler(void*) /home/zlfn/rust-z80/llvm-project/llvm/lib/Support/Unix/Signals.inc:675:1
#2 0x000056109454a881 llvm::sys::RunSignalHandlers() /home/zlfn/rust-z80/llvm-project/llvm/lib/Support/Signals.cpp:104:20
#3 0x000056109454c6cd SignalHandler(int) /home/zlfn/rust-z80/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#4 0x00007efc0acc81d0 (/usr/lib/libc.so.6+0x3d1d0)
#5 0x00007efc0ad213f4 (/usr/lib/libc.so.6+0x963f4)
#6 0x00007efc0acc8120 raise (/usr/lib/libc.so.6+0x3d120)
#7 0x00007efc0acaf4c3 abort (/usr/lib/libc.so.6+0x244c3)
#8 0x0000561094484c6d bindingsErrorHandler(void*, char const*, bool) /home/zlfn/rust-z80/llvm-project/llvm/lib/Support/ErrorHandling.cpp:221:55
#9 0x00005610932d6fc8 std::pair<std::__strip_reference_wrapper<std::decay<llvm::AttributeList>::type>::__type, std::__strip_reference_wrapper<std::decay<llvm::CallingConv::._anon_132>::type>::__type> std::make_pair<llvm::AttributeList, llvm::CallingConv::._anon_132>(llvm::AttributeList&&, llvm::CallingConv::._anon_132&&) /usr/include/c++/14.2.1/bits/stl_pair.h:1132:5
#10 0x00005610932d0b67 llvm_cbe::CWriter::printIntrinsicDefinition(llvm::FunctionType*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, llvm::raw_ostream&) /home/zlfn/rust-z80/llvm-project/llvm/projects/llvm-cbe/lib/Target/CBackend/CBackend.cpp:4563:7
#11 0x00005610932d2052 llvm_cbe::CWriter::printIntrinsicDefinition(llvm::Function&, llvm::raw_ostream&) /home/zlfn/rust-z80/llvm-project/llvm/projects/llvm-cbe/lib/Target/CBackend/CBackend.cpp:4777:27
#12 0x00005610932ca44e llvm_cbe::CWriter::generateHeader(llvm::Module&) /home/zlfn/rust-z80/llvm-project/llvm/projects/llvm-cbe/lib/Target/CBackend/CBackend.cpp:3398:3
#13 0x00005610932c3f17 llvm_cbe::CWriter::doFinalization(llvm::Module&) /home/zlfn/rust-z80/llvm-project/llvm/projects/llvm-cbe/lib/Target/CBackend/CBackend.cpp:2400:50
#14 0x0000561093cdf43b llvm::FPPassManager::doFinalization(llvm::Module&) /home/zlfn/rust-z80/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1499:13
#15 0x0000561093cdfa0e (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/zlfn/rust-z80/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1586:13
#16 0x0000561093cda448 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/zlfn/rust-z80/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:13
#17 0x0000561093ce0045 llvm::legacy::PassManager::run(llvm::Module&) /home/zlfn/rust-z80/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1678:1
#18 0x0000561090a3443c compileModule(char**, llvm::LLVMContext&) /home/zlfn/rust-z80/llvm-project/llvm/projects/llvm-cbe/tools/llvm-cbe/llvm-cbe.cpp:352:12
#19 0x0000561090a337cd main /home/zlfn/rust-z80/llvm-project/llvm/projects/llvm-cbe/tools/llvm-cbe/llvm-cbe.cpp:204:35
#20 0x00007efc0acb0e08 (/usr/lib/libc.so.6+0x25e08)
#21 0x00007efc0acb0ecc __libc_start_main (/usr/lib/libc.so.6+0x25ecc)
#22 0x0000561090a32fa5 _start (/home/zlfn/rust-gb/source/out/../../ext/llvm-cbe+0x922fa5)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/zlfn/rust-gb/source/out/../../ext/llvm-cbe core-2ed864bedde1aa0b.ll
LLVM-CBE errror 2
- (In Progress)
After upgrading the version to LLVM-19, the following error occurs. It seems to be an error related to LegacyPassManager, and I think it will be resolved by migrating to ModulePassManager. (but not sure)
#0 0x000055d2da99280c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/zlfn/rust-gb/ext/./llvm-cbe+0x22ea80c)
#1 0x000055d2da98fc9b SignalHandler(int) Signals.cpp:0:0
#2 0x00007fabac4bf1d0 (/usr/lib/libc.so.6+0x3d1d0)
#3 0x000055d2d99625a5 llvm_cbe::CWriter::generateHeader(llvm::Module&) (/home/zlfn/rust-gb/ext/./llvm-cbe+0x12ba5a5)
#4 0x000055d2da1a23b0 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> llvm::function_ref<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> ()>::callback_fn<llvm::FPPassManager::runOnFunction(llvm::Function&)::'lambda'()>(long) LegacyPassManager.cpp:0:0
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/zlfn/rust-gb/ext/./llvm-cbe core-c7f0b5febd1c5ff8.ll
1. Running pass 'Function Pass Manager' on module 'core-c7f0b5febd1c5ff8.ll'.
2. Running pass 'C backend' on function '@_ZN4core3num3fmt4Part5write17h3ba8354fc9370b66E'