Commit Graph

1132 Commits

Author SHA1 Message Date
Dylan Noblesmith
226c34be0d ExecutionEngine: delete duplicated files
Forgot to `svn rm` these in revisions 131025 / 131029.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131030 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 22:24:04 +00:00
Dylan Noblesmith
e6297010a6 ExecutionEngine: add missing file
From revision 131025.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131029 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 22:20:09 +00:00
Dylan Noblesmith
bfb8705d97 ExecutionEngine: move createJIT() definition
As an ExecutionEngine class function, its definition
really belongs in ExecutionEngine.cpp, not JIT.cpp.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131027 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 22:07:14 +00:00
Dylan Noblesmith
c06b511eba ExecutionEngine: push TargetMachine creation into clients
In particular, into EngineBuilder. This should only impact
the private API between the EE and EB classes, not external
clients, since JITCtor and MCJITCtor are both protected members.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131026 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 22:06:22 +00:00
Dylan Noblesmith
71cbac6a83 ExecutionEngine: fix JIT/MCJIT selectTarget() duplication
This prepares for making JITCtor/MCJITCtor take a
TargetMachine* directly from clients like EngineBuilder.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131025 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 22:05:43 +00:00
Douglas Gregor
c003229ddc Fix a C++0x portability issue with std::make_pair. Explicitly providing template arguments no longer works when the call arguments are lvalues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130513 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-29 16:57:12 +00:00
Chandler Carruth
80d9e07262 Fix the last -Wnon-pod-memset I'm seeing. This is benign, but appears
a bit more sinister as the memset doesn't do what the constructor does.
There seems to be a cleaner solution than a cast here though, instead we
can point the memset destination into the union its actually trying to
clear.

An alternative is to point to the Untyped member of this union. Review
appreciated, and if that is cleaner I'm happy to switch. All of these
should be functionally equivalent to the original code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130395 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-28 08:37:18 +00:00
Jay Foad
ddcdcc8863 Remove unused STL header includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130068 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-23 19:53:52 +00:00
Eric Christopher
bb498ca5c2 80-col fix.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129973 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-22 03:07:06 +00:00
Chris Lattner
7a2bdde0a0 Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129558 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-15 05:18:47 +00:00
Jim Grosbach
69e813282d MCJIT relocation resolution.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129445 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-13 15:28:10 +00:00
Jay Foad
5b24017ca8 Like the coding standards say, do not use "using namespace std".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129435 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-13 12:46:01 +00:00
Jim Grosbach
f8c1c8465f MCJIT lazy relocation resolution and symbol address re-assignment.
Add handling for tracking the relocations on symbols and resolving them.
Keep track of the relocations even after they are resolved so that if
the RuntimeDyld client moves the object, it can update the address and any
relocations to that object will be updated.

For our trival object file load/run test harness (llvm-rtdyld), this enables
relocations between functions located in the same object module. It should
be trivially extendable to load multiple objects with mutual references.

As a simple example, the following now works (running on x86_64 Darwin 10.6):


$ cat t.c
int bar() {
  return 65;
}

int main() {
  return bar();
}
$ clang t.c -fno-asynchronous-unwind-tables -o t.o -c
$ otool -vt t.o
t.o:
(__TEXT,__text) section
_bar:
0000000000000000  pushq %rbp
0000000000000001  movq  %rsp,%rbp
0000000000000004  movl  $0x00000041,%eax
0000000000000009  popq  %rbp
000000000000000a  ret
000000000000000b  nopl  0x00(%rax,%rax)
_main:
0000000000000010  pushq %rbp
0000000000000011  movq  %rsp,%rbp
0000000000000014  subq  $0x10,%rsp
0000000000000018  movl  $0x00000000,0xfc(%rbp)
000000000000001f  callq 0x00000024
0000000000000024  addq  $0x10,%rsp
0000000000000028  popq  %rbp
0000000000000029  ret
$ llvm-rtdyld t.o -debug-only=dyld ; echo $?
Function sym: '_bar' @ 0
Function sym: '_main' @ 16
Extracting function: _bar from [0, 15]
    allocated to 0x100153000
