Commit Graph

1005 Commits

Author SHA1 Message Date
Bruno Cardoso Lopes a194c3a69e First patch in the direction of splitting MachineCodeEmitter in two subclasses:
JITCodeEmitter and ObjectCodeEmitter. No functional changes yet. Patch by Aaron Gray

llvm-svn: 72631
2009-05-30 20:51:52 +00:00
Torok Edwin a602caf369 stat64/open64/lseek64 for the interpreter
llvm-svn: 72329
2009-05-23 16:23:59 +00:00
Argyrios Kyrtzidis c65c525617 Allow the JIT ExecutionEngine to report details about the generated machine 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
2009-05-18 21:06:40 +00:00
Duncan Sands af9eaa830a Rename PaddedSize to AllocSize, in the hope that this
will make it more obvious what it represents, and stop
it being confused with the StoreSize.

llvm-svn: 71349
2009-05-09 07:06:46 +00:00
Argyrios Kyrtzidis 30481e275c Set FnEnd in JITEmitter::finishFunction to point strictly to the end of function's machine code.
Don't include memory allocated for global variables during relocations resolution.

llvm-svn: 70517
2009-04-30 23:01:58 +00:00
Bill Wendling 352ee2cb05 Fix the JIT bindings for ocaml.
llvm-svn: 70454
2009-04-30 00:43:39 +00:00
Bill Wendling 026e5d7667 Instead of passing in an unsigned value for the optimization level, use an enum,
which better identifies what the optimization is doing. And is more flexible for
future uses.

llvm-svn: 70440
2009-04-29 23:29:43 +00:00
Bill Wendling 9f795134f3 The second part of the change from -fast to -O#. This changes the JIT to accept
an optimization level instead of a simple boolean telling it to generate code
"fast" or the other type of "fast".

llvm-svn: 70347
2009-04-29 00:32:19 +00:00
Nick Lewycky f44a5bf158 Under unusual circumstances (jitting a function that causes the creation of
another stub, but then never calling the jitted function) can cause the JIT to
leave a stub in place. Judging by the comments this is a known deficiency, so
we're just not going to use AssertingVH for the StubToFunctionTy map.

Also shorten some lines longer than 80 columns.

This fixes the "make check" failure with ocaml on x86-64 linux.

llvm-svn: 70185
2009-04-27 05:09:44 +00:00
Nick Lewycky 0575dbb692 Use an AssertingVH to detect the case where the Function was deleted but
freeMachineCodeForFunction was never called.

llvm-svn: 69531
2009-04-19 18:32:03 +00:00
Chris Lattner 11ceb38df0 make sure to unlock keymgr if the JIT is created and destroyed, all
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
2009-04-16 21:47:59 +00:00
Evan Cheng 3f1a3008f4 Mac OS X 10.6 and above do not use key manager to register EH frames.
llvm-svn: 69090
2009-04-14 22:31:59 +00:00
Nick Lewycky e54da991d1 Link against libffi if available, fall back to "no external calls from
interpreter mode" when it's not.

llvm-svn: 68937
2009-04-13 04:26:06 +00:00
Dan Gohman cff6953c45 Use CHAR_BIT instead of hard-coding 8 in several places where it
is appropriate. This helps visually differentiate host-oriented
calculations from target-oriented calculations.

llvm-svn: 68227
2009-04-01 18:45:54 +00:00
Dale Johannesen 4d7e4ee799 fix one more fp80 case (used only by Interpreter)
and streamline code here a bit.

llvm-svn: 67636
2009-03-24 18:16:17 +00:00
Dale Johannesen f259f3f312 Change JIT for different layout of fp80.
llvm-svn: 67629
2009-03-24 17:35:45 +00:00
Evan Cheng 1fb8aedd1e Fix some significant problems with constant pools that resulted in unnecessary paddings between constant pool entries, larger than necessary alignments (e.g. 8 byte alignment for .literal4 sections), and potentially other issues.
1. ConstantPoolSDNode alignment field is log2 value of the alignment requirement. This is not consistent with other SDNode variants.
2. MachineConstantPool alignment field is also a log2 value.
3. However, some places are creating ConstantPoolSDNode with alignment value rather than log2 values. This creates entries with artificially large alignments, e.g. 256 for SSE vector values.
4. Constant pool entry offsets are computed when they are created. However, asm printer group them by sections. That means the offsets are no longer valid. However, asm printer uses them to determine size of padding between entries.
5. Asm printer uses expensive data structure multimap to track constant pool entries by sections.
6. Asm printer iterate over SmallPtrSet when it's emitting constant pool entries. This is non-deterministic.


Solutions:
1. ConstantPoolSDNode alignment field is changed to keep non-log2 value.
2. MachineConstantPool alignment field is also changed to keep non-log2 value.
3. Functions that create ConstantPool nodes are passing in non-log2 alignments.
4. MachineConstantPoolEntry no longer keeps an offset field. It's replaced with an alignment field. Offsets are not computed when constant pool entries are created. They are computed on the fly in asm printer and JIT.
5. Asm printer uses cheaper data structure to group constant pool entries.
6. Asm printer compute entry offsets after grouping is done.
7. Change JIT code to compute entry offsets on the fly.

llvm-svn: 66875
2009-03-13 07:51:59 +00:00
Nate Begeman 664cf27602 Allow cross-process JIT to handle MachineRelocations of the ExternalSymbol
variety.  For example, an i64 div might turn into a call to __divdi3 during
legalization.

