[LLVMdev] An enhancement for MCJIT::getFunctionAddress

Yaron Keren yaron.keren at gmail.com
Sat Oct 19 15:16:42 PDT 2013


In MCJIT, the old JIT functions are deprecated in favor
of getFunctionAddress.
Code like:

  llvm::Function *F = M->getFunction(FuncName);
  void *FN = EE->getPointerToFunction(F);

should be rewritten as

  uint64_t FN = EE->getFunctionAddress(FuncName);

While functionally identical, in case the correct module is known the new
version will be much slower, linear with the number of added (but not
loaded) modules, since it has to (possibly) search for the correct module
while old code directly searches the correct module.

To solve the issue, getFunctionAddress could get an optional Module "hint"
(=NULL by default) which - if provided - will make getSymbolAddress skip
calling findModuleForSymbol (a very slow operation) and instead directly
use the Module provided.

Yaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131020/04318b9d/attachment.html>


More information about the llvm-dev mailing list