1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

847 Commits

Author SHA1 Message Date
Nick Lewycky
5c4f46c2e9 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
01c85bb37d 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
1f5c81d50f 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
b9bcbb730d 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
1a908fef1a 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
770f4158e5 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
17dddcd886 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
68e30cdf59 Change JIT for different layout of fp80.
llvm-svn: 67629
2009-03-24 17:35:45 +00:00
Evan Cheng
f9951d1557 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
04ae01ec54 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
5eccc173d1 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
5ab54d488f 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
24605efdaf 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
7e98d87d98 switch this message back to only being in -debug mode.
llvm-svn: 66143
2009-03-05 06:48:16 +00:00
Nate Begeman
ec80b49533 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
511a668cd1 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
db4a8af064 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
094f4d810f 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
e7a4098f7a 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
d4a9fb3478 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
5e78e558ff 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
93eebdfcc7 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
c264b63de6 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
9e3a296933 allow main to have any integer type.
llvm-svn: 63743
2009-02-04 17:48:18 +00:00
Nick Lewycky
a9c6af0bb8 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
d650c9ecd7 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
4de6ffb743 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
33f3303401 Revert r62553 and r62616 due to issues with portability.
llvm-svn: 62777
2009-01-22 20:09:20 +00:00
Chris Lattner
da545d3918 rename methods in System/Host to be more consistent.
llvm-svn: 62776
2009-01-22 19:53:00 +00:00
Chris Lattner
b4ffb1f824 add getPointerToGlobal to the C bindings, patch by Lennart Augustsson!
PR3364

llvm-svn: 62697
2009-01-21 18:11:10 +00:00
Duncan Sands
eb7ffc9654 Fix typo. Patch by Alexei Svitkine.
llvm-svn: 62616
2009-01-20 21:20:23 +00:00
Nick Lewycky
6ef90b1a25 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
0354d30311 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
2932869ed4 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
49be18cfc6 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
5000223556 Delete trailing whitespace.
llvm-svn: 62307
2009-01-16 06:53:46 +00:00
Rafael Espindola
0aba6c9435 Add the private linkage.
llvm-svn: 62279
2009-01-15 20:18:42 +00:00
Duncan Sands
bcdbfb63dc Rename getABITypeSize to getTypePaddedSize, as
suggested by Chris.

llvm-svn: 62099
2009-01-12 20:38:59 +00:00
Misha Brukman
71c7e40966 Removed trailing whitespace from Makefiles.
llvm-svn: 61991
2009-01-09 16:44:42 +00:00
Dan Gohman
8271066844 Tidy up #includes, deleting a bunch of unnecessary #includes.
llvm-svn: 61715
2009-01-05 17:59:02 +00:00
Evan Cheng
b3026de547 Fix misplaced right parentheses.
llvm-svn: 61699
2009-01-05 17:17:04 +00:00
Dan Gohman
6d6dd15fc3 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
caa31a82fc 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
1264f4bc9c 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
3130873f30 DisableGVCompilation should not abort on internal GlobalValue's.
llvm-svn: 60750
2008-12-09 07:31:49 +00:00
Chris Lattner
5c70ae0588 Make JIT::runFunction handle functions with non-C calling conventions.
llvm-svn: 59904
2008-11-23 08:00:11 +00:00
Nicolas Geoffray
3cd13e7e65 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
f8ba919d76 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
b6c760349e Change binary dump format.
llvm-svn: 59119
2008-11-12 08:22:43 +00:00
Evan Cheng
b9dbae83d7 Comments and indentation.
llvm-svn: 59007
2008-11-10 23:26:16 +00:00