Commit Graph

97 Commits

Author SHA1 Message Date
Axel Naumann
7e2955f8de Remove unused "remap symbols". 2015-02-11 10:57:46 +01:00
Axel Naumann
8efd56133d Implement getMissingSymbolAddress(). Take ref to IncrementalExecutor.
Weak symbols can be generated after getSymbolAddress(). Instead them "error" part
now needs to go through getMissingSymbolAddress().
2015-02-11 10:57:46 +01:00
Axel Naumann
b59de8a40a Adapt to clang/llvm changes (mostly ownership). 2015-02-11 10:57:43 +01:00
Axel Naumann
9c2d9fb700 Simplify interface: no need for the llvm::Module. 2015-02-11 10:57:41 +01:00
Axel Naumann
46673943f8 MCJIT knows where to find things, do not rely on the module (which one?) 2015-02-11 10:57:40 +01:00
Axel Naumann
9bae38af55 Check for missing symbols found during relocations. 2015-02-11 10:57:37 +01:00
Axel Naumann
e919b241c8 Remove unused struct. 2015-02-11 10:57:36 +01:00
Axel Naumann
061cd37390 Provide __cxa_atexit replacement through custom MemoryManager.
On some platforms, global destructors are registered through a call to
__cxa_atexit(dtor, 0/*args*/, __dso_handle). While __cxa_atexit can be resolved
by the regular MemoryManager, __dso_handle (representing the "current shared
library" such that the corresponding atexit function can be called on its
dlclose) can not be resolved by MCJIT. Instead, we provide our own, poining to
the ExecutionEngine, which in turn holds a "current module" that corresponds in
spirit to the shared library handle.

__cxa_atexit, on the other hand, needs to be re-wired: the interpreter needs to
destruct globals upon its destruction, and those globals from a certain module
when that module is unloaded.

Both is done through a custom MemoryManager, significantly reducing the
complexity of the previous ("JIT without MC") implementation.

The custom MemoryManager also forwards in case of a unknown symbols to the LazyFunctionCreators instead of using the generic
ExecutionEngine::InstallLazyFunctionCreator() which has no effect with MCJIT.
2015-02-11 10:57:36 +01:00
Axel Naumann
2ee6383c36 Remove inline asm boost hack: not needed for MCJIT. 2015-02-11 10:57:35 +01:00
Axel Naumann
baf51f6b04 Create a new llvm::Module per codegen'ed transaction.
MCJIT needs to finalize modules. To simplify the interface with MCJIT, each
transaction now has its own module. It gets created when the previous module
gets passed to the execution engine; the first one is created by
clang::CreateLLVMCodeGen(). CodeGen now releases the module such that it can be
added to the execution engine.

