Commit Graph

4730 Commits

Author SHA1 Message Date
Rafael Espindola
efdbec8b0a Simplify the handling of iterators in ObjectFile.
None of the object file formats reported error on iterator increment. In
retrospect, that is not too surprising: no object format stores symbols or
sections in a linked list or other structure that requires chasing pointers.
As a consequence, all error checking can be done on begin() and end().

This reduces the text segment of bin/llvm-readobj in my machine from 521233 to
518526 bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200442 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30 02:49:50 +00:00
Rafael Espindola
b0dcfa5c1f Fix TLS handling in ELF's getAddress and llvm-nm to print 'D' for it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200433 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30 00:42:30 +00:00
Justin Bogner
5b4cc3f027 llvm-cov: Accept the long forms of gcov options
This is a bit imperfect, as these options don't show up in the help as
is and single dash variants are accepted, which differs from gcov.
Unfortunately, this seems to be as good as it gets with the cl::opt
machinery, so it'll do as an incremental step.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200419 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29 21:31:47 +00:00
Justin Bogner
c8662b128c llvm-cov: Improve help message text
This Properly capitalizes and clarifies the help output from
llvm-cov. It also puts the llvm-only / non-gcov-compatible options in
their own category.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200418 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29 21:31:45 +00:00
Justin Bogner
5119fd5e0f llvm-cov: Expect a source file as a positional parameter
Currently, llvm-cov isn't command-line compatible with gcov, which
accepts a source file name as its first parameter and infers the gcno
and gcda file names from that. This change keeps our -gcda and -gcno
options available for convenience in overriding this behaviour, but
adds the required parameter and inference behaviour as a compatible
default.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200417 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29 21:31:34 +00:00
Rafael Espindola
83780350c4 Normalize the style in llvm-nm.cpp.
It had grown fairly inconsistent. I am about to change it quite a bit to also
use the object api when handling IR files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200374 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29 04:56:19 +00:00
Rafael Espindola
07dc57c38a Make createObjectFile's signature a bit less error prone.
This will be better with c++11, but right now file_magic converts to bool,
which makes the api really easy to misuse.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200357 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29 00:02:26 +00:00
David Woodhouse
4396f5d9d2 Change MCStreamer EmitInstruction interface to take subtarget info
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200345 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28 23:12:42 +00:00
NAKAMURA Takumi
57d68595e6 [CMake] Put lli-child-target into the Folder "Misc".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200297 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28 09:43:41 +00:00
Tobias Grosser
bb0bb73da1 Do not reference llvm-gcc from bugpoint
Reiterating: llvm-gcc is dead since a long time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200220 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-27 13:44:58 +00:00
Rui Ueyama
878e272310 Rename IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA.
editbin.exe and link.exe both accepts /highentropyva option to set this bit, so
doing s/VIRTUAL_ADDRESS/VA/ should make sense.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200191 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-27 04:22:24 +00:00
Rafael Espindola
550d791907 Pass a MCSubtargetInfo down to the TargetStreamer creation.
With this the target streamers will be able to know the target features that
are in use.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200135 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-26 06:38:58 +00:00
Rui Ueyama
baa58b6692 COFF: Add a missing enum value for high entropy ASLR.
That bit is not documented in the PE/COFF spec published by Microsoft, so we
don't know the official name of it. I named this bit
IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VIRTUAL_ADDRESS because the bit is
reported as "high entropy virtual address" by dumpbin.exe,

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200121 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-26 05:05:23 +00:00
Rui Ueyama
1e839eb2cd llvm-readobj: add support for PE32+ (Windows 64 bit executable).
PE32+ supports 64 bit address space, but the file format remains 32 bit.
So its file format is pretty similar to PE32 (32 bit executable). The
differences compared to PE32 are (1) the lack of "BaseOfData" field and
(2) some of its data members are 64 bit.

In this patch, I added a new member function to get a PE32+ Header object to
COFFObjectFile class and made llvm-readobj to use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200117 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-26 04:15:52 +00:00
Mark Seaborn
2effd6cdc1 Fix "llvm-objdump -d -r" to show relocations inline for ELF files
This fixes a regression introduced by r182908, which broke
llvm-objdump's ability to display relocations inline in a disassembly
dump for ELF object files.

That change removed a SectionRelocMap from Object/ELF.h, which we
recreate in llvm-objdump.cpp.

