<div dir="ltr"><div><div><div>Hi All,<br><br></div>Any comments on this?<br><br></div>Thanks, <br></div>Sumeeth<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Oct 6, 2013 at 1:54 PM, sumeeth kc <span dir="ltr"><<a href="mailto:sumeethkc@gmail.com" target="_blank">sumeethkc@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div>Hey,<br><br></div>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:<br>
<br></div>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.<br></div>2. I create the .bc using -emit-llvm and run it with lli.<br>
</div>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.<br><br></div>I tried the way external library symbols are being resolved in JITMemoryManager.cpp but the error I get is as follows:<br>
<br>pseudo instructions should be removed before code emission<br>UNREACHABLE executed at /llvm/lib/Target/X86/X86CodeEmitter.cpp:1175!<br>0 lli 0x00000000011fa92e llvm::sys::PrintStackTrace(_IO_FILE*) + 46<br>
1 lli 0x00000000011fabeb<br>2 lli 0x00000000011fae4a<br>3 libpthread.so.0 0x00007f08378cecb0<br>4 libc.so.6 0x00007f0836915425 gsignal + 53<br>5 libc.so.6 0x00007f0836918b8b abort + 379<br>
6 lli 0x00000000011e1726<br>7 lli 0x0000000000688f83<br>8 lli 0x0000000000688700<br>9 lli 0x0000000000b5789e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 110<br>
10 lli 0x0000000001168e7b llvm::FPPassManager::runOnFunction(llvm::Function&) + 427<br>11 lli 0x0000000001168777 llvm::FunctionPassManagerImpl::run(llvm::Function&) + 119<br>12 lli 0x00000000011686e7 llvm::FunctionPassManager::run(llvm::Function&) + 167<br>
13 lli 0x0000000000ac478f llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) + 63<br>14 lli 0x0000000000ac467e llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard const&) + 94<br>
15 lli 0x0000000000ac4a9e llvm::JIT::getPointerToFunction(llvm::Function*) + 734<br>16 lli 0x0000000000ad7e18<br>17 lli 0x000000000077eb85<br>18 lli 0x000000000077e9ca X86CompilationCallback + 74<br>
Stack dump:<br>0. Program arguments: lli -jit-emit-debug test <br>1. Running pass 'X86 Machine Code Emitter' on function '@_ZN4llvm5APInt15clearUnusedBitsEv'<br>Aborted<br><br></div>If this approach is not proper, where else can I intercept the call to that symbol and return a pointer to the concrete implementation?<br>
<br></div>Thanks in advance.<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888">-Sumeeth<br></font></span></div>
</blockquote></div><br></div>