1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

184 Commits

Author SHA1 Message Date
David Blaikie
19fb98da55 PR19553: Memory leak in RuntimeDyldELF::createObjectImageFromFile
This starts in MCJIT::getSymbolAddress where the
unique_ptr<object::Binary> is release()d and (after a cast) passed to a
single caller, MCJIT::addObjectFile.

addObjectFile calls RuntimeDyld::loadObject.
RuntimeDld::loadObject calls RuntimeDyldELF::createObjectFromFile

And the pointer is never owned at this point. I say this point, because
the alternative codepath, RuntimeDyldMachO::createObjectFile certainly
does take ownership, so this seemed like a good hint that this was a/the
right place to take ownership.

llvm-svn: 207580
2014-04-29 21:52:46 +00:00
Craig Topper
0e2ab5732c [C++] Use 'nullptr'. Tools edition.
llvm-svn: 207176
2014-04-25 04:24:47 +00:00
Chandler Carruth
237fe5f5d8 [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE
definition below all of the header #include lines, tools edition.

llvm-svn: 206848
2014-04-22 03:10:36 +00:00
Craig Topper
76695802bd [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203345
2014-03-08 08:27:28 +00:00
Ahmed Charles
52ce0c101e Replace OwningPtr<T> with std::unique_ptr<T>.
This compiles with no changes to clang/lld/lldb with MSVC and includes
overloads to various functions which are used by those projects and llvm
which have OwningPtr's as parameters. This should allow out of tree
projects some time to move. There are also no changes to libs/Target,
which should help out of tree targets have time to move, if necessary.

llvm-svn: 203083
2014-03-06 05:51:42 +00:00
Ahmed Charles
4a96a15754 [C++11] Replace OwningPtr::take() with OwningPtr::release().
llvm-svn: 202957
2014-03-05 10:19:29 +00:00
Rafael Espindola
d89ca7eab7 Replace the F_Binary flag with a F_Text one.
After this I will set the default back to F_None. The advantage is that
before this patch forgetting to set F_Binary would corrupt a file on windows.
Forgetting to set F_Text produces one that cannot be read in notepad, which
is a better failure mode :-)

llvm-svn: 202052
2014-02-24 18:20:12 +00:00
Alp Toker
5041573a0f Replace the interim lli build fix with something cleaner
Eliminates the LLI_BUILDING_CHILD build hack from r199885.

Also add a FIXME to remove code that tricks the tests into passing when the
feature fails to work. Please don't do stuff like this, the tests exist for a
reason!

llvm-svn: 199929
2014-01-23 19:57:16 +00:00
Alp Toker
03e4f23b0c Tweak r199835 to use can_execute() instead of exists()
The execution code path crashes if it can't execute the binary so we might as
well take precautions here.

llvm-svn: 199844
2014-01-22 22:17:51 +00:00
Alp Toker
c7f817a228 Eliminate inappropriate use of FindProgramByName() from lli
llvm-svn: 199835
2014-01-22 21:52:35 +00:00
Rafael Espindola
a7de95d3e7 Change createObjectFile to return an ErrorOr.
llvm-svn: 199776
2014-01-22 00:14:49 +00:00
Rafael Espindola
32f031d9a5 Return an error_code from materializeAllPermanently.
llvm-svn: 199275
2014-01-14 23:51:27 +00:00
Renato Golin
5e0ba8b8db Sanitize MCJIT remote execution
MCJIT remote execution (ChildTarget+RemoteTargetExternal) protocol was in
dire need of refactoring. It was fail-prone, had no error reporting and
implemented the same message logic on every single function.

This patch rectifies it, and makes it work on ARM, where it was randomly
failing. Other architectures shall profit from this change as well, making
their buildbots and releases more reliable.

llvm-svn: 199261
2014-01-14 22:43:43 +00:00
NAKAMURA Takumi
7f9f4d1b7d lli: Tweak CacheName not to contain DOS driveletter.
llvm-svn: 198929
2014-01-10 10:38:40 +00:00
NAKAMURA Takumi
f770ac39bf lli: LLIObjectCache: Use llvm::sys::path to get dirname.
llvm-svn: 198928
2014-01-10 10:38:34 +00:00
NAKAMURA Takumi
da4e382ace Whitespace.
llvm-svn: 198927
2014-01-10 10:38:28 +00:00
Lang Hames
a1f22f9a72 Fix accidental use of the exotic "std::string::back()" method. Turns out it's
new in C++11.

llvm-svn: 198853
2014-01-09 05:29:59 +00:00
Lang Hames
30a091cf50 Add an "-object-cache-dir=<string>" option to LLI. This option specifies the
root path to which object files managed by the LLIObjectCache instance should be
written. This option defaults to "", in which case objects are cached in the
same directory as the bitcode they are derived from.

The load-object-a.ll test has been rewritten to use this option to support
testing in environments where the test directory is not writable.

llvm-svn: 198852
2014-01-09 05:24:05 +00:00
Lang Hames
0a2238104b Replace fstream use with raw_fd_ostream.
llvm-svn: 198821
2014-01-09 00:47:54 +00:00
Lang Hames
24d99bb391 Re-apply r196639: Add support for archives and object file caching under MCJIT.
I believe the bot failures on linux systems were due to overestimating the
alignment of object-files within archives, which are only guaranteed to be
two-byte aligned. I have reduced the alignment in
RuntimeDyldELF::createObjectImageFromFile accordingly.

llvm-svn: 198737
2014-01-08 04:09:09 +00:00
NAKAMURA Takumi
8570d9058f Whitespace cleanups.
llvm-svn: 196654
2013-12-07 11:21:42 +00:00
Lang Hames
544d618765 Revert r196639 while I investigate a bot failure.
llvm-svn: 196641
2013-12-07 04:25:19 +00:00
Lang Hames
a8f3295449 Add support for archives and object file caching under MCJIT.
Patch by Andy Kaylor, with minor edits to resolve merge conflicts.

llvm-svn: 196639
2013-12-07 03:05:51 +00:00
Andrew Kaylor
ebf56c2f5f Cleaning up comments in lli
llvm-svn: 193571
2013-10-29 01:33:14 +00:00
Andrew Kaylor
e37d9c43ed Adding a workaround for __main linking with remote lli and Cygwin/MinGW
llvm-svn: 193570
2013-10-29 01:29:56 +00:00
Alp Toker
918eded7e7 Fix the lli --extra-module value_desc
llvm-svn: 193552
2013-10-28 22:51:25 +00:00
Andrew Kaylor
0fb11a9ebb Standardizing lli's extra module command line option
llvm-svn: 193544
2013-10-28 21:58:15 +00:00
Andrew Kaylor
54a20b979d Fixing problems in lli's RemoteMemoryManager.
This fixes a problem from a previous check-in where a return value was omitted.

Previously the remote/stubs-remote.ll and remote/stubs-sm-pic.ll tests were reporting passes, but they should have been failing.  Those tests attempt to link against an external symbol and remote symbol resolution is not supported.  The old RemoteMemoryManager implementation resulted in local symbols being used for resolution and the child process crashed but the test didn't notice.  With this check-in remote symbol resolution fails, and so the test (correctly) fails.

llvm-svn: 192514
2013-10-11 22:47:10 +00:00
Andrew Kaylor
d7a81f88ad Removing unintended code block from lli
llvm-svn: 192205
2013-10-08 17:15:11 +00:00
Andrew Kaylor
4c916e5212 Adding support and tests for multiple module handling in lli
llvm-svn: 191938
2013-10-04 00:49:38 +00:00
Richard Smith
6c053da49c Pass the resolved lli-child-target executable name to execv, rather than
searching $PATH for it then blindly executing it from $PWD anyway.

llvm-svn: 191856
2013-10-02 21:33:12 +00:00
Andrew Kaylor
fa19dd0edf Clean up lli execution code
llvm-svn: 191845
2013-10-02 18:04:40 +00:00
Andrew Kaylor
948eef739c Adding out-of-process execution support to lli.
At this time only Unix-based systems are supported.  Windows has stubs and should re-route to the simulated mode.

Thanks to Sriram Murali for contributions to this patch.

llvm-svn: 191843
2013-10-02 17:12:36 +00:00
Andrew Kaylor
b068069d0c Adding multiple module support for MCJIT.
Tests to follow.

PIC with small code model and  EH frame handling will not work with multiple modules.  There are also some rough edges to be smoothed out for remote target support.

llvm-svn: 191722
2013-10-01 01:47:35 +00:00
Daniel Malea
b47853a3be Add flag to lli to enable debugging of IR when used with MCJIT.
- warn users when -debug-ir is used with old JIT engine (only partial debug
  info is available) 

For example, to debug an IR file with GDB (that supports JIT registration), do:

$ gdb --args lli -use-mcjit -debug-ir testcase.ll
(gdb) break main
(gdb) run
<Process continues to lli main>
(gdb) continue
<Process continues to testcase.ll main()
(gdb) step
<Now stepping through the LLVM IR in testcase.ll>

llvm-svn: 185197
2013-06-28 19:11:40 +00:00
Tim Northover
74519947c0 Print uint64_t -debug text correctly on 32-bit hosts
On 32-bit hosts %p can print garbage when given a uint64_t, we should
use %llx instead. This only affects the output of the debugging text
produced by lli.

llvm-svn: 182209
2013-05-19 09:55:06 +00:00
Filip Pizlo
585f35b5a0 SectionMemoryManager shouldn't be a JITMemoryManager. Previously, the
EngineBuilder interface required a JITMemoryManager even if it was being used 
to construct an MCJIT. But the MCJIT actually wants a RTDyldMemoryManager. 
Consequently, the SectionMemoryManager, which is meant for MCJIT, derived 
from the JITMemoryManager and then stubbed out a bunch of JITMemoryManager 
methods that weren't relevant to the MCJIT.

This patch fixes the situation: it teaches the EngineBuilder that 
RTDyldMemoryManager is a supertype of JITMemoryManager, and that it's 
appropriate to pass a RTDyldMemoryManager instead of a JITMemoryManager if 
we're using the MCJIT. This allows us to remove the stub methods from 
SectionMemoryManager, and make SectionMemoryManager a direct subtype of 
RTDyldMemoryManager.

llvm-svn: 181820
2013-05-14 19:29:00 +00:00
Rafael Espindola
b0598a0361 Remove exception handling support from the old JIT.
llvm-svn: 181354
2013-05-07 20:53:59 +00:00
Chandler Carruth
5bf5043e5b Split out the IRReader header and the utility functions it provides into
its own library. These functions are bridging between the bitcode reader
and the ll parser which are in different libraries. Previously we didn't
have any good library to do this, and instead played fast and loose with
a "header only" set of interfaces in the Support library. This really
doesn't work well as evidenced by the recent attempt to add timing logic
to the these routines.

As part of this, make them normal functions rather than weird inline
functions, and sink the implementation into the library. Also clean up
the header to be nice and minimal.

This requires updating lots of build system dependencies to specify that
the IRReader library is needed, and several source files to not
implicitly rely upon the header file to transitively include all manner
of other headers.

If you are using IRReader.h, this commit will break you (the header
moved) and you'll need to also update your library usage to include
'irreader'. I will commit the corresponding change to Clang momentarily.

llvm-svn: 177971
2013-03-26 02:25:37 +00:00
Chandler Carruth
4c1f3c24db Move all of the header files which are involved in modelling the LLVM IR
into their new header subdirectory: include/llvm/IR. This matches the
directory structure of lib, and begins to correct a long standing point
of file layout clutter in LLVM.

There are still more header files to move here, but I wanted to handle
them in separate commits to make tracking what files make sense at each
layer easier.

The only really questionable files here are the target intrinsic
tablegen files. But that's a battle I'd rather not fight today.

I've updated both CMake and Makefile build systems (I think, and my
tests think, but I may have missed something).

