fnune / vampa

An attempt at writing a programming language
5 stars 0 forks source link

Program with a function declaration but no calls segfaults #4

Open fnune opened 1 year ago

fnune commented 1 year ago

LLVM 10.0.1

test.vam:

fun returns_three returning i32 = 3;
 ~/Development/vampa [3] => cargo run --bin vamc ./test.vam && lli ./test.o                     23:02:47
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/vamc ./test.vam`
Stack dump:
0.      Program arguments: lli ./test.o
1.      Running pass 'Function Pass Manager' on module './test.o'.
2.      Running pass 'Branch Probability Analysis' on function '@main'
 #0 0x0000557686f9f23a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0xd0423a)
 #1 0x0000557686f9cf34 llvm::sys::RunSignalHandlers() (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0xd01f34)
 #2 0x0000557686f9d068 SignalHandler(int) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0xd02068)
 #3 0x00007f0bc35f8140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13140)
 #4 0x0000557686a409e0 llvm::Instruction::getNumSuccessors() const (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x7a59e0)
 #5 0x00005576875d7991 llvm::BranchProbabilityInfo::computePostDominatedByUnreachable(llvm::Function const&, llvm::PostDominatorTree*) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x133c991)
 #6 0x00005576875def6d llvm::BranchProbabilityInfo::calculate(llvm::Function const&, llvm::LoopInfo const&, llvm::TargetLibraryInfo const*) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x1343f6d)
 #7 0x00005576875e02a2 llvm::BranchProbabilityInfoWrapperPass::runOnFunction(llvm::Function&) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x13452a2)
 #8 0x0000557686a69c88 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x7cec88)
 #9 0x0000557686a6b1cc llvm::FPPassManager::runOnModule(llvm::Module&) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x7d01cc)
#10 0x0000557686a6b52a llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x7d052a)
#11 0x0000557686b5728e llvm::MCJIT::emitObject(llvm::Module*) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x8bc28e)
#12 0x0000557686b5794e llvm::MCJIT::generateCodeForModule(llvm::Module*) (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x8bc94e)
#13 0x0000557686b53728 llvm::MCJIT::finalizeObject() (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x8b8728)
#14 0x00005576865a5bba main (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x30abba)
#15 0x00007f0bc30e3d0a __libc_start_main ./csu/../csu/libc-start.c:308:16
#16 0x00005576865e187a _start (/home/fausto/.local/share/llvmenv/10.0.1/bin/lli+0x34687a)
[1]    515605 segmentation fault  lli ./test.o