Open nonchip opened 2 years ago
i decided to mess with the actual compiler a bit to maybe make it use less features by claiming to target MIPS1 (which is gonna be better for the compiler that will handle the resulting c code anyway, because i'm planning to feed that into a rather ancient cpu) and also disabling any optimization, that got rid of the 64bit abs, but now it's dying due to llvm.is.constant.i32
:
LLVM ERROR: Code generator does not support intrinsic function 'llvm.is.constant.i32'!
#0 0x00007fb4ed40ecad llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/libLLVM-12.so+0xbdfcad)
#1 0x00007fb4ed40c984 llvm::sys::RunSignalHandlers() (/usr/lib/libLLVM-12.so+0xbdd984)
#2 0x00007fb4ed40cafb (/usr/lib/libLLVM-12.so+0xbddafb)
#3 0x00007fb4ec2de000 __restore_rt (/usr/lib/libc.so.6+0x3d000)
#4 0x00007fb4ec2ddf81 raise /builddir/glibc-2.32/signal/../sysdeps/unix/sysv/linux/raise.c:50:1
#5 0x00007fb4ec2c7536 abort /builddir/glibc-2.32/stdlib/abort.c:81:7
#6 0x00007fb4ed34250f llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/libLLVM-12.so+0xb1350f)
#7 0x00007fb4ed728a8d llvm::IntrinsicLowering::LowerIntrinsicCall(llvm::CallInst*) (/usr/lib/libLLVM-12.so+0xef9a8d)
#8 0x000055656bd085cf llvm_cbe::CWriter::lowerIntrinsics(llvm::Function&) (/home/kyra/src/llvm-cbe/build/tools/llvm-cbe/llvm-cbe+0x325cf)
#9 0x000055656bcf2a69 llvm_cbe::CWriter::runOnFunction(llvm::Function&) (/home/kyra/src/llvm-cbe/build/tools/llvm-cbe/llvm-cbe+0x1ca69)
#10 0x00007fb4ed5656b0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/libLLVM-12.so+0xd366b0)
#11 0x00007fb4ed566c9c llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/libLLVM-12.so+0xd37c9c)
#12 0x00007fb4ed564fc8 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/libLLVM-12.so+0xd35fc8)
#13 0x000055656bce9e94 compileModule(char**, llvm::LLVMContext&) (/home/kyra/src/llvm-cbe/build/tools/llvm-cbe/llvm-cbe+0x13e94)
#14 0x000055656bce927e main (/home/kyra/src/llvm-cbe/build/tools/llvm-cbe/llvm-cbe+0x1327e)
#15 0x00007fb4ec2c8e0a __libc_start_main /builddir/glibc-2.32/csu/../csu/libc-start.c:314:16
#16 0x000055656bce8a2a _start /builddir/glibc-2.32/csu/../sysdeps/x86_64/start.S:122:0
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: llvm-cbe -- runtime.ll
1. Running pass 'Function Pass Manager' on module 'runtime.ll'.
2. Running pass 'C backend' on function '@_ZNSt11char_traitsIcE7compareEPKcS2_j'
[1] 9009 abort llvm-cbe -- runtime.ll
for the record, the code we're talking about is there, and i compiled it using:
$ ~/src/llvm-project/build/bin/clang++ -std=c++20 --target=mips-linux-musl \
--sysroot=/usr/mips-linux-musl -I/usr/mips-linux-musl/include \
-I/usr/mips-linux-musl/usr/include/ -I/usr/mips-linux-musl/usr/include/c++/10.2/ \
-I/usr/mips-linux-musl/usr/include/c++/10.2/mips-linux-musl \
-O0 -emit-llvm runtime.cpp -S -o runtime.ll
i also tried manually compiling a function that satisfies the intrinsic's documentation, and then patching that into the ll file by hand, but sadly isIntrinsic
seems to take precedence over "is already there", so it gets ignored and LowerIntrinsicCall
still complains about being called for it.
something something "missing functionality", but also: i wonder if it would be possible to turn that fatal error into a warning instead and have the user provide such missing functions? after all they are emitted into the resulting C code, so it should be rather trivial to just emit a declaration and go "this isn't a thing yet, just implement it yourself for now" without requiring people to learn how to hack the LLVM internals?
runtime.ll