I've also re-sorted the includes throughout the project. I'll be
committing updates to Clang, DragonEgg, and Polly momentarily.

llvm-svn: 171366
2013-01-02 11:36:10 +00:00
Chandler Carruth
800daa7d3d Sort the #include lines for tools/...
Again, tools are trickier to pick the main module header for than
library source files. I've started to follow the pattern of using
LLVMContext.h when it is included as a stub for program source files.

llvm-svn: 169252
2012-12-04 10:44:52 +00:00
Andrew Kaylor
74326c99fd Modifying lli to use the SectionMemoryManager.
The functionality of SectionMemoryManager is equivalent to the LLIMCJITMemoryManager being replaced except that it allocates memory as RW and later changes it to RX or R as needed.  The page permissions are set in the call to MCJIT::finalizeObject.

llvm-svn: 168722
2012-11-27 19:49:00 +00:00
Andrew Kaylor
bf5ce8a2b0 Interface changes to allow RuntimeDyld memory managers to set memory permissions after an object has been loaded.
llvm-svn: 168114
2012-11-15 23:50:01 +00:00
Andrew Kaylor
45466ea079 Add a method to indicate section address re-assignment is finished.
Prior to this patch RuntimeDyld attempted to re-apply relocations every time reassignSectionAddress was called (via MCJIT::mapSectionAddress).  In addition to being inefficient and redundant, this led to a problem when a section was temporarily moved too far away from another section with a relative relocation referencing the section being moved.  To fix this, I'm adding a new method (finalizeObject) which the client can call to indicate that it is finished rearranging section addresses so the relocations can safely be applied.