I discovered this regression via an out-of-tree test
(test/NaCl/X86/pnacl-hides-sandbox-x86-64.ll) which used llvm-objdump.

Note that the "Unknown" string in the test output on i386 isn't quite
right, but this appears to be a pre-existing bug.

Differential Revision: http://llvm-reviews.chandlerc.com/D2559

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200090 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-25 17:38:19 +00:00
Mark Seaborn
2760cc2967 llvm-objdump: Some style cleanups to follow LLVM coding style
Rename "ec" to "EC", and rename some iterators.

Then fix whitespace using clang-format-diff.

(As requested in http://llvm-reviews.chandlerc.com/D2559)

Differential Revision: http://llvm-reviews.chandlerc.com/D2594

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200053 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-25 00:32:01 +00:00
Rafael Espindola
dbba2eb82f Fix c++03 build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200042 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-24 21:52:44 +00:00
Rafael Espindola
584fe2db6a Make ObjectFile ownership of the MemoryBuffer optional.
This allows llvm-ar to mmap the input files only once.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200040 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-24 21:32:21 +00:00
Alp Toker
ae43cab6ba Fix known typos
Sweep the codebase for common typos. Includes some changes to visible function
names that were misspelt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200018 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-24 17:20:08 +00:00
Alp Toker
27ce8feb4a Report lli remote IO errors consistently
This enables IO error reports in both the child and server processes.

The scheme still isn't entirely satisfactory and output is jumbled but it beats
having no output at all. This will hopefully unblock ARM support (PR18057).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200017 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-24 17:18:52 +00:00
Alp Toker
2a02d4bee3 lli: Factor portable messaging into a new RPCChannel facility
The client and server now use a single unified low-level RPC core built around
LLVM's existing cross-platform abstractions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199947 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 22:19:45 +00:00
Alp Toker
a4bb03774f Remove unused include following r199929
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199930 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 20:01:21 +00:00
Alp Toker
fe32bb7833 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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199929 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 19:57:16 +00:00
Juergen Ributzka
9ce88db752 Add target analysis passes to the codegen pipeline for MCJIT.
This patch adds the target analysis passes (usually TargetTransformInfo) to the
codgen pipeline. We also expose now the AddAnalysisPasses method through the C
API, because the optimizer passes would also benefit from better target-specific
cost models.

Reviewed by Andrew Kaylor

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199926 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 19:23:28 +00:00
NAKAMURA Takumi
12f6a851de Windows/ChildTarget.inc: LLIChildTarget::allocate() has gone since r199881.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199889 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 12:55:05 +00:00
Alp Toker
1f0d177335 Interim build fix for Makefiles
Looks like some parts still need detangling. Let's see if this holds for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199885 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 11:26:37 +00:00
Alp Toker
5eba14a04c Prospective Makefile build fix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199882 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 11:14:00 +00:00
Alp Toker
972fb8ca77 Refactor lli-child-target to remove duplicated code
Eliminate the copies LLVM's System mmap and cache invalidation code. These were
slowly drifting away from the original version, and moreover the copied code
was a dead end in terms of portability.

We now statically link to Support but in practice with stripping this adds next
to no weight to the resultant binary.

Also avoid installing lli-child-target to the user's $PATH. It's not meant to
be run directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199881 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 11:04:42 +00:00
Alp Toker
ac2d2e0a3d 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199844 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 22:17:51 +00:00
Alp Toker
1214e71d77 Eliminate inappropriate use of FindProgramByName() from lli
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199835 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 21:52:35 +00:00
Rafael Espindola
fa4a8f4f5a Don't open or fstat files twice in llvm-ar.
We still read/mmap them twice, but the fix for that is a bit more complex.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199815 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 16:43:45 +00:00
Rafael Espindola
2edc3a6b8d Pass the computed magic to createBinary and createObjectFile if available.
identify_magic is not free, so we should avoid calling it twice. The argument
also makes it cheap for createBinary to just forward to createObjectFile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199813 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 16:04:52 +00:00
NAKAMURA Takumi
ad8d69bfdd Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199785 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 03:12:43 +00:00
Rafael Espindola
825fc31bd3 Change createObjectFile to return an ErrorOr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199776 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 00:14:49 +00:00
Rafael Espindola
3d218156f8 Be a bit more consistent about using ErrorOr when constructing Binary objects.
The constructors of classes deriving from Binary normally take an error_code
as an argument to the constructor. My original intent was to change them
to have a trivial constructor and move the initial parsing logic to a static
method returning an ErrorOr. I changed my mind because:

* A constructor with an error_code out parameter is extremely convenient from
  the implementation side. We can incrementally construct the object and give
  up when we find an error.
* It is very efficient when constructing on the stack or when there is no
  error. The only inefficient case is where heap allocating and an error is
  found (we have to free the memory).

The result is that this is a much smaller patch. It just standardizes the
create* helpers to return an ErrorOr.

Almost no functionality change: The only difference is that this found that
we were trying to read past the end of COFF import library but ignoring the
error.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199770 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21 23:06:54 +00:00
Yunzhong Gao
a747cf1c4d Adding new LTO APIs to parse metadata nodes and extract linker options and
dependent libraries from a bitcode module.

Differential Revision: http://llvm-reviews.chandlerc.com/D2343



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199759 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21 18:31:27 +00:00
Rafael Espindola
94ad5a120f Rename these methods to match the style guide.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199751 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21 16:09:45 +00:00
Saleem Abdulrasool
bb70b577e3 tools: use 64-bit print specifier
Try to repair the ARM Cortex-A15 buildbot by using a more appropriate conversion
specifier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199711 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21 04:31:29 +00:00
Saleem Abdulrasool
d28c094c80 tools: support decoding ARM EHABI opcodes in readobj
Add support to llvm-readobj to decode the actual opcodes.  The ARM EHABI opcodes
are a variable length instruction set that describe the operations required for
properly unwinding stack frames.

The primary motivation for this change is to ease the creation of tests for the
ARM EHABI object emission as well as the unwinding directive handling in the ARM
IAS.

Thanks to Logan Chien for an extra test case!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199708 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21 02:33:15 +00:00
NAKAMURA Takumi
04a62614a3 Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199667 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 15:47:15 +00:00
Chandler Carruth
1d9ab25560 [PM] Wire up the Verifier for the new pass manager and connect it to the
various opt verifier commandline options.

Mostly mechanical wiring of the verifier to the new pass manager.
Exercises one of the more unusual aspects of it -- a pass can be either
a module or function pass interchangably. If this is ever problematic,
we can make things more constrained, but for things like the verifier
where there is an "obvious" applicability at both levels, it seems
convenient.

This is the next-to-last piece of basic functionality left to make the
opt commandline driving of the new pass manager minimally functional for
testing and further development. There is still a lot to be done there
(notably the factoring into .def files to kill the current boilerplate
code) but it is relatively uninteresting. The only interesting bit left
for minimal functionality is supporting the registration of analyses.
I'm planning on doing that on top of the .def file switch mostly because
the boilerplate for the analyses would be significantly worse.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199646 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 11:34:08 +00:00
Chandler Carruth
e608d695de [PM] Make the verifier work independently of any pass manager.
This makes the 'verifyFunction' and 'verifyModule' functions totally
independent operations on the LLVM IR. It also cleans up their API a bit
by lifting the abort behavior into their clients and just using an
optional raw_ostream parameter to control printing.

The implementation of the verifier is now just an InstVisitor with no
multiple inheritance. It also is significantly more const-correct, and
hides the const violations internally. The two layers that force us to
break const correctness are building a DomTree and dispatching through
the InstVisitor.

A new VerifierPass is used to implement the legacy pass manager
interface in terms of the other pieces.

The error messages produced may be slightly different now, and we may
have slightly different short circuiting behavior with different usage
models of the verifier, but generally everything works equivalently and
this unblocks wiring the verifier up to the new pass manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199569 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-19 02:22:18 +00:00
Rui Ueyama
9106d365f5 llvm-objdump/COFF: Print ordinal base number.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199518 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-17 22:02:24 +00:00
Quentin Colombet
9b24eeee01 [opt][PassInfo] Allow opt to run passes that need target machine.
When registering a pass, a pass can now specify a second construct that takes as
argument a pointer to TargetMachine.
The PassInfo class has been updated to reflect that possibility.
If such a constructor exists opt will use it instead of the default constructor
when instantiating the pass.

Since such IR passes are supposed to be rare, no specific support has been
added to this commit to allow an easy registration of such a pass.
In other words, for such pass, the initialization function has to be
hand-written (see CodeGenPrepare for instance).

Now, codegenprepare can be tested using opt:
opt -codegenprepare -mtriple=mytriple input.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199430 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 21:44:34 +00:00
Rui Ueyama
4b81ee4d9a Fix style issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199423 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 20:57:55 +00:00
Rui Ueyama
6010e5dfee llvm-objdump/COFF: Print DLL name in the export table header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199422 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 20:50:34 +00:00
Ed Maste
22939fa0a4 llvm-symbolizer: make mangled name heuristic apply to all symbols
PR: http://llvm.org/pr18431
Review: http://llvm-reviews.chandlerc.com/D2552


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199404 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 17:25:12 +00:00
Quentin Colombet
6b925d4ed2 Revert r199361: Now, the sanitizer got the change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199362 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 07:29:07 +00:00
Quentin Colombet
75d95de0ae [LTO] Modify lto.exports to force the sanitizer to rebuilt LTO.exports
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199361 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 07:14:01 +00:00
Rui Ueyama
fb432acff8 llmv-objdump/COFF: Print export table contents.
This patch adds the capability to dump export table contents. An example
output is this:

  Export Table:
   Ordinal      RVA  Name
         5   0x2008  exportfn1
         6   0x2010  exportfn2

By adding this feature to llvm-objdump, we will be able to use it to check
export table contents in LLD's tests. Currently we are doing binary
comparison in the tests, which is fragile and not readable to humans.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199358 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 07:05:49 +00:00
Rui Ueyama
d12cef8281 llvm-objdump: Don't print "Import table:" header if there's no import table.
If a binary does not depend on any DLL, it does not contain import table at
all. Printing the section title without contents looks wrong, so we shouldn't
print it in that case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199340 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-15 23:46:18 +00:00
Quentin Colombet
4c831d97bf [LTO] Add a hook to map LLVM diagnostics into the clients of LTO.
Add a hook in the C API of LTO so that clients of the code generator can set
their own handler for the LLVM diagnostics.
The handler is defined like this:
typedef void (*lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t
severity, const char *diag, void *ctxt)
- severity says how bad this is.
- diag is a string that contains the diagnostic message.
- ctxt is the registered context for this handler.

This hook is more general than the lto_get_error_message, since this function
keeps only the latest message and can only be queried when something went wrong
(no warning for instance).

<rdar://problem/15517596>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199338 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-15 22:04:35 +00:00
Rafael Espindola
1fca78a9b1 Return an ErrorOr<Binary *> from createBinary.
I did write a version returning ErrorOr<OwningPtr<Binary> >, but it is too
cumbersome to use without std::move. I will keep the patch locally and submit
when we switch to c++11.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199326 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-15 19:37:43 +00:00
NAKAMURA Takumi
7871309054 Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199305 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-15 08:21:38 +00:00
Rafael Espindola
27a41c1547 Check the error code and save a call to sys::fs::exists.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199293 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-15 04:49:50 +00:00
Rafael Espindola
0be7e6ffb1 Make parseBitcodeFile return an ErrorOr<Module *>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199279 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-15 01:08:23 +00:00
Rafael Espindola
1dc66089e6 Return an error_code from materializeAllPermanently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199275 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 23:51:27 +00:00
Renato Golin
70aa0556d4 Fix Remote MCJIT on Windows
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199268 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 22:59:11 +00:00
Renato Golin
83ece7a499 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199261 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 22:43:43 +00:00
Duncan P. N. Exon Smith
3e4542b2ca Reapply "LTO: add API to set strategy for -internalize"
Reapply r199191, reverted in r199197 because it carelessly broke
Other/link-opts.ll.  The problem was that calling
createInternalizePass("main") would select
createInternalizePass(bool("main")) instead of
createInternalizePass(ArrayRef<const char *>("main")).  This commit
fixes the bug.

The original commit message follows.

Add API to LTOCodeGenerator to specify a strategy for the -internalize
pass.

This is a new attempt at Bill's change in r185882, which he reverted in
r188029 due to problems with the gold linker.  This puts the onus on the
linker to decide whether (and what) to internalize.

In particular, running internalize before outputting an object file may
change a 'weak' symbol into an internal one, even though that symbol
could be needed by an external object file --- e.g., with arclite.

This patch enables three strategies:

- LTO_INTERNALIZE_FULL: the default (and the old behaviour).
- LTO_INTERNALIZE_NONE: skip -internalize.
- LTO_INTERNALIZE_HIDDEN: only -internalize symbols with hidden
  visibility.

LTO_INTERNALIZE_FULL should be used when linking an executable.

Outputting an object file (e.g., via ld -r) is more complicated, and
depends on whether hidden symbols should be internalized.  E.g., for
ld -r, LTO_INTERNALIZE_NONE can be used when -keep_private_externs, and
LTO_INTERNALIZE_HIDDEN can be used otherwise.  However,
LTO_INTERNALIZE_FULL is inappropriate, since the output object file will
eventually need to link with others.

lto_codegen_set_internalize_strategy() sets the strategy for subsequent
calls to lto_codegen_write_merged_modules() and lto_codegen_compile*().

<rdar://problem/14334895>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199244 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 18:52:17 +00:00
Rafael Espindola
0972d2777c Handle UIDs and GIDs that don't fit in 6 decimal places.
Newer unix systems have 32 bit uid and gid types, but the archive format was
not updated. Fortunately, these fields are not normally used. Just truncate
the data to fit in 6 chars.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199223 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 17:02:09 +00:00
NAKAMURA Takumi
d13b9da1b6 Revert r199191, "LTO: add API to set strategy for -internalize"
Please update also Other/link-opts.ll, in next time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199197 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 09:40:18 +00:00
Duncan P. N. Exon Smith
67af0456bc LTO: add API to set strategy for -internalize
Add API to LTOCodeGenerator to specify a strategy for the -internalize
pass.

This is a new attempt at Bill's change in r185882, which he reverted in
r188029 due to problems with the gold linker.  This puts the onus on the
linker to decide whether (and what) to internalize.

In particular, running internalize before outputting an object file may
change a 'weak' symbol into an internal one, even though that symbol
could be needed by an external object file --- e.g., with arclite.

This patch enables three strategies:

- LTO_INTERNALIZE_FULL: the default (and the old behaviour).
- LTO_INTERNALIZE_NONE: skip -internalize.
- LTO_INTERNALIZE_HIDDEN: only -internalize symbols with hidden
  visibility.

LTO_INTERNALIZE_FULL should be used when linking an executable.

Outputting an object file (e.g., via ld -r) is more complicated, and
depends on whether hidden symbols should be internalized.  E.g., for
ld -r, LTO_INTERNALIZE_NONE can be used when -keep_private_externs, and
LTO_INTERNALIZE_HIDDEN can be used otherwise.  However,
LTO_INTERNALIZE_FULL is inappropriate, since the output object file will
eventually need to link with others.

lto_codegen_set_internalize_strategy() sets the strategy for subsequent
calls to lto_codegen_write_merged_modules() and lto_codegen_compile*().

<rdar://problem/14334895>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199191 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 06:37:26 +00:00
Chandler Carruth
7f2eff792a [PM] Split DominatorTree into a concrete analysis result object which
can be used by both the new pass manager and the old.

This removes it from any of the virtual mess of the pass interfaces and
lets it derive cleanly from the DominatorTreeBase<> template. In turn,
tons of boilerplate interface can be nuked and it turns into a very
straightforward extension of the base DominatorTree interface.

The old analysis pass is now a simple wrapper. The names and style of
this split should match the split between CallGraph and
CallGraphWrapperPass. All of the users of DominatorTree have been
updated to match using many of the same tricks as with CallGraph. The
goal is that the common type remains the resulting DominatorTree rather
than the pass. This will make subsequent work toward the new pass
manager significantly easier.

Also in numerous places things became cleaner because I switched from
re-running the pass (!!! mid way through some other passes run!!!) to
directly recomputing the domtree.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199104 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-13 13:07:17 +00:00
Chandler Carruth
56e1394c88 [cleanup] Move the Dominators.h and Verifier.h headers into the IR
directory. These passes are already defined in the IR library, and it
doesn't make any sense to have the headers in Analysis.

Long term, I think there is going to be a much better way to divide
these matters. The dominators code should be fully separated into the
abstract graph algorithm and have that put in Support where it becomes
obvious that evn Clang's CFGBlock's can use it. Then the verifier can
manually construct dominance information from the Support-driven
interface while the Analysis library can provide a pass which both
caches, reconstructs, and supports a nice update API.

But those are very long term, and so I don't want to leave the really
confusing structure until that day arrives.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199082 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-13 09:26:24 +00:00
Chandler Carruth
213fb8f11e [cleanup] Add a missing include exposed by resorting other includes.
Should fix the build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199081 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-13 08:09:47 +00:00
Chandler Carruth
9f20a4c6ce Re-sort #include lines again, prior to moving headers around.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199080 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-13 08:04:33 +00:00
Chandler Carruth
e2dc71d312 [PM] Wire up support for writing bitcode with new PM.
This moves the old pass creation functionality to its own header and
updates the callers of that routine. Then it adds a new PM supporting
bitcode writer to the header file, and wires that up in the opt tool.
A test is added that round-trips code into bitcode and back out using
the new pass manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199078 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-13 07:38:24 +00:00
Chandler Carruth
085c07f4ed [PM] Wire up support for printing assembly output from the opt command.
This lets us round-trip IR in the expected manner with the opt tool.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199075 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-13 05:16:45 +00:00
Chandler Carruth
4a76032da6 [PM] Add an enum for describing the desired output strategy, and run
that through the interface rather than a simple bool. This should allow
starting to wire up real output to round-trip IR through opt with the
new pass manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199071 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-13 03:08:40 +00:00
Chandler Carruth
a59525786d [PM] Add module and function printing passes for the new pass manager.
This implements the legacy passes in terms of the new ones. It adds
basic testing using explicit runs of the passes. Next up will be wiring
the basic output mechanism of opt up when the new pass manager is
engaged unless bitcode writing is requested.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199049 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-12 12:15:39 +00:00
Chandler Carruth
b6458b6bbd [PM] Update one user of the printing pass API that I missed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199046 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-12 11:39:04 +00:00
Chandler Carruth
a5ced5ed37 [PM] Simplify the interface exposed for IR printing passes.
Nothing was using the ability of the pass to delete the raw_ostream it
printed to, and nothing was trying to pass it a pointer to the
raw_ostream. Also, the function variant had a different order of
arguments from all of the others which was just really confusing. Now
the interface accepts a reference, doesn't offer to delete it, and uses
a consistent order. The implementation of the printing passes haven't
been updated with this simplification, this is just the API switch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199044 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-12 11:30:46 +00:00
Chandler Carruth
8a5351f0f5 [PM] Rename the IR printing pass header to a more generic and correct
name to match the source file which I got earlier. Update the include
sites. Also modernize the comments in the header to use the more
recommended doxygen style.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199041 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-12 11:10:32 +00:00
Chandler Carruth
83bdd1d763 [PM] Fix a bunch of bugs I spotted by inspection when working on this
code. Copious tests added to cover these cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199039 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-12 10:02:02 +00:00
Chandler Carruth
e7687650c9 [PM] Add support for parsing function passes and function pass manager
nests to the opt commandline support. This also showcases the
implicit-initial-manager support which will be most useful for testing.
There are several bugs that I spotted by inspection here that I'll fix
with test cases in subsequent commits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199038 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-12 09:34:22 +00:00
Chandler Carruth
08be87bdfa [PM] Actually nest pass managers correctly when parsing the pass
pipeline string. Add tests that cover this now that we have execution
dumping in the pass managers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199005 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 12:06:47 +00:00
Chandler Carruth
b56749c3b7 [PM] Add names to passes under the new pass manager, and a debug output
mode that can be used to debug the execution of everything.

No support for analyses here, that will come later. This already helps
show parts of the opt commandline integration that isn't working. Tests
of that will start using it as the bugs are fixed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199004 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 11:52:05 +00:00
Chandler Carruth
4e728be2bf [PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.

The current design is looking something like this:

  ./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'

So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:

  ./bin/opt -passes=instcombine,sroa,gvn

But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.

The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.

Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.

There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
  this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.

Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.

Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
Tom Roeder
69051578c7 Space formatting fix for r198966.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198971 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 23:17:39 +00:00
Tom Roeder
48324ba825 Fixing build break: should be in the if statement, not outside.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198966 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 22:55:25 +00:00
Tom Roeder
b2c6a6c0bd Restore the library dependency of LLVMgold on LTO; this was removed recently but
is needed for LLVMgold to load in ld.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198965 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 22:48:35 +00:00
NAKAMURA Takumi
744f816bc1 lli: Tweak CacheName not to contain DOS driveletter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198929 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 10:38:40 +00:00
NAKAMURA Takumi
32712c7614 lli: LLIObjectCache: Use llvm::sys::path to get dirname.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198928 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 10:38:34 +00:00
NAKAMURA Takumi
9f456a9451 Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198927 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 10:38:28 +00:00
Lang Hames
0ee9bc7894 Fix accidental use of the exotic "std::string::back()" method. Turns out it's
new in C++11.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198853 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-09 05:29:59 +00:00
Lang Hames
4442b6ec3a 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198852 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-09 05:24:05 +00:00
David Blaikie
a34ec4a961 llvm-dwarfdump: type unit dwo support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198850 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-09 05:08:24 +00:00
Saleem Abdulrasool
3ca4db23ed llvm-readobj: address review comments for ARM EHABI printing
Rename bytecode to opcodes to make it more clear.  Change an impossible case to
llvm_unreachable instead.  Avoid allocation of a buffer by modifying the
PrintOpcodes iteration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198848 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-09 04:31:18 +00:00
Saleem Abdulrasool
fe097bffa7 llvm-readobj: fix endianness
Explicitly handle endianness to ensure that bytes are read properly on
big-endian systems.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198847 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-09 04:31:14 +00:00
Chandler Carruth
560e3955c3 Put the functionality for printing a value to a raw_ostream as an
operand into the Value interface just like the core print method is.
That gives a more conistent organization to the IR printing interfaces
-- they are all attached to the IR objects themselves. Also, update all
the users.

This removes the 'Writer.h' header which contained only a single function
declaration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198836 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-09 02:29:41 +00:00
Lang Hames
fd4f17f0d9 Replace fstream use with raw_fd_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198821 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-09 00:47:54 +00:00
Rafael Espindola
dee18bb2e8 Use getError and remove the error_code operator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198799 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-08 22:03:39 +00:00
Rafael Espindola
5de64fcb5e Use -std=gnu99 in tools/llvm-c-test/CMakeLists.txt
With a current mingw (gcc 4.8.1) it looks like we hit some variation of

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40278

The end result is that off_t is not defined and the build fails without this
patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198749 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-08 11:48:19 +00:00
Lang Hames
42fdb1f00f 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198737 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-08 04:09:09 +00:00
Saleem Abdulrasool
bc41190a74 llvm-readobj: add support for ARM EHABI unwind info
This adds some preliminary support for decoding ARM EHABI unwinding information.
The major functionality that remains from complete support is bytecode
translation.

Each Unwind Index Table is printed out as a separate entity along with its
section index, name, offset, and entries.

Each entry lists the function address, and if possible, the name, of the
function to which it corresponds.  The encoding model, personality routine or
index, and byte code is also listed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198734 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-08 03:28:09 +00:00
Chandler Carruth
bc65a8d518 Move the LLVM IR asm writer header files into the IR directory, as they
are part of the core IR library in order to support dumping and other
basic functionality.

Rename the 'Assembly' include directory to 'AsmParser' to match the
library name and the only functionality left their -- printing has been
in the core IR library for quite some time.

Update all of the #includes to match.

All of this started because I wanted to have the layering in good shape
before I started adding support for printing LLVM IR using the new pass
infrastructure, and commandline support for the new pass infrastructure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198688 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-07 12:34:26 +00:00
Simon Atanasyan
9de1c5fcb4 [Mips] Add support for DT_MIPS_RLD_MAP and DT_MIPS_PLTGOT dynamic
section tags to the llvm-readobj.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198561 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-05 13:40:27 +00:00
Nico Weber
94d1e67cb5 Port r198087 and r198089 (strip dead code by default) from make to cmake.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198198 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-30 03:36:05 +00:00
Nico Weber
15deec7a8d Set LLVM_EXPORTED_SYMBOL_FILE in CMakeLists whose corresponding Makefiles do so.
(unittests/ExecutionEngine/JIT/CMakeLists.txt is still missing for now, since
it handles export files in a strange way: It generates a .exports file from a
.def file instead of the other way round.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198183 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-29 23:06:49 +00:00