Hi!
The upcoming release of Ubuntu 20.10 includes LLVM 11.0.0.
Crystal doesn't support compiling with this version.
$ LVM_CONFIG=/usr/bin/llvm-config make
Using /usr/bin/llvm-config [version=11.0.0]
# rest of the output with errors
I have a WIP for this... but I need to discover why the following code works in llvm 10 but not in llvm 11 ¬¬
; ModuleID = 'min-crash.ll'
source_filename = "min-crash.ll"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
%ctx = type { i8*, i64 }
define void @f(%ctx* %a, %ctx* %b) #0 {
entry:
call void asm "", "r,r"(%ctx* %a, %ctx* %b)
ret void
}
attributes #0 = { naked noinline }
; $ llvm-as min-crash.ll -o min-crash.bc && llc min-crash.bc -o min-crash.s
$ llvm-as min-crash.ll -o min-crash.bc && llc min-crash.bc -o min-crash.s
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: llc min-crash.bc -o min-crash.s
1. Running pass 'Function Pass Manager' on module 'min-crash.bc'.
2. Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
0 libLLVM.dylib 0x000000010ed02814 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 libLLVM.dylib 0x000000010ed02c8c SignalHandler(int) + 200
2 libsystem_platform.dylib 0x00007fff73b83b5d _sigtramp + 29
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338574709952
4 libLLVM.dylib 0x000000010f15642f llvm::RegsForValue::getCopyToRegs(llvm::SDValue, llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue&, llvm::SDValue*, llvm::Value const*, llvm::ISD::NodeType) const + 233
5 libLLVM.dylib 0x000000010f16b30e llvm::SelectionDAGBuilder::visitInlineAsm(llvm::CallBase const&) + 7642
6 libLLVM.dylib 0x000000010f1580d7 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) + 113
7 libLLVM.dylib 0x000000010f1be605 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, bool&) + 155
8 libLLVM.dylib 0x000000010f1be324 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 3686
9 libLLVM.dylib 0x000000010f1bcb24 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1618
10 libLLVM.dylib 0x0000000110636374 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 88
11 libLLVM.dylib 0x000000010ef08e2b llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 239
12 libLLVM.dylib 0x000000010edc8af5 llvm::FPPassManager::runOnFunction(llvm::Function&) + 517
13 libLLVM.dylib 0x000000010edcc354 llvm::FPPassManager::runOnModule(llvm::Module&) + 52
14 libLLVM.dylib 0x000000010edc8f64 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 668
15 llc 0x000000010c178327 compileModule(char**, llvm::LLVMContext&) + 5981
16 llc 0x000000010c1767df main + 1264
17 libdyld.dylib 0x00007fff739983d5 start + 1
18 libdyld.dylib 0x0000000000000004 start + 18446603338576722992
Segmentation fault: 11
We are not alone https://bugs.llvm.org/show_bug.cgi?id=47708
The previous code is a reduction of Fiber.swapcontext which need to be naked AFAIK so it seems like a blocker issue to support LLVM 11.
Yet the crash is only exhibited in --release mode it seems.
If you have an account there I would also submit your failing snippet. That way they have more reproducible code, and it shows it affects more then one user.
Yeah, I was waiting for the account and I've just got it ✅ 🐛 .
@bcardiff So it seems that we're misusing naked attribute?
For Brian's test case
min-crash.ll, we think that's also invalid IR, because the GCC docs say only "basic asm" can be used in a naked function, i.e. no input or output constraints.
Yes. I tried replacing the assembly Fiber.swapcontext assembly arguments by the same assembly that today is generated eg: $0/%rdi , $1/%rsi on sysv but that didn't work. I probably overlook some detail. The path is probably that: generate assembly without argument, and hard-code how arguments are supposed to be passed in assembly.