[LLVMdev] Resolving a function symbol using JIT.

sumeeth kc sumeethkc at gmail.com
Mon Oct 7 17:17:18 PDT 2013


Hi All,

Any comments on this?

Thanks,
Sumeeth


On Sun, Oct 6, 2013 at 1:54 PM, sumeeth kc <sumeethkc at gmail.com> wrote:

> Hey,
>
> I have a situation where in I need to intercept a call to a particular
> function and return a pointer to a separate implementation of that function
> using JIT. The scenario is like this:
>
> 1. A test code or client code calls a function A() for which a dummy
> implementation is provided in a library which the test code/client links
> with during compilation.
> 2. I create the .bc using -emit-llvm and run it with lli.
> 3. Now, in the JIT, I have provided the concrete implementation of the
> function A(). I have to intercept this call to function A() and return a
> pointer to the concrete implementation in JIT.
>
> I tried the way external library symbols are being resolved in
> JITMemoryManager.cpp but the error I get is as follows:
>
> pseudo instructions should be removed before code emission
> UNREACHABLE executed at /llvm/lib/Target/X86/X86CodeEmitter.cpp:1175!
> 0  lli             0x00000000011fa92e
> llvm::sys::PrintStackTrace(_IO_FILE*) + 46
> 1  lli             0x00000000011fabeb
> 2  lli             0x00000000011fae4a
> 3  libpthread.so.0 0x00007f08378cecb0
> 4  libc.so.6       0x00007f0836915425 gsignal + 53
> 5  libc.so.6       0x00007f0836918b8b abort + 379
> 6  lli             0x00000000011e1726
> 7  lli             0x0000000000688f83
> 8  lli             0x0000000000688700
> 9  lli             0x0000000000b5789e
> llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 110
> 10 lli             0x0000000001168e7b
> llvm::FPPassManager::runOnFunction(llvm::Function&) + 427
> 11 lli             0x0000000001168777
> llvm::FunctionPassManagerImpl::run(llvm::Function&) + 119
> 12 lli             0x00000000011686e7
> llvm::FunctionPassManager::run(llvm::Function&) + 167
> 13 lli             0x0000000000ac478f
> llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) + 63
> 14 lli             0x0000000000ac467e
> llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard
> const&) + 94
> 15 lli             0x0000000000ac4a9e
> llvm::JIT::getPointerToFunction(llvm::Function*) + 734
> 16 lli             0x0000000000ad7e18
> 17 lli             0x000000000077eb85
> 18 lli             0x000000000077e9ca X86CompilationCallback + 74
> Stack dump:
> 0.    Program arguments: lli -jit-emit-debug test
> 1.    Running pass 'X86 Machine Code Emitter' on function
> '@_ZN4llvm5APInt15clearUnusedBitsEv'
> Aborted
>
> If this approach is not proper, where else can I intercept the call to
> that symbol and return a pointer to the concrete implementation?
>
> Thanks in advance.
>
> -Sumeeth
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131007/ad52ed84/attachment.html>


More information about the llvm-dev mailing list