summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/JIT/JIT.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Implement the JIT side of the GDB JIT debugging interface. To enable thisReid Kleckner2009-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | feature, either build the JIT in debug mode to enable it by default or pass -jit-emit-debug to lli. Right now, the only debug information that this communicates to GDB is call frame information, since it's already being generated to support exceptions in the JIT. Eventually, when DWARF generation isn't tied so tightly to AsmPrinter, it will be easy to push that information to GDB through this interface. Here's a step-by-step breakdown of how the feature works: - The JIT generates the machine code and DWARF call frame info (.eh_frame/.debug_frame) for a function into memory. - The JIT copies that info into an in-memory ELF file with a symbol for the function. - The JIT creates a code entry pointing to the ELF buffer and adds it to a linked list hanging off of a global descriptor at a special symbol that GDB knows about. - The JIT calls a function marked noinline that GDB knows about and has put an internal breakpoint in. - GDB catches the breakpoint and reads the global descriptor to look for new code. - When sees there is new code, it reads the ELF from the inferior's memory and adds it to itself as an object file. - The JIT continues, and the next time we stop the program, we are able to produce a proper backtrace. Consider running the following program through the JIT: #include <stdio.h> void baz(short z) { long w = z + 1; printf("%d, %x\n", w, *((int*)NULL)); // SEGFAULT here } void bar(short y) { int z = y + 1; baz(z); } void foo(char x) { short y = x + 1; bar(y); } int main(int argc, char** argv) { char x = 1; foo(x); } Here is a backtrace before this patch: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x2aaaabdfbd10 (LWP 25476)] 0x00002aaaabe7d1a8 in ?? () (gdb) bt #0 0x00002aaaabe7d1a8 in ?? () #1 0x0000000000000003 in ?? () #2 0x0000000000000004 in ?? () #3 0x00032aaaabe7cfd0 in ?? () #4 0x00002aaaabe7d12c in ?? () #5 0x00022aaa00000003 in ?? () #6 0x00002aaaabe7d0aa in ?? () #7 0x01000002abe7cff0 in ?? () #8 0x00002aaaabe7d02c in ?? () #9 0x0100000000000001 in ?? () #10 0x00000000014388e0 in ?? () #11 0x00007fff00000001 in ?? () #12 0x0000000000b870a2 in llvm::JIT::runFunction (this=0x1405b70, F=0x14024e0, ArgValues=@0x7fffffffe050) at /home/rnk/llvm-gdb/lib/ExecutionEngine/JIT/JIT.cpp:395 #13 0x0000000000baa4c5 in llvm::ExecutionEngine::runFunctionAsMain (this=0x1405b70, Fn=0x14024e0, argv=@0x13f06f8, envp=0x7fffffffe3b0) at /home/rnk/llvm-gdb/lib/ExecutionEngine/ExecutionEngine.cpp:377 #14 0x00000000007ebd52 in main (argc=2, argv=0x7fffffffe398, envp=0x7fffffffe3b0) at /home/rnk/llvm-gdb/tools/lli/lli.cpp:208 And a backtrace after this patch: Program received signal SIGSEGV, Segmentation fault. 0x00002aaaabe7d1a8 in baz () (gdb) bt #0 0x00002aaaabe7d1a8 in baz () #1 0x00002aaaabe7d12c in bar () #2 0x00002aaaabe7d0aa in foo () #3 0x00002aaaabe7d02c in main () #4 0x0000000000b870a2 in llvm::JIT::runFunction (this=0x1405b70, F=0x14024e0, ArgValues=...) at /home/rnk/llvm-gdb/lib/ExecutionEngine/JIT/JIT.cpp:395 #5 0x0000000000baa4c5 in llvm::ExecutionEngine::runFunctionAsMain (this=0x1405b70, Fn=0x14024e0, argv=..., envp=0x7fffffffe3c0) at /home/rnk/llvm-gdb/lib/ExecutionEngine/ExecutionEngine.cpp:377 #6 0x00000000007ebd52 in main (argc=2, argv=0x7fffffffe3a8, envp=0x7fffffffe3c0) at /home/rnk/llvm-gdb/tools/lli/lli.cpp:208 llvm-svn: 82418
* Push LLVMContexts through the IntegerType APIs.Owen Anderson2009-08-131-10/+14
| | | | llvm-svn: 78948
* Move types back to the 2.5 API.Owen Anderson2009-07-291-2/+1
| | | | llvm-svn: 77516
* Move ConstantExpr to 2.5 API.Owen Anderson2009-07-291-1/+1
| | | | llvm-svn: 77494
* Move ConstantFP construction back to the 2.5-ish API.Owen Anderson2009-07-271-3/+3
| | | | llvm-svn: 77247
* Revert the ConstantInt constructors back to their 2.5 forms where possible, ↵Owen Anderson2009-07-241-3/+3
| | | | | | thanks to contexts-on-types. More to come. llvm-svn: 77011
* Get rid of the Pass+Context magic.Owen Anderson2009-07-221-9/+9
| | | | llvm-svn: 76702
* Simplify / normalize some uses of Value::getName.Daniel Dunbar2009-07-211-1/+1
| | | | llvm-svn: 76553
* Add EngineBuilder to ExecutionEngine in favor of the five optional argument ↵Reid Kleckner2009-07-181-6/+23
| | | | | | | | EE::create(). Also a test commit. llvm-svn: 76276
* Move EVER MORE stuff over to LLVMContext.Owen Anderson2009-07-141-8/+10
| | | | llvm-svn: 75703
* llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.Torok Edwin2009-07-141-4/+4
| | | | | | | | | This adds location info for all llvm_unreachable calls (which is a macro now) in !NDEBUG builds. In NDEBUG builds location info and the message is off (it only prints "UREACHABLE executed"). llvm-svn: 75640
* assert(0) -> LLVM_UNREACHABLE.Torok Edwin2009-07-111-4/+4
| | | | | | | | | Make llvm_unreachable take an optional string, thus moving the cerr<< out of line. LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for NDEBUG builds. llvm-svn: 75379
* Convert more assert(0)+abort() -> LLVM_UNREACHABLE,Torok Edwin2009-07-111-13/+7
| | | | | | and abort()/exit() -> llvm_report_error(). llvm-svn: 75363
* Add an option to allocate JITed global data separately from code. ByJeffrey Yasskin2009-07-081-37/+41
| | | | | | | | | | | | | | default, this option is not enabled to support clients who rely on this behavior. Fixes http://llvm.org/PR4483 A patch to allocate additional memory for globals after we run out is forthcoming. Patch by Reid Kleckner! llvm-svn: 75059
* Introduce new error handling API.Torok Edwin2009-07-071-3/+3
| | | | | | | | This will replace exit()/abort() style error handling with an API that allows clients to register custom error handling hooks. The default is to call exit(1) when no error handler is provided. llvm-svn: 74922
* improve the APIs for creating struct and function types with no ↵Chris Lattner2009-07-011-1/+1
| | | | | | | | arguments/elements to not have to create a temporary vector (in the API at least). Patch by Jay Foad! llvm-svn: 74584
* Add a JITEventListener interface that gets called back when a new function isJeffrey Yasskin2009-06-251-3/+53
| | | | | | | | | emitted or the machine code for a function is freed. Chris mentioned that we may also want a notification when a stub is emitted, but that'll be a future change. I intend to use this to tell oprofile where functions are emitted and what lines correspond to what addresses. llvm-svn: 74157
* Fix the Ocaml bindings for the ExecutionEngine: with the change to buildBob Wilson2009-06-241-3/+1
| | | | | | | | libraries instead of relinked objects, the interpreter, JIT, and native target libraries were not being linked in to an ocaml program using the ExecutionEngine. llvm-svn: 74117
* After obtaining the lock, look if the function has been codegen'd byNicolas Geoffray2009-06-121-0/+5
| | | | | | another thread. llvm-svn: 73227
* First patch in the direction of splitting MachineCodeEmitter in two subclasses:Bruno Cardoso Lopes2009-05-301-9/+9
| | | | | | JITCodeEmitter and ObjectCodeEmitter. No functional changes yet. Patch by Aaron Gray llvm-svn: 72631
* Allow the JIT ExecutionEngine to report details about the generated machine ↵Argyrios Kyrtzidis2009-05-181-1/+7
| | | | | | | | | | code. Introduce a new class (MachineCodeInfo) that the JIT can fill in with details. Right now, just the address and the size of the machine code are reported. Patch by Evan Phoenix! llvm-svn: 72040
* Rename PaddedSize to AllocSize, in the hope that thisDuncan Sands2009-05-091-2/+2
| | | | | | | will make it more obvious what it represents, and stop it being confused with the StoreSize. llvm-svn: 71349
* Instead of passing in an unsigned value for the optimization level, use an enum,Bill Wendling2009-04-291-5/+5
| | | | | | | which better identifies what the optimization is doing. And is more flexible for future uses. llvm-svn: 70440
* The second part of the change from -fast to -O#. This changes the JIT to acceptBill Wendling2009-04-291-7/+7
| | | | | | | an optimization level instead of a simple boolean telling it to generate code "fast" or the other type of "fast". llvm-svn: 70347
* make sure to unlock keymgr if the JIT is created and destroyed, allChris Lattner2009-04-161-5/+3
| | | | | | | | locks must be matched with unlocks. Also, use calloc to allocate the block so that it is properly zero'd. Thanks to Nick Kledzik for tracking this down. llvm-svn: 69314
* Mac OS X 10.6 and above do not use key manager to register EH frames.Evan Cheng2009-04-141-2/+8
| | | | llvm-svn: 69090
* Introduce new linkage types linkonce_odr, weak_odr, common_odrDuncan Sands2009-03-071-2/+2
| | | | | | | | | | | | | | | | | | | | | and extern_weak_odr. These are the same as the non-odr versions, except that they indicate that the global will only be overridden by an *equivalent* global. In C, a function with weak linkage can be overridden by a function which behaves completely differently. This means that IP passes have to skip weak functions, since any deductions made from the function definition might be wrong, since the definition could be replaced by something completely different at link time. This is not allowed in C++, thanks to the ODR (One-Definition-Rule): if a function is replaced by another at link-time, then the new function must be the same as the original function. If a language knows that a function or other global can only be overridden by an equivalent global, it can give it the weak_odr linkage type, and the optimizers will understand that it is alright to make deductions based on the function body. The code generators on the other hand map weak and weak_odr linkage to the same thing. llvm-svn: 66339
* Finish cross-process JIT work, and clean up previous work.Nate Begeman2009-03-071-1/+2
| | | | | | | | | | | | | | | | 1. When the JIT is asked to remove a function, updating it's mapping to 0, we invalidate any function stubs used only by that function. Now, also invalidate the JIT's mapping from the GV the stub pointed to, to the address of the GV. 2. When dlsym stubs for cross-process JIT are enabled, do not abort just because a named function cannot be found in the JIT's process. 3. Fix various assumptions about when it is ok to use the lazy resolver when non-lazy JITing is enabled. llvm-svn: 66324
* Fix a thinko in the JIT where the address of a GV was only recorded in the mapNate Begeman2009-03-041-2/+2
| | | | | | | | | on failure to resolve it. Do not abort on failure to resolve an external symbol when using dlsym stubs, since the symbol may not be in the JIT's address space. Just use 0. Allow dlsym stubs to differentiate between GlobalVars and Functions. llvm-svn: 66050
* don't #include a header into the middle of an anon namespace.Chris Lattner2009-03-031-7/+5
| | | | llvm-svn: 65967
* Fix the logic in this assertion to properly validate the numberDan Gohman2009-02-191-2/+3
| | | | | | of arguments. llvm-svn: 64999
* Reapply r57340. VMKit does not presently rely on materializeFunctionDan Gohman2009-02-191-2/+2
| | | | | | | being called with the lock released, and this fixes a race condition in the JIT as used by lli. llvm-svn: 64997
* Add support to the JIT for true non-lazy operation. When a call to a functionNate Begeman2009-02-181-9/+61
| | | | | | | | | | | | | | | | | | | | that has not been JIT'd yet, the callee is put on a list of pending functions to JIT. The call is directed through a stub, which is updated with the address of the function after it has been JIT'd. A new interface for allocating and updating empty stubs is provided. Add support for removing the ModuleProvider the JIT was created with, which would otherwise invalidate the JIT's PassManager, which is initialized with the ModuleProvider's Module. Add support under a new ExecutionEngine flag for emitting the infomration necessary to update Function and GlobalVariable stubs after JITing them, by recording the address of the stub and the name of the GlobalValue. This allows code to be copied from one address space to another, where libraries may live at different virtual addresses, and have the stubs updated with their new correct target addresses. llvm-svn: 64906
* Split the locking out of JIT::runJITOnFunction so that callersDan Gohman2009-02-061-3/+6
| | | | | | | that already hold the lock can call an entry point that doesn't re-acquire the lock. llvm-svn: 63965
* Fix PR3423: Link llvm on ARM EABI machines. Patch by Robert Schuster.Evan Cheng2009-02-011-3/+3
| | | | llvm-svn: 63489
* Add support for deleting a module provider from a JIT in such a way that it ↵Nate Begeman2009-01-231-0/+13
| | | | | | does not cause the owned module to be fully materialized. llvm-svn: 62864
* Change isGVCompilationDisabled() semantics again. It should abort on any GV ↵Evan Cheng2009-01-161-1/+4
| | | | | | that's not constant whether it's "internal" or not. In a server / client environment, GV is returned in the same block of memory as code. However, the memory might not be writable. llvm-svn: 62336
* Add the private linkage.Rafael Espindola2009-01-151-1/+1
| | | | llvm-svn: 62279
* Rename getABITypeSize to getTypePaddedSize, asDuncan Sands2009-01-121-2/+2
| | | | | | suggested by Chris. llvm-svn: 62099
* Handle weak_extern in the JIT. This fixesDan Gohman2009-01-051-4/+5
| | | | | | | | SingleSource/UnitTests/2007-04-25-weak.c in JIT mode. The test now passes on systems which are able to produce a correct reference output to compare with. llvm-svn: 61674
* DisableGVCompilation should not abort on internal GlobalValue's.Evan Cheng2008-12-091-2/+2
| | | | llvm-svn: 60750
* Make JIT::runFunction handle functions with non-C calling conventions.Chris Lattner2008-11-231-0/+1
| | | | llvm-svn: 59904
* For some targets, it's not possible to place GVs in the same memory buffer ↵Evan Cheng2008-11-041-0/+10
| | | | | | | | as the MachineCodeEmitter allocated memory. Code and data has different read / write / execution privilege requirements. This is a short term workaround. The current solution is for the JIT memory manager to manage code and data memory separately. llvm-svn: 58688
* Support for allocation of TLS variables in the JIT. Allocation of a globalNicolas Geoffray2008-10-251-1/+20
| | | | | | | | variable is moved to the execution engine. The JIT calls the TargetJITInfo to allocate thread local storage. Currently, only linux/x86 knows how to allocate thread local global variables. llvm-svn: 58142
* Revert r57340 move guard mutex in getPointerToFunction as this can causeMon P Wang2008-10-101-2/+2
| | | | | | deadlock issues with java llvm-svn: 57356
* Moved guard mutex upwards to guard materializing a functionMon P Wang2008-10-101-3/+3
| | | | | | in getPointerToFunction llvm-svn: 57340
* Add DisableGVCompilation which forces the JIT to assert when it tries to ↵Evan Cheng2008-09-241-0/+4
| | | | | | allocate space for a GlobalVariable. llvm-svn: 56557
* Add support for JIT exceptions on Darwin. Since we're dealing with libgcc,Nicolas Geoffray2008-08-281-2/+135
| | | | | | | whose darwin code was written after the ability to dynamically register frames, we need to do special hacks to make things work. llvm-svn: 55507
* Register the frame register function when allocating the JIT,Nicolas Geoffray2008-08-181-5/+5
| | | | | | so that lli works out of the box with -enable-eh. llvm-svn: 54920
* Add new parameter Fast to createJIT to enable the fast codegen path.Evan Cheng2008-08-081-4/+5
| | | | llvm-svn: 54523
OpenPOWER on IntegriCloud