[LLVMdev] Kaleidoscope doesn't work properly

Andrii Vasyliev andrii.vasyliev at gmail.com
Thu Sep 25 06:20:21 PDT 2008


Hi

I hope this is a proper place to put my question.

I've compiled Kaleidoscope from "Adding JIT and Optimizer Support"  tutorial.
Basically it works just fine but when I try to run extern'ed putchard
function it aborts.
Please, tell me what am I doing wrong?

Here is more information:
My PC runs FreeBSD.
I've copied the toy source code exactly and didn't change it.

Here is the log:
# ./toy
ready> extern putchard(x);
ready> Read extern:
declare double @putchard(double)

ready> def asd (a) putchard(a);
ready> Read function definition:
define double @asd(double %a) {
entry:
        %calltmp = call double @putchard( double %a )           ;
<double> [#uses=1]
        ret double %calltmp
}

ready> asd(120);
ready> ERROR: Program used external function 'putchard' which could
not be resolved!
Abort (core dumped)

Here is the backtrace from the toy.core:
(gdb) backtrace
#0  0x4889cbb7 in kill () from /lib/libc.so.7
#1  0x4868d146 in raise () from /lib/libthr.so.3
#2  0x4889b76a in abort () from /lib/libc.so.7
#3  0x0831f8a0 in llvm::JIT::getPointerToNamedFunction ()
#4  0x0832177a in llvm::JIT::getPointerToFunction ()
#5  0x083275a2 in (anonymous namespace)::JITEmitter::getPointerToGlobal ()
#6  0x083280e4 in (anonymous namespace)::JITEmitter::finishFunction ()
#7  0x0805f8d0 in (anonymous namespace)::Emitter::runOnMachineFunction ()
#8  0x081deee8 in llvm::MachineFunctionPass::runOnFunction ()
#9  0x08561cd7 in llvm::FPPassManager::runOnFunction ()
#10 0x08562185 in llvm::FunctionPassManagerImpl::run ()
#11 0x08562337 in llvm::FunctionPassManager::run ()
#12 0x0831f9ec in llvm::JIT::runJITOnFunction ()
#13 0x08321847 in llvm::JIT::getPointerToFunction ()
#14 0x0804f680 in MainLoop () at toy.cpp:508
#15 0x0804ff12 in main () at toy.cpp:590



More information about the llvm-dev mailing list