llvm-svn: 167400
2012-11-05 20:57:16 +00:00
Jim Grosbach
7241c49ace lli: Initialize the native asm parser for inline assembly.
MCJIT supports inline assembly, but requires the asm parser to do so.
Make sure to link it in and initialize it.

llvm-svn: 167392
2012-11-05 19:06:05 +00:00
Andrew Kaylor
33e910f445 Streamlined memory manager hierarchy for MCJIT and RuntimeDyld.
Patch by Ashok Thirumurthi

llvm-svn: 167192
2012-11-01 00:46:04 +00:00
Andrew Kaylor
17a434c0ae Fixed format strings to avoid pointer truncation during 64-bit debugging.
llvm-svn: 167185
2012-11-01 00:17:11 +00:00
Tim Northover
a1e6e26f6e Align the data section correctly when loading an ELF file.
Patch by Amara Emerson.

llvm-svn: 166920
2012-10-29 10:47:07 +00:00
Tim Northover
ad545e6da4 Add float-abi and softfloat options to lli
Patch by Amara Emerson.

llvm-svn: 165791
2012-10-12 09:55:13 +00:00
NAKAMURA Takumi
62159aa984 lli: [MCJIT] Suppress "__main" for cygming in LLIMCJITMemoryManager::getPointerToNamedFunction(), like legacy JITMemoryManager's.
CRT's __main (aka premain) invokes global ctors on cygming. See also PR3897.

llvm-svn: 165312
2012-10-05 14:10:23 +00:00