summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
Commit message (Collapse)AuthorAgeFilesLines
...
* Add ability to set code model within the execution engine buildersEric Christopher2009-11-173-8/+15
| | | | | | and creation interfaces. llvm-svn: 89151
* Fail less mysteriously; inform the user that their LLVM was not built withNick Lewycky2009-11-171-0/+3
| | | | | | | libffi support and that the interpreter can't call external functions without it. Patch by Timo Juhani Lindfors! Fixes PR5466. llvm-svn: 89062
* Make X86-64 in the Large model always emit 64-bit calls.Jeffrey Yasskin2009-11-161-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The large code model is documented at http://www.x86-64.org/documentation/abi.pdf and says that calls should assume their target doesn't live within the 32-bit pc-relative offset that fits in the call instruction. To do this, we turn off the global-address->target-global-address conversion in X86TargetLowering::LowerCall(). The first attempt at this broke the lazy JIT because it can separate the movabs(imm->reg) from the actual call instruction. The lazy JIT receives the address of the movabs as a relocation and needs to record the return address from the call; and then when that call happens, it needs to patch the movabs with the newly-compiled target. We could thread the call instruction into the relocation and record the movabs<->call mapping explicitly, but that seems to require at least as much new complication in the code generator as this change. To fix this, we make lazy functions _always_ go through a call stub. You'd think we'd only have to force lazy calls through a stub on difficult platforms, but that turns out to break indirect calls through a function pointer. The right fix for that is to distinguish between calls and address-of operations on uncompiled functions, but that's complex enough to leave for someone else to do. Another attempt at this defined a new CALL64i pseudo-instruction, which expanded to a 2-instruction sequence in the assembly output and was special-cased in the X86CodeEmitter's emitInstruction() function. That broke indirect calls in the same way as above. This patch also removes a hack forcing Darwin to the small code model. Without far-call-stubs, the small code model requires things of the JITMemoryManager that the DefaultJITMemoryManager can't provide. Thanks to echristo for lots of testing! llvm-svn: 88984
* Implement DISABLE_INLINE for MSVC. This required changing the position in allBenjamin Kramer2009-11-141-1/+1
| | | | | | forward declaration and patching tblgen to emit it right. Patch by Amine Khaldi! llvm-svn: 88798
* Use stubs when we have them, otherwise use code we already have,Eric Christopher2009-11-121-65/+68
| | | | | | | | otherwise create a stub. Add a test to make sure we don't create extraneous stubs. llvm-svn: 86941
* Fix typo, cleanup whitespace.Eric Christopher2009-11-121-35/+35
| | | | llvm-svn: 86917
* Remove dlsym stubs, with Nate Begeman's permission.Jeffrey Yasskin2009-11-095-142/+8
| | | | llvm-svn: 86606
* Remove ByteswapSCANFResults, it is dead.Daniel Dunbar2009-11-081-76/+0
| | | | llvm-svn: 86458
* We don't need to byteswap, the interpreter assumes the program is runningNick Lewycky2009-11-081-8/+1
| | | | | | native anyways. This fixes a crash using %d and similar in a scanf statement. llvm-svn: 86440
* Fix the interpreter to not crash due to zeroext/signextNick Lewycky2009-11-081-10/+0
| | | | llvm-svn: 86428
* Make the need-stub variables accurate and consistent. In the case ofJeffrey Yasskin2009-11-071-15/+13
| | | | | | | | | | | | | MachineRelocations, "stub" always refers to a far-call stub or a load-a-faraway-global stub, so this patch adds "Far" to the term. (Other stubs are used for lazy compilation and dlsym address replacement.) The variable was also inconsistent between the positive and negative sense, and the positive sense ("NeedStub") was more demanding than is accurate (since a nearby-enough function can be called directly even if the platform often requires a stub). Since the negative sense causes double-negatives, I switched to "MayNeedFarStub" globally. llvm-svn: 86363
* Give the JITResolver a direct pointer to its JITEmitter, and use that insteadJeffrey Yasskin2009-11-071-235/+234
| | | | | | | of going through the global TheJIT variable. This makes it easier to use features of JITEmitter that aren't in JITCodeEmitter for fixing PR5201. llvm-svn: 86305
* Fix MSVC build.Benjamin Kramer2009-10-291-0/+1
| | | | llvm-svn: 85505
* add interpreter support for indirect goto / blockaddress. The interpreterChris Lattner2009-10-294-13/+29
| | | | | | | now correctly runs clang's test/CodeGen/indirect-goto.c. The JIT will abort on it until someone feels compelled to implement this. llvm-svn: 85488
* Change the JIT to compile eagerly by default as agreed inJeffrey Yasskin2009-10-273-11/+11
| | | | | | | http://llvm.org/PR5184, and beef up the comments to describe what both options do and the risks of lazy compilation in the presence of threads. llvm-svn: 85295
* Fix OProfileJITEventListener after r85182.Jeffrey Yasskin2009-10-271-1/+1
| | | | llvm-svn: 85192
* Automatically do the equivalent of freeMachineCodeForFunction(F) when F isJeffrey Yasskin2009-10-274-21/+40
| | | | | | | | | | | | | being destroyed. This allows users to run global optimizations like globaldce even after some functions have been jitted. This patch also removes the Function* parameter to JITEventListener::NotifyFreeingMachineCode() since it can cause that to be called when the Function is partially destroyed. This change will be even more helpful later when I think we'll want to allow machine code to actually outlive its Function. llvm-svn: 85182
* Remove FreeInst.Victor Hernandez2009-10-262-9/+0
| | | | | | | Remove LowerAllocations pass. Update some more passes to treate free calls just like they were treating FreeInst. llvm-svn: 85176
* Move DataTypes.h to include/llvm/System, update all users. This breaks the lastChandler Carruth2009-10-262-2/+2
| | | | | | direct inclusion edge from System to Support. llvm-svn: 85086
* fix PR5186: the JIT shouldn't try to codegen available_externallyChris Lattner2009-10-251-1/+1
| | | | | | functions it should just look them up like declarations. llvm-svn: 85077
* Fix http://llvm.org/PR4822: allow module deletion after a function has beenJeffrey Yasskin2009-10-232-27/+63
| | | | | | | | | | | | | | compiled. When functions are compiled, they accumulate references in the JITResolver's stub maps. This patch removes those references when the functions are destroyed. It's illegal to destroy a Function when any thread may still try to call its machine code. This patch also updates r83987 to use ValueMap instead of explicit CallbackVHs and fixes a couple "do stuff inside assert()" bugs from r84522. llvm-svn: 84975
* Remove AllocationInst. Since MallocInst went away, AllocaInst is the only ↵Victor Hernandez2009-10-232-2/+2
| | | | | | subclass of AllocationInst, so it no longer is necessary. llvm-svn: 84969
* Random include cleanup.Benjamin Kramer2009-10-221-0/+1
| | | | llvm-svn: 84898
* Fix OProfileJITEventListener after r84054 renamed CompileUnit to Scope.Jeffrey Yasskin2009-10-221-6/+6
| | | | llvm-svn: 84895
* Verify that the function and exception table have been allocatedNicolas Geoffray2009-10-221-2/+2
| | | | | | before freeing them. llvm-svn: 84859
* De-bork CMake buildDouglas Gregor2009-10-211-1/+0
| | | | llvm-svn: 84744
* Delete the MacOSJITEventListener per echristo's request. It was disabled byJeffrey Yasskin2009-10-211-172/+0
| | | | | | default and didn't work anyway. llvm-svn: 84720
* Move the Function*->allocated blocks map from the JITMemoryManager to theJeffrey Yasskin2009-10-202-34/+30
| | | | | | | | | | | | | | | JITEmitter. I'm gradually making Functions auto-remove themselves from the JIT when they're destroyed. In this case, the Function needs to be removed from the JITEmitter, but the map recording which Functions need to be removed lived behind the JITMemoryManager interface, which made things difficult. This patch replaces the deallocateMemForFunction(Function*) method with a pair of methods deallocateFunctionBody(void *) and deallocateExceptionTable(void *) corresponding to the two startFoo/endFoo pairs. llvm-svn: 84651
* Clean up the JITResolver stub/callsite<->function maps.Jeffrey Yasskin2009-10-191-44/+100
| | | | | | | | | | | | | | | | | The JITResolver maps Functions to their canonical stubs and all callsites for lazily-compiled functions to their target Functions. To make Function destruction work, I'm going to need to remove all callsites on destruction, so this patch also adds the reverse mapping for that. There was an incorrect assumption in here that the only stub for a function would be the one caused by needing to lazily compile it, while x86-64 far calls and dlsym-stubs could also cause such stubs, but I didn't look for a test case that the assumption broke. This also adds DenseMapInfo<AssertingVH> so I can use DenseMaps instead of std::maps. llvm-svn: 84522
* s/DebugLoc.CompileUnit/DebugLoc.Scope/gDevang Patel2009-10-131-1/+1
| | | | | | s/DebugLoc.InlinedLoc/DebugLoc.InlinedAtLoc/g llvm-svn: 84054
* Keep track of stubs that are created. This fixes PR5162 and probably PR4822 andJeffrey Yasskin2009-10-132-11/+9
| | | | | | 4406. Patch by Nick Lewycky! llvm-svn: 84032
* Make the ExecutionEngine automatically remove global mappings on when theirJeffrey Yasskin2009-10-131-30/+47
| | | | | | | GlobalValue is destroyed. Function destruction still leaks machine code and can crash on leaked stubs, but this is some progress. llvm-svn: 83987
* ExecutionEngine::clearGlobalMappingsFromModule failed to remove reverseJeffrey Yasskin2009-10-091-16/+19
| | | | | | | mappings, which could cause errors and assert-failures. This patch fixes that, adds a test, and refactors the global-mapping-removal code into a single place. llvm-svn: 83678
* Introduce and use convenience methods for getting pointer typesDuncan Sands2009-10-061-1/+1
| | | | | | | where the element is of a basic builtin type. For example, to get an i8* use getInt8PtrTy. llvm-svn: 83379
* Update processDebugLoc() to handle requests to process debug info, before ↵Devang Patel2009-10-061-9/+11
| | | | | | and after emitting instructions. llvm-svn: 83364
* Fix http://llvm.org/PR5116 by rolling back r60822. This passes `make unittestsJeffrey Yasskin2009-10-061-1/+1
| | | | | | check-lit` on both x86-64 Linux and x86-32 Darwin. llvm-svn: 83353
* strength reduce a ton of type equality tests to check the typeid (ThroughChris Lattner2009-10-052-22/+20
| | | | | | | | the new predicates I added) instead of going through a context and doing a pointer comparison. Besides being cheaper, this allows a smart compiler to turn the if sequence into a switch. llvm-svn: 83297
* Fix compile error as debug interface changed.Nick Lewycky2009-09-301-6/+4
| | | | | | | By the way, this code is buggy. You can't keep a map<MDNode *, something> because the MDNode may be destroyed and reused for something else. llvm-svn: 83141
* Fix a struct/class mismatch.Benjamin Kramer2009-09-231-1/+1
| | | | llvm-svn: 82622
* errorstr can be null, don't unconditionally set it. Only report thatChris Lattner2009-09-231-6/+9
| | | | | | | | "the jit has not been linked in" if the interpreter failed. This fixes a unit test failure. llvm-svn: 82601
* Make EngineBuilder return more error codes, by KS Sreeram.Chris Lattner2009-09-231-13/+22
| | | | llvm-svn: 82600
* Use Compiler.h macro instead of __attribute__.Daniel Dunbar2009-09-221-1/+1
| | | | llvm-svn: 82532
* Update cmake.Xerxes Ranby2009-09-211-0/+1
| | | | llvm-svn: 82449
* Register the MachineModuleInfo for the ARM JIT, and update JITDwarfEmitter toDaniel Dunbar2009-09-211-1/+5
| | | | | | assert if the setModuleInfo hasn't been called. llvm-svn: 82441
* Implement the JIT side of the GDB JIT debugging interface. To enable thisReid Kleckner2009-09-207-17/+374
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Stop using alloca.Nick Lewycky2009-09-181-17/+14
| | | | llvm-svn: 82225
* Some platforms may need malloc.h for alloca.Daniel Dunbar2009-09-171-3/+6
| | | | llvm-svn: 82100
* remove a dead variable.Chris Lattner2009-09-162-3/+0
| | | | llvm-svn: 81985
* Fix PR4865. This syncs up the JIT's DWARF emitter with what's in theBill Wendling2009-09-091-20/+21
| | | | | | | 'DwarfException.cpp' file, which changed how CIEs were emitted, the sizes of some fields, etc. llvm-svn: 81295
* Improve JIT error message for users crazy enough to use -march with JIT, andDaniel Dunbar2009-09-081-2/+4
| | | | | | mention -version in messages about missing targets. llvm-svn: 81272
OpenPOWER on IntegriCloud