llvm-svn: 66646
2009-03-11 07:03:43 +00:00
Chris Lattner 26161cdc6c Fix PR3724 by searching for the largest free block when
allocating memory in the JIT.  This is insanely inefficient, but
hey, most people implement their own memory managers anyway.

Patch by Eric Yew!

llvm-svn: 66472
2009-03-09 21:34:10 +00:00
Duncan Sands 12da8ce3d2 Introduce new linkage types linkonce_odr, weak_odr, common_odr
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
2009-03-07 15:45:40 +00:00
Nate Begeman 52b696c7ad Finish cross-process JIT work, and clean up previous work.
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
2009-03-07 06:41:19 +00:00
Chris Lattner 0c33d436b3 switch this message back to only being in -debug mode.
llvm-svn: 66143
2009-03-05 06:48:16 +00:00
Nate Begeman 359df7420f When allocating stubs, keep track of which Functions are referencing the stub.
This invalidates the stubs in the resolver map when they are no longer referenced,
and should the JIT memory manager ever pick up a deallocateStub interface, the
JIT could reclaim the memory for unused stubs as well.

llvm-svn: 66141
2009-03-05 06:34:37 +00:00
Nate Begeman 920438ef1d Fix a thinko in the JIT where the address of a GV was only recorded in the map
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
2009-03-04 19:10:38 +00:00
Chris Lattner 7956bba545 don't #include a header into the middle of an anon namespace.
llvm-svn: 65967
2009-03-03 20:10:23 +00:00
Nate Begeman aa06843c56 Fix the calculation for how big the allocated stub needs to be.
llvm-svn: 65895
2009-03-02 23:10:14 +00:00
Dan Gohman c0ae249b22 Fix the logic in this assertion to properly validate the number
of arguments.

llvm-svn: 64999
2009-02-19 02:55:18 +00:00
Dan Gohman 6c109b4979 Reapply r57340. VMKit does not presently rely on materializeFunction
being called with the lock released, and this fixes a race condition
in the JIT as used by lli.

llvm-svn: 64997
2009-02-19 02:40:15 +00:00
Nate Begeman 18d85e7403 Add support to the JIT for true non-lazy operation. When a call to a function
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
2009-02-18 08:31:02 +00:00
Nicolas Geoffray 7f543ba9fa On 64bit we may have a personality function which requires 64 bits to
be encoded.

llvm-svn: 64600
2009-02-15 20:49:23 +00:00
Dan Gohman 21cb4114fb Split the locking out of JIT::runJITOnFunction so that callers
that already hold the lock can call an entry point that doesn't
re-acquire the lock.

llvm-svn: 63965
2009-02-06 21:25:08 +00:00
Chris Lattner 370ec10dad allow main to have any integer type.
llvm-svn: 63743
2009-02-04 17:48:18 +00:00
Nick Lewycky a89ec99fa2 Reapply patch from r62553, with a fix to avoid looking for an ffi.h that isn't
there.

This changes the interpreter to use libffi. After this patch, the interpreter
will barely be able to call any external functions if built on a system without
libffi installed (just enough to pass 'make check' really). But with libffi,
we can now call any function that isn't variadic or taking a struct or vector
parameter (but pointer to struct is fine). Patch by Alexei Svitkine!

llvm-svn: 63723
2009-02-04 06:26:47 +00:00
Evan Cheng 676130f2e1 Fix PR3423: Link llvm on ARM EABI machines. Patch by Robert Schuster.
llvm-svn: 63489
2009-02-01 06:42:27 +00:00
Nate Begeman 617001d842 Add support for deleting a module provider from a JIT in such a way that it does not cause the owned module to be fully materialized.
llvm-svn: 62864
2009-01-23 19:27:28 +00:00
Tanya Lattner 9a8602ce50 Revert r62553 and r62616 due to issues with portability.
llvm-svn: 62777
2009-01-22 20:09:20 +00:00
Chris Lattner aa1212271a rename methods in System/Host to be more consistent.
llvm-svn: 62776
2009-01-22 19:53:00 +00:00
Chris Lattner 41b43da217 add getPointerToGlobal to the C bindings, patch by Lennart Augustsson!
PR3364

llvm-svn: 62697
2009-01-21 18:11:10 +00:00
Duncan Sands 363501d09b Fix typo. Patch by Alexei Svitkine.
llvm-svn: 62616
2009-01-20 21:20:23 +00:00
Nick Lewycky 766ac10452 Make the Interpreter use libffi if it's available. Patch from Alexei Svitkine!
This requires a rebuild of 'configure' itself. I will be committing that next, but
built with the wrong version of autoconf. Somebody who has the right one, please update
it.

As a side-note, because of the way autoconf works, all built tools will link against
libffi, not just lli. If you know how to fix this, please let me know ...

llvm-svn: 62553
2009-01-20 00:51:40 +00:00
Chris Lattner 762edbc074 don't assert and die on out of range (undefined) shifts. This fixes
PR3334.

llvm-svn: 62352
2009-01-16 20:17:02 +00:00
Evan Cheng 5f936ef1ac Change isGVCompilationDisabled() semantics again. It should abort on any GV 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
2009-01-16 19:14:49 +00:00
Mikhail Glushenkov 6e8d814d36 Registry.h should not depend on CommandLine.h.
Split Support/Registry.h into two files so that we have less to
recompile every time CommandLine.h is changed.

