[LLVMdev] is this code really JITed and/or optimized=?koi8-r?Q?=3F=20?=..

Chris Lattner sabre at nondot.org
Sat Aug 14 13:49:37 PDT 2004


On Sat, 14 Aug 2004, Valery A.Khamenya wrote:
> > >   ExecutionEngine* EE = ExecutionEngine::create( MP, true );
> > As Reid pointed out, changing true to false will get it to work.
>
> as I've posted already, I got Segmentation Fault.
> Now, i have re-compiled LLVM with debug support.
>
> The evaluation is broken at line 78 in file:
> lib/ExecutionEngine/JIT/JIT.cpp
>
> The assertion
>
>     assert(ArgValues.size() == 1);
>
> fails. But what's wrong? My function has type
> int FooF(void);
> so ArgValues should have size 0, right?

Yes, you're right.

> BTW, the code of runFunction is quite unclear, indeed, for some reason
> cases ArgValues==3 and ArgValues==1 are specially considered... I looked
> in JIT.h for more description on interface -- quite ascetic info,
> nothing interesting. Anyway, few lines of documentation could make life
> easier for other guys too.

If you look at the 3 lines above the assert that is failing, you'll see
this:

    // FIXME: This code should handle a couple of common cases efficiently, but
    // it should also implement the general case by code-gening a new anonymous
    // nullary function to call.

Basically it's saying that we only support one argument functions that
take an integer right now.  This is a bug/suboptimality, hence the FIXME.

There are several different ways to fix the problem, as hinted at by the
comment.  In the short term, adding something like this:

  } else if (ArgValues.empty()) {
    void (*PF)() = (void(*)())getPointerToFunction(F);
    assert(PF && "Pointer to fn's code was null after getPointerToFunction");
    PF();

before the "else" case, should fix the issue for you.  That code is
basically only smart enough to run 'main', but could be enhanced by
someone interested in it to handle the general case.

-Chris

-- 
http://llvm.org/
http://nondot.org/sabre/




More information about the llvm-dev mailing list