Extracting function: _main from [16, 41]
    allocated to 0x100154000
Relocation at '_main' + 16 from '_bar(Word1: 0x2d000000)
Resolving relocation at '_main' + 16 (0x100154010) from '_bar (0x100153000)(pcrel, type: 2, Size: 4).
loaded '_main' at: 0x100154000
65
$




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129388 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 21:20:41 +00:00
Jim Grosbach
7cbf92d1d9 Tidy up a bit now that we're using the MemoryManager interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129328 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:23:32 +00:00
Nick Lewycky
5ea5c61589 Just because a GlobalVariable's initializer is [N x { i32, void ()* }] doesn't
mean that it has to be ConstantArray of ConstantStruct. We might have
ConstantAggregateZero, at either level, so don't crash on that.

Also, semi-deprecate the sentinal value. The linker isn't aware of sentinals so
we end up with the two lists appended, each with their "sentinals" on them.
Different parts of LLVM treated sentinals differently, so make them all just
ignore the single entry and continue on with the rest of the list.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129307 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 22:11:20 +00:00
Benjamin Kramer
cc513e1cf1 Make error message more useful.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129209 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-09 10:10:35 +00:00
Jim Grosbach
e2e777b0e7 Workaround g++ 4.2.1 warning diagnostic false positive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129149 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-08 21:11:20 +00:00
Jim Grosbach
b027105fa5 Refactor MCJIT 32-bit section loading.
Teach 32-bit section loading to use the Memory Manager interface, just like
the 64-bit loading does. Tidy up a few other things here and there.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129138 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-08 17:31:24 +00:00
Nick Lewycky
2c44a80d99 llvm.global_[cd]tor is defined to be either external, or appending with an array
of { i32, void ()* }. Teach the verifier to verify that, deleting copies of
checks strewn about.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129128 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-08 07:30:21 +00:00
Jim Grosbach
01ccab4012 tidy up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129032 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-06 22:13:52 +00:00
Nick Lewycky
a040d47c74 Fix comment to use llvm 2.x syntax.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129025 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-06 20:38:44 +00:00
Jim Grosbach
c41ab789a0 RuntimeDyld should use the memory manager API.
Start teaching the runtime Dyld interface to use the memory manager API
for allocating space. Rather than mapping directly into the MachO object,
we extract the payload for each object and copy it into a dedicated buffer
allocated via the memory manager. For now, just do Segment64, so this works
on x86_64, but not yet on ARM.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128973 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-06 01:11:05 +00:00
Chandler Carruth
53c5e7b2e7 Make the virtual destructor out-of-line so we have a key function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128964 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-05 23:54:31 +00:00
Jim Grosbach
caf767bb02 Remove extraneous 'return'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128959 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-05 23:39:08 +00:00
Jim Grosbach
b572830a52 Add missing file from r128851.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128856 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-04 23:20:40 +00:00
Jim Grosbach
fcbe5b7193 Layer the memory manager between the JIT and the runtime Dyld.
The JITMemory manager references LLVM IR constructs directly, while the
runtime Dyld works at a lower level and can handle objects which may not
originate from LLVM IR. Introduce a new layer for the memory manager to
handle the interface between them. For the MCJIT, this layer will be almost
entirely simply a call-through w/ translation between the IR objects and
symbol names.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128851 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-04 23:04:39 +00:00
Jim Grosbach
5acfa9f0fd Instantiate a JITMemoryManager for MCJIT Dyld
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128485 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-29 21:03:05 +00:00
Jim Grosbach
5ffe37f2c7 Runtime dylib simple ARM 24-bit branch relocation support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128184 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-23 23:35:17 +00:00
Jim Grosbach
a8287e322f Split out relocation resolution into target-specific bits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128173 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-23 22:06:06 +00:00
Jim Grosbach
66978bd81c Fix double-free of Module.
The ExecutionEngine constructor already added the module, so there's no
need to call addModule() directly. Doing so causes a double-free of the
Module at program termination.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128171 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-23 21:35:02 +00:00
Jim Grosbach
8b54dca41c Start of relocation resolution for the runtime dyld library.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128161 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-23 19:52:00 +00:00
Jim Grosbach
8086f3b494 Make sure to report any errors from the runtime dyld.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128160 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-23 19:51:34 +00:00
Jim Grosbach
91dde155f1 Tidy up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128096 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 18:22:27 +00:00
Jim Grosbach
5010ed0367 Add missing file from previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128095 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 18:21:14 +00:00
Jim Grosbach
b3eecaf19e Propogate the error message, not just the error state.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128094 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 18:19:42 +00:00
Jim Grosbach
34714a0609 Add simple arg passing to MC-JIT and support for exit() call.
Support argument passing simple, common, prototypes directly. More
complicated scenarios will require building up a stub function, which the
MC-JIT isn't set up to handle yet.