llvm-svn: 62312
2009-01-16 07:02:28 +00:00
Mikhail Glushenkov b2f9a73029 Delete trailing whitespace.
llvm-svn: 62307
2009-01-16 06:53:46 +00:00
Rafael Espindola 6de96a1b5d Add the private linkage.
llvm-svn: 62279
2009-01-15 20:18:42 +00:00
Duncan Sands dc020f9c3c Rename getABITypeSize to getTypePaddedSize, as
suggested by Chris.

llvm-svn: 62099
2009-01-12 20:38:59 +00:00
Misha Brukman 5cbf223916 Removed trailing whitespace from Makefiles.
llvm-svn: 61991
2009-01-09 16:44:42 +00:00
Dan Gohman 906152a20f Tidy up #includes, deleting a bunch of unnecessary #includes.
llvm-svn: 61715
2009-01-05 17:59:02 +00:00
Evan Cheng 70b42590b0 Fix misplaced right parentheses.
llvm-svn: 61699
2009-01-05 17:17:04 +00:00
Dan Gohman d32ec016cc Handle weak_extern in the JIT. This fixes
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
2009-01-05 05:32:42 +00:00
Evan Cheng 0b77319742 Fix MachineCodeEmitter to use uintptr_t instead of intptr_t. This avoids some overflow issues. Patch by Thomas Jablin.
llvm-svn: 60828
2008-12-10 02:32:19 +00:00
Evan Cheng 15e0481d39 Fix a bug introduced by r59265. If lazy compilation is disabled, return actual function ptr instead of ptr to stub if function is already compiled.
llvm-svn: 60822
2008-12-10 01:33:59 +00:00
Evan Cheng 75900bf5cd DisableGVCompilation should not abort on internal GlobalValue's.
llvm-svn: 60750
2008-12-09 07:31:49 +00:00
Chris Lattner ddd7581c73 Make JIT::runFunction handle functions with non-C calling conventions.
llvm-svn: 59904
2008-11-23 08:00:11 +00:00
Nicolas Geoffray 7aa444c031 Implement support for JIT exceptions on X86_64. Relative offsets are
encoded on 32 bytes, and the personality function is not encoded as
relative.

llvm-svn: 59516
2008-11-18 10:44:46 +00:00
Evan Cheng bf9a055c98 Always emit a function pointer as a pointer to the function stub (if there is one). This makes it possible to compare function pointer values in lazy compilation mode. This fixes PR3043.
llvm-svn: 59265
2008-11-13 21:50:50 +00:00
Evan Cheng e4df875dd6 Change binary dump format.
llvm-svn: 59119
2008-11-12 08:22:43 +00:00
Evan Cheng b172c66af3 Comments and indentation.
llvm-svn: 59007
2008-11-10 23:26:16 +00:00
Evan Cheng 0d9db40994 Forgot these.
llvm-svn: 58952
2008-11-10 01:52:24 +00:00
Evan Cheng 686a725b45 Remove a InvalidateInstructionCache call with incorrect size.
llvm-svn: 58898
2008-11-08 08:15:39 +00:00
Evan Cheng b31a717527 Rename startFunctionStub to startGVStub since it's also used for GV non-lazy ptr.
llvm-svn: 58897
2008-11-08 08:02:53 +00:00
Evan Cheng 1b889b16da Rename isString -> isExternalSymbol; getString -> getExternalSymbol since these work on externsym machine relocations.
llvm-svn: 58895
2008-11-08 07:37:34 +00:00
Evan Cheng 776f5922fb More debug output.
llvm-svn: 58894
2008-11-08 07:22:53 +00:00
Evan Cheng 077f686d4b More debug output.
llvm-svn: 58868
2008-11-07 22:30:29 +00:00
Evan Cheng 00203155ad Jump tables may be emitted by target.
llvm-svn: 58835
2008-11-07 09:02:17 +00:00
Evan Cheng 972fd1a1e0 Improve JIT debugging outputs format consistency.
llvm-svn: 58807
2008-11-06 17:46:04 +00:00
Evan Cheng 3aeeb3a47c Need a \n.
llvm-svn: 58788
2008-11-06 01:18:29 +00:00
Evan Cheng d1c5c7f499 Undo 58778 but makes the binary dump prettier.
llvm-svn: 58782
2008-11-05 23:44:08 +00:00
Evan Cheng 51b9b9f6e2 Remove debug output that's not really useful.
llvm-svn: 58778
2008-11-05 23:21:11 +00:00
Evan Cheng 132de1983f Rename isGVLazyPtr to isGVNonLazyPtr relocation. This represents Mac OS X
indirect gv reference. Please don't call it lazy.

llvm-svn: 58746
2008-11-05 01:50:32 +00:00
Evan Cheng 33ba5e78d2 Debugging output tweak.
llvm-svn: 58737
2008-11-05 00:22:28 +00:00
Evan Cheng 9340be4641 For some targets, it's not possible to place GVs in the same memory buffer 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
2008-11-04 09:30:48 +00:00
Evan Cheng 09053e62a9 80 col violation.
llvm-svn: 58684
2008-11-04 06:10:31 +00:00
Evan Cheng 3a9aead4d4 Silence a compiler warning.
llvm-svn: 58598
2008-11-03 07:14:02 +00:00
Jim Grosbach 2589604d85 Revert errant deletion. The target needs to be able to specify that it doesn't want the generic constant pool to be emitted.
llvm-svn: 58475
2008-10-30 23:44:39 +00:00
Evan Cheng 4421a114bb Let target resolve some relocation results.
llvm-svn: 58407
2008-10-29 23:54:46 +00:00
Jim Grosbach ff2b4948ce Support for constant islands in the ARM JIT.
Since the ARM constant pool handling supercedes the standard LLVM constant
pool entirely, the JIT emitter does not allocate space for the constants,
nor initialize the memory. The constant pool is considered part of the 
instruction stream.

