[LLVMdev] Forcing the Interpreter segfaults

Duncan Sands baldrick at free.fr
Wed Nov 3 01:28:51 PDT 2010


Hi Salomon,

> Hi everyone !
> I am very new to LLVM and intent to use it in a research project.
> I have a problem with the interpreter: I have a simple compiler that generates
> LLVM bitcode, JIT it and execute it, and it works very well.
> Now I would like to execute it using the interpreter. And I get a segfault.

please open a bugreport with complete code (so others can try to reproduce
this).  Also, did you build LLVM with assertions enabled?  Enabling assertions
usually means you get a helpful failure message rather than a segmentation
fault.

Ciao,

Duncan.

>
> Here is the code :
>
> // This code JIT the function and executes it
> llvm::InitializeNativeTarget();
> llvm::ExecutionEngine * EJ  = llvm::ExecutionEngine::create(&nM);
> typedef int (*REFunc)(const char *);
> union { void * obj; REFunc func; } u;
> u.obj = EJ->getPointerToFunction(func);
> REFunc jit = u.func;
> int ret = jit("aaa");
> std::cout << std::endl << ret << std::endl;
>
> // This code interprets the function
> llvm::initializeCore();
> llvm::ExecutionEngine * EI  =
> llvm::EngineBuilder(&M).setEngineKind(llvm::EngineKind::Interpreter).create();
> EI->runStaticConstructorsDestructors(false);
> std::vector<llvm::GenericValue> args;
> llvm::GenericValue arg1((void*)"aaabc");
> args.push_back(arg1);
> llvm::APInt res = EI->runFunction(func, args).IntVal;
> llvm::outs() << res << "\n";
>
> The first block of code works very well and write the expected result.
> The second block segfaults on the EI->runFunction(func, args) call.
> I can't find my mistake. Would somebody help me on this ???
>
> Thank you very much !
>
> Salomon BRYS.
>
> --
> ###########################################
> # Salomon BRYS
> # +33 (0) 6 83 54 55 96
> #------------------------------------------
> # > EPITECH "Koala" : C++ assistant : Sbire du C++
> # > Zend Certified Engineer for PHP5
> #------------------------------------------
> # All data in this e-mail is confidential.
> # If you are not, or if you don't believe you are, the recipient of this e-mail,
> please delete it.
> #------------------------------------------
> # GPG : http://gpgkey-salomon.antesocial.fr/
> ###########################################
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list