This enables simple use cases of cling with MCJIT; most notably cross-module
linking is still missing.
2015-02-11 10:57:34 +01:00
Axel Naumann
d22c54fd61 Return 0 to signal missing symbols. 2014-10-22 19:16:06 +02:00
Axel Naumann
2dc1fdc217 Silence warning. Keep the FIXME visible :-) 2014-10-16 16:11:05 +02:00
Axel Naumann
2243b3bfdb Bring back old diag format. 2014-10-16 11:26:07 +02:00
Axel Naumann
61dbdbd506 Refactor diag of unresolved syms; also diagnose in getAddressOfGlobal(). 2014-10-15 11:39:12 +02:00
Vassil Vassilev
56473aa73e Name got changed from _GLOBAL__I_a to _GLOBAL__sub_I__. 2014-08-14 14:56:35 +02:00
Vassil Vassilev
a57c866b3d Silence a warning. 2014-06-13 09:19:57 +02:00
Vassil Vassilev
2c16f39465 Align up the comment properly. 2014-06-04 12:12:14 +02:00
Vassil Vassilev
21d9481ce0 Clang diagnostics cause havoc, disable until understood. 2014-06-04 12:06:03 +02:00
Vassil Vassilev
86c66f2b73 Remove useless error msg. 2014-06-04 09:20:09 +02:00
Vassil Vassilev
213141cb5c Use the more user-friendly clang diagnostics engine to produce execution errors. 2014-06-04 09:20:09 +02:00
CristinaCristescu
d85eba73ee Default cling::Value set to invalid.
The cling::Value is initialized to be invalid then the value extraction changes it or not. If we do not have an available copy constructor for objects the value stays invalid.
2014-05-26 18:30:57 +02:00
Axel Naumann
ed65edecb3 Fix func/ptr cast warning; work around MSVC2012 lack of C++11. 2014-04-28 15:55:58 +02:00
Axel Naumann
05e3be6503 Fix non-GCC (and non-thread-safe!) case. 2014-04-28 15:13:57 +02:00
Axel Naumann
e85b873a26 Also replace boost::detail::atomic_exchange_and_add for the interpreter.
Generalize the __cxa_atexit replacement to cover more symbols.
Because the JIT cannot handle inline asm, provide compiled symbols for relevant
functions until cling has switched to MCJIT.
This fixes the use of many boost libraries (e.g. regex) in cling on x86_64/i386.
Kudos to Marco Clemencic for the idea!
2014-04-28 12:38:15 +02:00
Axel Naumann
93970e8c35 Replace StoredValueRef by Value. 2014-04-01 18:31:58 +02:00
Vassil Vassilev
ff57cb4da0 Collect all functions that we need to delete and delete them 2014-03-15 10:08:24 +01:00
Vassil Vassilev
1aa3c27c06 @_GLOBAL__I_aN can have multiple calls also 2014-03-15 10:08:24 +01:00
Vassil Vassilev
344657830e Add clarification comment. 2014-03-15 10:08:24 +01:00
Vassil Vassilev
1f7d6836f8 Remove the functions after the loop is done. 2014-03-14 10:52:29 +01:00
Vassil Vassilev
fff83003a6 Protect against calling a function with an unexpected signature. 2014-03-14 10:52:29 +01:00
Vassil Vassilev
4e4d39d389 Make it power of 2. 2014-03-14 10:52:29 +01:00
Vassil Vassilev
bb46c353f0 Style consistency. 2014-03-14 10:52:29 +01:00
Vassil Vassilev
b5e6cb8dee Use runFunction for running inits. Let's see whether it imporves LHCb builds 2014-03-14 10:52:29 +01:00
Vassil Vassilev
66c59788d5 Remove @_GLOBAL__I_a and @__cxx_global_var_init after running them. 2014-03-14 10:52:28 +01:00
Vassil Vassilev
5e5e7e9d1f Improve consistency. IncrementalExecutor should use llvm by default. 2014-03-14 10:52:28 +01:00
Axel Naumann
c505d76e2f Fix constness warning. 2014-03-05 09:46:09 +01:00
Axel Naumann
6325e7ed19 Keep trying to remap __cxa_atexit until succeeded.
__cxa_atexit is generated by clang::CodeGen upon seeing the first static
destructor. Instead of trying to provoke that we just continue to search for it.
2014-03-04 19:55:00 +01:00
Axel Naumann
baca204185 Simplify cxa_atexit(), first part.
Remove trigger__cxa_atexit(), we will just remap until successful.
Remove unused dso parameter.
Instead of friending just provide a function.
Pass a transaction, the typesafe way.
2014-03-04 19:54:59 +01:00
Vassil Vassilev
8d457e947f StringRef-y. 2014-03-03 15:27:05 +01:00
Vassil Vassilev
c7503fbe79 Inline. 2014-03-03 15:27:05 +01:00
Vassil Vassilev
15918cd889 Remove unused interface. 2014-03-03 15:27:05 +01:00
Vassil Vassilev
150231c357 Run only dtors of the unloaded entities. 2014-02-27 12:49:11 +01:00
Vassil Vassilev
e89b570618 Use iterators instead. 2014-02-27 12:49:11 +01:00
Vassil Vassilev
e7b0024c88 Doesn't depend on neither the module nor the execution engine. 2014-02-27 12:49:10 +01:00
Vassil Vassilev
bd023123b0 No llvm.global_dtors variable in the module. 2014-02-27 12:49:09 +01:00
Vassil Vassilev
4eeddf8a8c Bind cxa_atexit to the Transaction instead of the Decl. 2014-02-27 12:49:09 +01:00
Vassil Vassilev
2309fc097e Rename ExecutionContext -> IncrementalExecutor 2014-02-19 12:55:00 +01:00