Likewise, when resolving relocations into the constant pool, a hook into
the target back end is used to resolve from the constant ID# to the
address where the constant is stored.

For now, the support in the ARM emitter is limited to 32-bit integer. Future
patches will expand this to the full range of constants necessary.

llvm-svn: 58338
2008-10-28 18:25:49 +00:00
Nicolas Geoffray 5457ce9ac3 Support for allocation of TLS variables in the JIT. Allocation of a global
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
2008-10-25 15:41:43 +00:00
Oscar Fuentes f3c03b02dc CMake: Turned some libraries into partially linked objects. Corrected
names of LLVMCore and ARMCodeGen.

llvm-svn: 57943
2008-10-22 02:51:53 +00:00
Nuno Lopes 94844e2054 fix a tricky bug in the JIT global variable emitter, that was triggered when JITing a variable independently of a function. This lead to sharing memory memory between functions and GVs thus changing the value of a GV could change the code in execution. more details on the ML.
llvm-svn: 57900
2008-10-21 11:42:16 +00:00
Nuno Lopes a67f06b9c7 little optimization: reuse getPointerToGlobalIfAvailable(CGV) value in emitGlobals()
llvm-svn: 57484
2008-10-14 10:04:52 +00:00
Mon P Wang 297364cd3b Revert r57340 move guard mutex in getPointerToFunction as this can cause
deadlock issues with java

llvm-svn: 57356
2008-10-10 18:07:10 +00:00
Mon P Wang 6e5eccf86b Moved guard mutex upwards to guard materializing a function
in getPointerToFunction

llvm-svn: 57340
2008-10-10 01:47:42 +00:00
Dale Johannesen 4f0bd68cfe Add a "loses information" return value to APFloat::convert
and APFloat::convertToInteger.  Restore return value to
IEEE754.  Adjust all users accordingly.

llvm-svn: 57329
2008-10-09 23:00:39 +00:00
Dale Johannesen 54306fe499 Rename APFloat::convertToAPInt to bitcastToAPInt to
make it clearer what the function does.  No functional
change.

llvm-svn: 57325
2008-10-09 18:53:47 +00:00
Duncan Sands 26ff6f9c54 Add <cstdio> include where needed by gcc-4.4.
Patch by Samuel Tardieu.

llvm-svn: 57291
2008-10-08 07:23:46 +00:00
Daniel Dunbar a8c424bf61 Unbreak build.
llvm-svn: 57017
2008-10-03 17:11:57 +00:00
Jim Grosbach b22ef71d46 On Darwin ARM, memory needs special handling to do JIT. This patch expands
this handling to work properly for modifying stub functions, relocations
back to entry points after JIT compilation, etc..

llvm-svn: 57013
2008-10-03 16:17:20 +00:00
Dan Gohman 0d1e9a8e04 Switch the MachineOperand accessors back to the short names like
isReg, etc., from isRegister, etc.

llvm-svn: 57006
2008-10-03 15:45:36 +00:00
Nicolas Geoffray 74056ae3d5 Acquire the lock only when necessary. More precisely, do not acquire
the lock when calling a method which may materialize the llvm::Function.

llvm-svn: 56995
2008-10-03 07:27:08 +00:00
Evan Cheng 1a9a0b7b4e Add runStaticConstructorsDestructors which runs ctors / dtors of a single module. Patch by David Chisnall.
llvm-svn: 56849
2008-09-30 15:51:21 +00:00
Devang Patel 4c758ea3e0 Large mechanical patch.
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage 
- to implement function notes as function attributes and 
- to distinguish between function attributes and return value attributes.

This requires corresponding changes in llvm-gcc and clang.

llvm-svn: 56622
2008-09-25 21:00:45 +00:00
Evan Cheng cdc0060e27 Add DisableGVCompilation which forces the JIT to assert when it tries to allocate space for a GlobalVariable.
llvm-svn: 56557
2008-09-24 16:25:55 +00:00
Devang Patel ba3fa6c6e1 s/ParameterAttributes/Attributes/g
llvm-svn: 56513
2008-09-23 23:03:40 +00:00
Oscar Fuentes a229b3c9a7 Initial support for the CMake build system.
llvm-svn: 56419
2008-09-22 01:08:49 +00:00
Evan Cheng 5cc53c34c3 Preliminary support for systems which require changing JIT memory regions privilege from read / write to read / executable.
llvm-svn: 56303
2008-09-18 07:54:21 +00:00
Anton Korobeynikov 1a1140429e Make safer variant of alias resolution routine to be default
llvm-svn: 56005
2008-09-09 20:05:04 +00:00
Evan Cheng 52b181206f MMI may be null.
llvm-svn: 55626
2008-09-02 08:14:01 +00:00
Nicolas Geoffray b011a8f611 Add support for JIT exceptions on Darwin. Since we're dealing with libgcc,
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
2008-08-28 22:34:49 +00:00
Dan Gohman cf3e3017c8 Avoid a warning about isTargetNullPtr being unused in release builds.
llvm-svn: 55350
2008-08-26 01:38:29 +00:00
Evan Cheng d5834e90dc Get rid of a couple of dynamic_cast.
llvm-svn: 55022
2008-08-20 00:28:12 +00:00
Nicolas Geoffray d58c8e759f Update the JIT exception writer to better mimic the codegen exception writer.
Also skip indirect encoding for platforms that ask for one: we direclty
write an address, not a pointer to the address.

