[llvm-dev] crash JIT with AVX intrinsics

Henning Thielemann via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 10 14:07:55 PDT 2016

Hi Tim,

I experimented for days now without success and your answer eventually 
solved the problem! I still have some questions.

On Wed, 10 Aug 2016, Tim Northover wrote:

> For some reason, even though you're getting an ExecutionEngine there's
> actually been an error: "Interpreter has not been linked in.".

I have added a check for the result of LLVMCreateExecutionEngineForModule 
and it returned successfully.

> I've seen this one before, and (for reasons I don't fully understand) 
> you need to include "llvm/ExecutionEngine/MCJIT.h" in your .cpp file to 
> fix it.

I have seen people calling LinkInMCJIT() in their code. Would that be 
equivalent? In ExecutionEngine/MCJIT.h I read:

       // We must reference MCJIT in such a way that compilers will not
       // delete it all as dead code, even with whole program optimization,

Anyway, neither including ExecutionEngine/MCJIT.h nor calling LinkInMCJIT 
affects whether my program crashes or not.

> It still doesn't run because LLVMRunFunction can't handle calling
> functions with arbitrary prototypes from C or C++.

I used LLVMRunFunction only for the example. What you say sounds like a 
regression from LLVM-3.5 where LLVMRunFunction worked with that prototype. 
Was this an intended regression and is it documented somewhere? If yes, 
then people should be warned with a deprecation pragma and I guess 
LLVMRunFunctionAsMain should be the prefered function then?

>  + Get a raw pointer to the function, cast it to the correct C type 
> yourself and call it (this assumes you're not interested in remote JIT).

I use LLVMGetPointerToGlobal now and this solves all problems!

Thanks a lot!

More information about the llvm-dev mailing list