[llvm-dev] crash JIT with AVX intrinsics

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 10 12:04:44 PDT 2016


Hi Henning,

On 10 August 2016 at 08:04, Henning Thielemann via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> My problem is that the simple C program crashes on newer LLVM versions. The
> preprocessor conditionals show my attempts to replace the AVX 8-float vector
> by a SSE 4-float vector or by a scalar and to replace the rounding by a
> simple addition.

For some reason, even though you're getting an ExecutionEngine there's
actually been an error: "Interpreter has not been linked in.". 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.

It still doesn't run because LLVMRunFunction can't handle calling
functions with arbitrary prototypes from C or C++. It can handle the
common "main" prototypes, but not much more. Some workarounds are:

  + Pass in some context to a main-like function.
  + Compile a special main-like function that's been told the
addresses you're using:
       define void @main() {
          call void @round(<8 x float>* inttoptr(i64 $MAGIC_NUMBER to
<8 x float>*))
          ret void
       }
  + 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).

Cheers.

Tim.


More information about the llvm-dev mailing list