llvm-svn: 54987
2008-08-19 14:48:14 +00:00
Nicolas Geoffray ba694a32dc Register the frame register function when allocating the JIT,
so that lli works out of the box with -enable-eh.

llvm-svn: 54920
2008-08-18 14:53:56 +00:00
Anton Korobeynikov bd890b1faf Move SLEB/ULEB size calculation routines from AsmPrinter to TargetAsmInfo. This makes JIT asmprinter-free.
llvm-svn: 54843
2008-08-16 12:57:46 +00:00
Dale Johannesen dafdbf77b3 Some fixes for x86-64 JIT. Make it use small code
model, except for external calls; this makes
addressing modes PC-relative.  Incomplete.

The assertion at the top of Emitter::runOnMachineFunction
was obviously bogus (always true) so I removed it.
If someone knows what the correct test should be to cover
all the various targets, please fix.

llvm-svn: 54656
2008-08-11 23:46:25 +00:00
Gordon Henriksen 5225cd66cf Fix the LLVMCreateJITCompiler C binding.
Evan broke it in r54523 by adding a parameter in the implementation without
updating the header correspondingly.

llvm-svn: 54555
2008-08-08 20:49:28 +00:00
Evan Cheng 7ff05bf541 Add new parameter Fast to createJIT to enable the fast codegen path.
llvm-svn: 54523
2008-08-08 08:11:34 +00:00
Dale Johannesen b086d3820d Rewrite JIT handling of GlobalVariables so they
are allocated in the same buffer as the code,
jump tables, etc.

The default JIT memory manager does not handle buffer
overflow well.  I didn't introduce this and I'm not
attempting to fix it here, but it is more likely to
be hit now since we're putting more stuff in the
buffer.  This affects one test that I know of so far,
MultiSource/Benchmarks/NPB-serial/is.

llvm-svn: 54442
2008-08-07 01:30:15 +00:00
Dan Gohman ced4857365 Use strcpy instead of sprintf here. This avoids a GCC 4.3 format-string
warning. There wasn't actually a problem here, because the contents of
the string are known.

llvm-svn: 54385
2008-08-05 23:36:35 +00:00
Dan Gohman 3da016d137 Trim #includes.
llvm-svn: 54350
2008-08-05 15:32:23 +00:00
Evan Cheng bf83579b30 Fix for PR2578. Do not split off a block whose size is less than FreeRangeHeader::getMinBlockSize(). Patch by Damien.
llvm-svn: 54152
2008-07-29 07:38:32 +00:00
Chris Lattner 2528d63ba7 Add a new hidden option to the interpreter to cause it to print
out every volatile load and store.  This is useful for tracking 
down insane volatile memory bugs.

llvm-svn: 53241
2008-07-08 17:25:49 +00:00
Dan Gohman e916fd5b96 Use empty() instead of size().
llvm-svn: 53178
2008-07-07 17:52:43 +00:00
Dan Gohman 4c6db53a36 Correct a comment.
llvm-svn: 53064
2008-07-03 00:51:05 +00:00
Dan Gohman e61e120c17 Prune a few dependencies on MachineFunction.h.
llvm-svn: 52976
2008-07-01 18:15:35 +00:00
Dan Gohman fb19f9402b Split ISD::LABEL into ISD::DBG_LABEL and ISD::EH_LABEL, eliminating
the need for a flavor operand, and add a new SDNode subclass,
LabelSDNode, for use with them to eliminate the need for a label id
operand.

Change instruction selection to let these label nodes through
unmodified instead of creating copies of them. Teach the MachineInstr
emitter how to emit a MachineInstr directly from an ISD label node.

This avoids the need for allocating SDNodes for the label id and
flavor value, as well as SDNodes for each of the post-isel label,
label id, and label flavor.

llvm-svn: 52943
2008-07-01 00:05:16 +00:00
Chris Lattner 58ecfbdad6 Implement JIT support for global aliases, patch by David Chisnall!
llvm-svn: 52738
2008-06-25 20:21:35 +00:00
Chris Lattner d3406fc2a7 Switch the PPC backend and target-independent JIT to use the libsystem
InvalidateInstructionCache method instead of calling through
a hook on the JIT.  This is a host feature, not a target feature.

llvm-svn: 52734
2008-06-25 17:18:44 +00:00
Dan Gohman 1ac5813726 Use back() instead of [size()-1].
llvm-svn: 52600
2008-06-21 22:00:54 +00:00
Dan Gohman 1cf5af9e42 Use static_cast instead of reinterpret_cast for casting void*.
llvm-svn: 52592
2008-06-21 20:17:03 +00:00
Gordon Henriksen 9f337549a7 Add C binding for ExecutionEngine::addGlobalMapping.
llvm-svn: 52523
2008-06-20 02:16:11 +00:00
Anton Korobeynikov 7d7dcd52db Provide generic hooks for icache invalidation. Add PPC implementation.
Patch by Gary Benson!

llvm-svn: 52418
2008-06-17 17:30:05 +00:00
Evan Cheng 84a9055e27 Don't forget to initialize SymbolSearchingDisabled.
llvm-svn: 52414
2008-06-17 16:49:02 +00:00
Chris Lattner 86d4f3a2a9 Add a new flag that disables symbol lookup with dlsym when set. This allows
a JIT client to completely control symbol lookup with the LazyFunctionCreator
interface.

