LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 419 - JIT Needs To Support Arbitrary Function Call
Summary: JIT Needs To Support Arbitrary Function Call
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: MCJIT (show other bugs)
Version: 1.0
Hardware: All All
: P normal
Assignee: Chris Lattner
URL:
Keywords: missing-feature
Depends on:
Blocks:
 
Reported: 2004-08-14 20:12 PDT by Reid Spencer
Modified: 2010-02-22 12:45 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Reid Spencer 2004-08-14 20:12:02 PDT
Currently, the JIT class supports calling of only two function prototypes:
  void func(int)
  int func(int, char**)

This is a known limitation of the current implementation but a more generic
solution could be developed so that any function could be invoked. There is a
FIXME in llvm::JIT::runFunction that reads:

  // FIXME: This code should handle a couple of common cases efficiently, but
  // it should also implement the general case by code-gening a new anonymous
  // nullary function to call.

There are several different ways to fix the problem, as hinted at by the
comment.  In the short term, adding something like this:

} else if (ArgValues.empty()) {
  void (*PF)() = (void(*)())getPointerToFunction(F);
  assert(PF && "Pointer to fn's code was null after getPointerToFunction");
  PF();

before the "else" case, should fix the issue.  That code is basically only smart
enough to run 'main', but could be enhanced by someone interested in it to
handle the general case.