Add Intercept.cpp, which is just a copy from ExecutionEngine/JIT for now,
to handle looking looking up external symbol names. This probably more
properly belongs as part of RuntimeDyld. It'll migrate there as things
flesh out more fully.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128090 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 18:05:27 +00:00
Jim Grosbach
8bf0ecdbf6 Trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128086 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 15:21:58 +00:00
Eric Christopher
d6190673f0 Fix comment in header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128077 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 08:49:56 +00:00
Jim Grosbach
f922910494 Hook up the MCJIT to the RuntimeDyld library.
Lots of cleanup to make the interfaces prettier, use the JITMemoryManager,
handle multiple functions and modules, etc.. This gets far enough that
the MCJIT compiles and runs code, though.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128052 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 01:06:42 +00:00
Jim Grosbach
8371c89902 Initialize HasError.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128049 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 00:42:19 +00:00
Oscar Fuentes
1dbf6f5ab4 Build the new RuntimeDyld library.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128035 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-21 23:07:53 +00:00
Jim Grosbach
6e56331ed9 Library-ize the dyld components of llvm-rtdyld.
Move the dynamic linking functionality of the llvm-rtdyld program into an
ExecutionEngine support library. Update llvm-rtdyld to just load an object
file into memory, use the library to process it, then run the _main()
function, if one is found.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128031 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-21 22:15:52 +00:00
Jim Grosbach
7b6747ed42 Silence a warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127918 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-18 22:50:49 +00:00
Jim Grosbach
31649e61bc Beginnings of MC-JIT code generation.
Proof-of-concept code that code-gens a module to an in-memory MachO object.
This will be hooked up to a run-time dynamic linker library (see: llvm-rtdyld
for similarly conceptual work for that part) which will take the compiled
object and link it together with the rest of the system, providing back to the
JIT a table of available symbols which will be used to respond to the
getPointerTo*() queries.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127916 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-18 22:48:41 +00:00
Jim Grosbach
124d0332db Tidy up. Whitespace and 80 column.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127721 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-16 01:21:55 +00:00
Jim Grosbach
4f9fc854bc Trailing whitespae.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127691 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15 20:25:54 +00:00
Eric Christopher
515c67ee77 Support unregistering exception frames of functions when they are removed.
Patch by Johannes Schaub!

Fixes PR8548


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127047 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-04 23:37:39 +00:00
Oscar Fuentes
6d857ca4d7 Move library stuff out of the toplevel CMakeLists.txt file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125968 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-18 22:06:14 +00:00
Oscar Fuentes
abcae24d99 Fix libffi usage when it is on a custom path.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124486 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 16:49:05 +00:00
Oscar Fuentes
11d23bd890 Use the paths to libffi's header and library even when no custom
location was stated with FFI_INCLUDE_DIR/FFI_LIBRARY_DIR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124449 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 22:58:34 +00:00