llvm-svn: 52335
2008-06-16 17:44:14 +00:00
Dan Gohman 643b3a0581 Add #includes to make some dependencies explicit.
llvm-svn: 51496
2008-05-23 20:40:06 +00:00
Nate Begeman 8f83fc4d9b Fix a couple issues with the JIT and multiple modules:
1. The "JITState" object creates a PassManager with the ModuleProvider that the
   jit is created with.  If the ModuleProvider is removed and deleted, the
   PassManager is invalid.

2. The Global maps in the JIT were not invalidated with a ModuleProvider was 
   removed.  This could lead to a case where the Module would be freed, and a 
   new Module with Globals at the same addresses could return invalid results.

llvm-svn: 51384
2008-05-21 16:34:48 +00:00
Dan Gohman 69ddfbfe9e Fix ExecutionEngine's constant code to work properly when structs and arrays
will become first-class types.

llvm-svn: 51293
2008-05-20 03:20:09 +00:00
Nate Begeman 7af15f17b5 Fix a backwards check in the JIT symbol table code
llvm-svn: 51229
2008-05-18 19:09:10 +00:00
Evan Cheng d37a6cf669 Disable JIT symbol table for now.
llvm-svn: 51152
2008-05-15 17:31:35 +00:00
Gabor Greif 697e94cc22 Fix a bunch of 80col violations that arose from the Create API change. Tweak makefile targets to find these better.
llvm-svn: 51143
2008-05-15 10:04:30 +00:00
Dale Johannesen ce4396bc92 Add CommonLinkage; currently tentative definitions
are represented as "weak", but there are subtle differences
in some cases on Darwin, so we need both.  The intent
is that "common" will behave identically to "weak" unless
somebody changes their target to do something else.
No functional change as yet.

llvm-svn: 51118
2008-05-14 20:12:51 +00:00
Dan Gohman d78c400b5b Clean up the use of static and anonymous namespaces. This turned up
several things that were neither in an anonymous namespace nor static
but not intended to be global.

llvm-svn: 51017
2008-05-13 00:00:25 +00:00
Gordon Henriksen 7993f4a6d1 PR2202: LLVMCreateInterpreter creates a JIT
Applying fix by Frits van Bommel.

llvm-svn: 50249
2008-04-25 02:52:30 +00:00
Nicolas Geoffray 481f44e12f Be pessimistic in computing the buffer size when aligning.
llvm-svn: 50008
2008-04-20 23:39:44 +00:00
Nicolas Geoffray f77618e6e8 Cosmetic changes, as suggested by Evan. No functionality changes.
llvm-svn: 49993
2008-04-20 17:44:19 +00:00
Nicolas Geoffray 568f9818f7 Do not hold the JIT lock when materializing a function and verify if the
function has already been codegen'd. This is required by the Java class loading
mechanism which executes Java code when materializing a function.

llvm-svn: 49988
2008-04-20 08:33:02 +00:00
Chris Lattner 3b18762f40 Switch to using Simplified ConstantFP::get API.
llvm-svn: 49977
2008-04-20 00:41:09 +00:00
Nicolas Geoffray 85a9f1911e Enable jitting with a known memory size.
llvm-svn: 49924
2008-04-18 20:59:31 +00:00
Nicolas Geoffray a7557dfe71 Correlate stubs with functions in JIT: when emitting a stub, the JIT tells the memory manager which function
the stub will resolve.

llvm-svn: 49814
2008-04-16 20:46:05 +00:00
Chris Lattner 4d232bccca Fix some serious logic errors that broke the jit on darwin/x86-64.
llvm-svn: 49606
2008-04-13 07:04:56 +00:00
Evan Cheng 213ea6b276 Add debugging code.
llvm-svn: 49566
2008-04-12 00:22:01 +00:00
Chris Lattner ad281e8e19 Reenable JIT symbol table.
llvm-svn: 49548
2008-04-11 18:11:56 +00:00
Chris Lattner 982e8502c9 fix warnings with assertions disabled.
llvm-svn: 49285
2008-04-06 21:50:58 +00:00
Gabor Greif e9ecc68d8f API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.

llvm-svn: 49277
2008-04-06 20:25:17 +00:00
Chris Lattner 8519c0ead8 disable this for now.
llvm-svn: 49248
2008-04-05 04:12:01 +00:00
Chris Lattner 318d3ef88e Provide an initial cut at exposing JIT compiled symbols to performance
tools.  This is currently only enabled on the mac, but could easily be
supported by other hosts that are interested.

llvm-svn: 49207
2008-04-04 05:51:42 +00:00
Chris Lattner ee1817300a Make ExecutionEngine::updateGlobalMapping return the old mapping.
llvm-svn: 49206
2008-04-04 04:47:41 +00:00
Chris Lattner 0f760dfe09 Fix "Control reaches the end of non-void function" warnings,
patch by David Chisnall.

llvm-svn: 48963
2008-03-30 18:22:13 +00:00
Erick Tryzelaar 8ac07c2834 Expose ExecutionEngine::getTargetData() to c and ocaml bindings.
llvm-svn: 48851
2008-03-27 00:27:14 +00:00
Dan Gohman c60c67fc37 Add explicit keywords.
llvm-svn: 48801
2008-03-25 22:06:05 +00:00
Anton Korobeynikov 7ebdd255b5 Register EH frames emitted in JIT when using gcc unwinding runtime
llvm-svn: 48688
2008-03-22 08:53:09 +00:00
Duncan Sands cd4a6bed89 Fix formatting.
llvm-svn: 48151
2008-03-10 16:38:37 +00:00
Nick Lewycky a53414fd79 Load the symbols first so that the interpreter constructor can find them when
it tries to initialize them.

