This is an archive of the discontinued LLVM Phabricator instance.

[OCaml] Build a wrapper for LLVMGetFunctionAddress
ClosedPublic

Authored by artagnon on Dec 22 2014, 10:20 AM.

Details

Reviewers
whitequark
Summary

I've verified that the LLVMGetFunctionAddress is receiving the right
string, and calling down to the MCJIT implementation of
getFunctionAddress. However, getSymbolAddress does not seem to want to
cooperate with us, and returns 0 for a perfectly valid function. Why
LLVMGetFunctionAddress works via the C API, but not via the OCaml API
after having verified that the arguments are right stumps me.

Perhaps there is some name mangling going on when OCaml emits the IR? I
can't imagine why, but it's the only explanation I've been able to reach
so far.

Diff Detail

Event Timeline

artagnon updated this revision to Diff 17565.Dec 22 2014, 10:20 AM
artagnon retitled this revision from to [OCaml] Build a wrapper for LLVMGetFunctionAddress.
artagnon updated this object.
artagnon added a reviewer: whitequark.
artagnon added a subscriber: Unknown Object (MLST).
artagnon updated this revision to Diff 17612.Dec 23 2014, 4:12 PM

Note the limitations of gfa, fix tests.

whitequark edited edge metadata.Dec 23 2014, 4:16 PM

Can you please:

  1. Add binding for LLVMGetGlobalValueAddress
  2. Remove get_pointer_to_global entirely (it was never in a release and it's deprecated)
artagnon updated this revision to Diff 17616.Dec 23 2014, 5:35 PM
artagnon edited edge metadata.

Two suggestions by whitequark:

  1. Remove gptg.
  2. Expose gva as well.

The wording in the documentation is a bit unclear.

I suggest:
Caution: this function finalizes, i.e. forces code generation, all loaded modules.
Further modifications to the modules will not have any effect.

artagnon updated this revision to Diff 17618.Dec 23 2014, 5:48 PM

Use whitequark-suggested wording.

whitequark accepted this revision.Dec 23 2014, 5:51 PM
whitequark edited edge metadata.
This revision is now accepted and ready to land.Dec 23 2014, 5:51 PM