llvm-svn: 48046
2008-03-08 02:49:45 +00:00
Chris Lattner c1969de3e9 fix 80 col violations
llvm-svn: 48019
2008-03-07 20:05:43 +00:00
Dan Gohman ca24fd9096 Simplify code using convertFromZeroExtendedInteger with an APInt
by using the new convertFromAPInt directly.

llvm-svn: 47739
2008-02-29 01:27:13 +00:00
Anton Korobeynikov 035eaacd1f Update gcc 4.3 warnings fix patch with recent head changes
llvm-svn: 47368
2008-02-20 11:10:28 +00:00
Anton Korobeynikov 579f07135a Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
llvm-svn: 47367
2008-02-20 11:08:44 +00:00
Evan Cheng ab5729cfe6 Added memmove to interpreter external functions list. Patch by Daniel Dunbar.
llvm-svn: 47363
2008-02-20 07:55:26 +00:00
Chris Lattner 1dd86b1154 Support vector constant zeros, thanks to Zack Rusin for the testcase.
llvm-svn: 47148
2008-02-15 00:57:28 +00:00
Nicolas Geoffray 21ad494f67 Enable exception handling int JIT
llvm-svn: 47079
2008-02-13 18:39:37 +00:00
Dan Gohman 70de4cb1cd Use empty() instead of comparing size() with zero.
llvm-svn: 46514
2008-01-29 13:02:09 +00:00
Duncan Sands 05837edae7 Use getPreferredAlignmentLog or getPreferredAlignment
to get the alignment of global variables, rather than
using hand-made versions.

llvm-svn: 46495
2008-01-29 06:23:44 +00:00
Chris Lattner 919ad97c01 JITEmitter.cpp was trying to sync the icache for function stubs, but
was actually passing a completely incorrect size to sys_icache_invalidate.
Instead of having the JITEmitter do this (which doesn't have the correct 
size), just make the target sync its own stubs.

llvm-svn: 46354
2008-01-25 16:41:09 +00:00
Duncan Sands c50c210d76 I doubt the address of the Error string was intended
to be used for the force_interpreter parameter...
Spotted by gcc-4.2.

llvm-svn: 45714
2008-01-07 19:14:42 +00:00
Evan Cheng 880b080887 X86 JIT PIC jumptable support.
llvm-svn: 45616
2008-01-05 02:26:58 +00:00
Evan Cheng 49ff8ecd03 X86 PIC JIT support fixes: encoding bugs, add lazy pointer stubs support.
llvm-svn: 45575
2008-01-04 10:46:51 +00:00
Chris Lattner 84cea329d5 Remove symbols that don't exist, remove tabs, fix comment typo
llvm-svn: 45553
2008-01-03 22:15:32 +00:00
Chris Lattner 705dc51f2c Fix PR1873, a problem finding stat-related symbols on linux, due to
"libc_nonshared.a". Patch by Edwin Török!

llvm-svn: 45532
2008-01-03 07:10:51 +00:00
Evan Cheng 563fcc3428 Change MachineRelocation::DoesntNeedFnStub to NeedStub. This fields will be used
for non-function GV relocations that require function address stubs (e.g. Mac OS X in non-static mode).

llvm-svn: 45527
2008-01-03 02:56:28 +00:00
Chris Lattner f3ebc3f3d2 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Chris Lattner a087a8d2ce remove attribution from lib Makefiles.
llvm-svn: 45415
2007-12-29 20:09:26 +00:00
Gordon Henriksen 2a8cd89d03 C and Ocaml bindings for ExecutionEngine (i.e., the JIT compiler).
llvm-svn: 45335
2007-12-23 16:59:28 +00:00
Christopher Lamb edf0788758 Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
llvm-svn: 45082
2007-12-17 01:12:55 +00:00
Duncan Sands 26d6539e70 These are more correctly called signaling NaNs.
llvm-svn: 45059
2007-12-15 17:37:40 +00:00
Duncan Sands 1202d1b1c4 Teach the interpreter to read and write memory in the
endianness of the target not of the host.  Done by the
simple expedient of reversing bytes for primitive types
if the host and target endianness don't match.  This is
correct for integer and pointer types.  I don't know if
it is correct for floating point types.

llvm-svn: 45039
2007-12-14 19:38:31 +00:00
Dan Gohman 8a332b235d Add explicit keywords, and fix a minor typo that they uncovered.
llvm-svn: 45034
2007-12-14 15:41:34 +00:00
Duncan Sands fde556745b Remove host endianness info from TargetData and
put it in a new header System/Host.h instead.
Instead of getting the endianness from configure,
calculate it directly.

llvm-svn: 44959
2007-12-12 23:03:45 +00:00
Zhou Sheng 3115ba39e8 Add a guard to cxxabi header as other platform may
not support it.

llvm-svn: 44914
2007-12-12 06:16:47 +00:00
Zhou Sheng ed5d693d67 Fixed PR1629.
Make lli interpreter correctly call external functions sin()/cos(),
__cxa_guard_acquire() and __cxa_guard_release().

llvm-svn: 44910
2007-12-12 04:55:43 +00:00
Duncan Sands 5c65cb4633 Fix PR1836: in the interpreter, read and write apints
using the minimum possible number of bytes.  For little
endian targets run on little endian machines, apints are
stored in memory from LSB to MSB as before.  For big endian
targets on big endian machines they are stored from MSB to
LSB which wasn't always the case before (if the target and
host endianness doesn't match values are stored according
to the host's endianness).  Doing this requires knowing the
endianness of the host, which is determined when configuring -
thanks go to Anton for this.  Only having access to little
endian machines I was unable to properly test the big endian
part, which is also the most complicated...

llvm-svn: 44796
2007-12-10 17:43:13 +00:00
Duncan Sands 81b25817f9 It looks like this has been broken for some time -
get it to compile.

llvm-svn: 44791
2007-12-10 14:43:10 +00:00
Chuck Rose III cc2a661322 Adjust VStudio files to add JITMemoryManager files + include <cassert> from same.
llvm-svn: 44651
2007-12-06 02:03:01 +00:00
Chris Lattner 7f3587e344 add a new ExecutionEngine::createJIT which can be used if you only want
to create a JIT.  This lets you specify JIT-specific configuration items
like the JITMemoryManager to use.

llvm-svn: 44647
2007-12-06 01:34:04 +00:00
Chris Lattner dc351b94f9 simplify creation of the interpreter, make ExecutionEngine ctor protected,
delete one ExecutionEngine ctor, minor cleanup.

llvm-svn: 44646
2007-12-06 01:08:09 +00:00
Chris Lattner 55d8c3f71b split the JIT memory management code out from the main JIT logic into its
own JITMemoryManager interface.  There is no functionality change with 
this patch.

llvm-svn: 44640
2007-12-05 23:39:57 +00:00
Chris Lattner 749478a61b for consistency, allow a fallthrough if the final check returns null.
llvm-svn: 44406
2007-11-28 18:30:18 +00:00
Duncan Sands 5208d1ab4a Add some convenience methods for querying attributes, and
use them.

llvm-svn: 44403
2007-11-28 17:07:01 +00:00
Duncan Sands ff306287ff My compiler complains that "x always evaluates to true"
in this call:

	Result.IntVal = APInt(80, 2, x);

What is x?

	uint16_t x[8];

I deduce that the APInt constructor being used is this one:

  APInt(uint32_t numBits, uint64_t val, bool isSigned = false);

rather than this one:

  APInt(uint32_t numBits, uint32_t numWords, const uint64_t bigVal[]);

That doesn't seem right!  This fix compiles but is otherwise completely
untested.

llvm-svn: 44400
2007-11-28 10:36:19 +00:00
Chris Lattner be5f3cb6f1 Make this actually work on systems that support ppc long double.
llvm-svn: 44374
2007-11-27 20:45:25 +00:00
Chris Lattner fffd0ae2f1 Unbreak all of the darwin/ppc32 JIT failures having to do
with not being able to find printf.

llvm-svn: 44373
2007-11-27 20:41:32 +00:00
Duncan Sands 44b8721de8 Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment.  This gives a primitive type for
which getTypeSize differed from getABITypeSize.  For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).

This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition).  Instead there is:

(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type.  For a primitive type, this is the minimum number
of bits.  For an i36 this is 36 bits.  For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.

(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it).  For an
i36 this is 40 bits, for an x86 long double it is 80 bits.  This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes).  There doesn't seem to be anything
corresponding to this in gcc.

(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment.  For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS.  This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes).  This is
TYPE_SIZE in gcc.

Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize.  This means that the size of an array
is the length times the getABITypeSize.  It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize.  Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case.  So alloca's and mallocs should use getABITypeSize.  Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.

Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.

In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases).  I will get around to auditing these too at some point,
but I could do with some help.

Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize.  I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers.  If someone wants to pack these types more
tightly they can always use a packed struct.

llvm-svn: 43620
2007-11-01 20:53:16 +00:00
Chris Lattner fd6f3257b8 add a mechanism for the JIT to invoke a function to lazily create functions as they are referenced.
llvm-svn: 43210
2007-10-22 02:50:12 +00:00
Chris Lattner bf5e958ba0 llvm-gcc3 is dead, along with it __main.
llvm-svn: 43209
2007-10-22 02:39:47 +00:00
Chris Lattner edaf0b4651 LoadLibraryPermanently doesn't throw.
llvm-svn: 43207
2007-10-21 22:58:11 +00:00
Chris Lattner b5163bb9f0 Add a convenience method for creating EE's.
llvm-svn: 43206
2007-10-21 22:57:11 +00:00
Gordon Henriksen ef5d08f4ea Switching TargetMachineRegistry to use the new generic Registry.
llvm-svn: 43094
2007-10-17 21:28:48 +00:00
Devang Patel 324fe8904f Add removeModuleProvider()
llvm-svn: 43002
2007-10-15 19:56:32 +00:00
Gabor Greif cb6832efe0 Fix an assertion abort on sparc. malloc(0) is allowed to
return NULL.

llvm-svn: 42871
2007-10-11 19:40:35 +00:00
Neil Booth 5f00973393 convertFromInteger, as originally written, expected sign-extended
input.  APInt unfortunately zero-extends signed integers, so Dale
modified the function to expect zero-extended input.  Make this
assumption explicit in the function name.

llvm-svn: 42732
2007-10-07 11:45:55 +00:00
Dale Johannesen 9150652b21 Constant fold int-to-long-double conversions;
use APFloat for int-to-float/double; use
round-to-nearest for these (implementation-defined,
seems to match gcc).

llvm-svn: 42484
2007-09-30 18:19:03 +00:00