Commit Graph

7289 Commits

Author SHA1 Message Date
Vedant Kumar
a6154f98d5 [llvm-cov] Flesh out some doxygen comments, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273772 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 05:48:54 +00:00
Vedant Kumar
49b4592c1a Try to fix the MSVC build
There's some kind of issue with using "constexpr unsigned" in an
anonymous namespace.

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/13395

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273770 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 03:27:29 +00:00
Vedant Kumar
a9bf312be4 [llvm-cov] Separate presentation logic from formatting logic, NFC
This makes it easier to add renderers for new kinds of output formats.

- Define and document a pure-virtual coverage rendering interface.
- Move the text-based rendering logic into its a new file.
- Re-work the API to better reflect the presentation/formatting split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273767 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 02:58:30 +00:00
Chris Bieneman
e92acf1526 [obj2yaml] [yaml2obj] Support for MachO Universal binaries
This patch adds round-trip support for MachO Universal binaries to obj2yaml and yaml2obj. Universal binaries have a header and list of architecture structures, followed by a the individual object files at specified offsets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273719 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 20:42:28 +00:00
Michael Kuperstein
f3f8fc6a20 [PM] Port PreISelIntrinsicLowering to the new PM
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273713 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 20:13:42 +00:00
Kevin Enderby
317de7ce5b Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to allow
a good error message to be produced.

This is nearly the last libObject interface that used ErrorOr and the last one
that appears in llvm/include/llvm/Object/MachO.h .  For Mach-O objects this is
just a clean up because it’s version of getSymbolAddress() can’t return an
error.

I will leave it to the experts on COFF and ELF to actually add meaning full
error messages in their tests if they wish.  And also leave it to these experts
to change the last two ErrorOr interfaces in llvm/include/llvm/Object/ObjectFile.h
for createCOFFObjectFile() and createELFObjectFile() if they wish.

Since there are no test cases for COFF and ELF error cases with respect to
getSymbolAddress() in the test suite this is no functional change (NFC).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273701 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 18:24:42 +00:00
Vedant Kumar
5187623c72 [llvm-cov] Fix two warnings
They were using output streams inconsistently. One also had a grammar
bug.

I noticed these while trying to pare down D18278.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273642 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 02:33:01 +00:00
Vedant Kumar
1bbbb81ac2 [llvm-cov] Use getOptions() instead of Options in SourceCoverageView, NFC
A lot of this code is going to move into the text-based coverage
renderer, and won't be able to use Options directly. Use the getter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273635 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 00:41:26 +00:00
Vedant Kumar
cc9ef12921 [llvm-cov] Add SourceNames to SourceCoverageViews, NFC
A SourceName can be a file or a function. It makes sense to attach this
information to a SourceCoverageView, seeing as views (1) already point
to the text corresponding to the relevant source code and (2) are
already used to render that text along with the SourceNames.

This is a nice cleanup which is independent of the upcoming html patch.

While we're at it, document the fields in SourceCoverageView.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273634 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 00:34:51 +00:00
Vedant Kumar
6706133bc9 [llvm-cov] Rename SourceCoverageView::LineCoverageInfo to LineCoverageStats, NFC
Pull LineCoverageInfo out of SourceCoverageView and rename it so that it
doesn't conflict with another class of the same name in
CoverageSummaryInfo.h.

This cuts down on the amount of code we have to move into a `protected`
section of SourceCoverageView for the upcoming html patch. It also makes
the code a bit clearer: having two LineCoverageInfo's is strange.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273633 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 00:34:48 +00:00
Chris Bieneman
46c1e8f8c6 [yaml2macho] Removing asserts in favor of explicit yaml parse error
32-bit Mach headers don't have reserved fields. When generating the
mapping for 32-bit headers leaving off the reserved field will result in
parse errors if the field is present in the yaml.

Added a CHECK-NOT line to ensure that mach_header.yaml isn't adding a
reserved field, and a test to ensure that the parser error gets hit with
32-bit headers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273623 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-23 22:36:31 +00:00
Vedant Kumar
26de1b8135 NFC, add an "end namespace" comment for consistency
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273577 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-23 16:27:08 +00:00
Diana Picus
c412e39cb6 [llc] Remove exit-on-error flag (PR27759)
This flag was introduced in r269655 with the new diagnostic handler for llc. Its
purpose was to keep the old behavior for some of the tests that didn't recover
well after an error. Those tests have been fixed, so now it's safe to remove the
flag entirely.

Fixes PR27759.

Differential Revision: http://reviews.llvm.org/D21368

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273554 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-23 09:49:56 +00:00
Reid Kleckner
e68240cbcd Change that to include MCMachObjectWriter.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273511 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 23:30:43 +00:00
Reid Kleckner
6398eb7a1c Add one more missing MCObjectWriter.h include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273510 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 23:28:12 +00:00
Saleem Abdulrasool
126491ead4 llvm-ar: reduce some duplication, NFC
Improve the previous change by using a local function to reduce the duplication
of the object file scanning.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273429 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 15:44:25 +00:00
George Rimar
a4c44066ce [llvm-readobj] - Teach llvm-readobj to print dependencies of SHT_GNU_verdef and refactor dumping method.
This patch changes single method of llvm-readobj.
It teaches SHT_GNU_verdef dumper to print version dependencies,
also it removes few fields from output that can be dumped with other keys
and slightly refactors code.
Testcase was also modified to match the changes.
Change is required for testcases of upcoming lld patches.

Differential revision: http://reviews.llvm.org/D21552

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273417 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 13:43:38 +00:00
Saleem Abdulrasool
d319cd64a4 llvm-ar: be more clever about default format
Try to be more clever about selecting the default format.  When an existing
archive is used, use the type of the archive to determine the format.  When
existing members are present, use the first member's format to determine the
format to use.  If we are creating an empty archive (MRI mode) or are adding
non-object members, default to the current behaviour of using the host type due
to the lack of a better alternative.  This aids in cross-compilation on Darwin
to non-Darwin platforms which rely on GNU format archives.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273373 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 04:03:28 +00:00
Peter Collingbourne
99e2e27b37 IR: Allow metadata attachments on declarations, and fix lazy loaded metadata issue with globals.
This change is motivated by an upcoming change to the metadata representation
used for CFI. The indirect function call checker needs type information for
external function declarations in order to correctly generate jump table
entries for such declarations. We currently associate such type information
with declarations using a global metadata node, but I plan [1] to move all
such metadata to global object attachments.

In bitcode, metadata attachments for function declarations appear in the
global metadata block. This seems reasonable to me because I expect metadata
attachments on declarations to be uncommon. In the long term I'd also expect
this to be the case for CFI, because we'd want to use some specialized bitcode
format for this metadata that could be read as part of the ThinLTO thin-link
phase, which would mean that it would not appear in the global metadata block.

To solve the lazy loaded metadata issue I was seeing with D20147, I use the
same bitcode representation for metadata attachments for global variables as I
do for function declarations. Since there's a use case for metadata attachments
in the global metadata block, we might as well use that representation for
global variables as well, at least until we have a mechanism for lazy loading
global variables.

In the assembly format, the metadata attachments appear after the "declare"
keyword in order to avoid a parsing ambiguity.

[1] http://lists.llvm.org/pipermail/llvm-dev/2016-June/100462.html

Differential Revision: http://reviews.llvm.org/D21052

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273336 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 23:42:48 +00:00
Kevin Enderby
6a96160eba Update llvm-obdump(1) to print FAT_MAGIC_64 for Darwin’s 64-bit universal files
with the -macho and -universal-headers flags.

Just a follow on to r273207, I missed updating the printing of the fat magic
number when the universal file is a 64-bit universal file.

rdar://26899493


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273324 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 21:55:01 +00:00
Rafael Espindola
1963865e9d Delete some dead code.
Found by gcc 6.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273303 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 19:48:12 +00:00
Artem Belevich
1e67d66d5e [build] Make sure to link main executable with pthreads
Otherwise it gets linked in by one of the dependencies of shared
libraries which may be too late and we end up with weird crashes in
std::call_once().

Differential Revision: http://reviews.llvm.org/D21478

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273302 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 19:34:40 +00:00
Saleem Abdulrasool
f855e058fa llvm-ar: correct typo
Default was misspelt.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273287 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 17:19:28 +00:00
Benjamin Kramer
e5eb673413 Apply another batch of fixes from clang-tidy's performance-unnecessary-value-param.
Contains some manual fixes. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273047 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 20:41:14 +00:00
Reid Kleckner
7abe77ab98 [pdb] Don't error on missing FPO streams
64-bit PDBs never have FPO data. They have xdata instead.

Also improve error recovery of stream summary dumping while I'm here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273046 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 20:38:01 +00:00
Rafael Espindola
870227d3f8 Don't use the new x86 relax relocations on the gold plugin.
Should bring back the bots with old versions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273022 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 17:53:57 +00:00
Rafael Espindola
3be11e69ac Change the default of -relax-relocations.
llvm-mc is a developer tool, as such it make sense for it to use new
features by default.

This doesn't change the user facing clang, which still defaults to non
relaxable relocations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273014 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 17:04:56 +00:00
Zachary Turner
e8d381d02c Resubmit "[pdb] Change type visitor pattern to be dynamic."
There was a regression introduced during type stream merging when
visiting a field list record.  This has been fixed in this patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272929 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 18:22:27 +00:00
Zachary Turner
575a9fbcc9 Revert "[pdb] Change type visitor pattern to be dynamic."
This reverts commit fb0dd311e1.

This breaks some llvm-readobj tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272927 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 18:09:04 +00:00
Zachary Turner
fb0dd311e1 [pdb] Change type visitor pattern to be dynamic.
This allows better catching of compiler errors since we can use
the override keyword to verify that methods are actually
overridden.

Also in this patch I've changed from storing a boolean Error
code everywhere to returning an llvm::Error, to propagate richer
error information up the call stack.

Reviewed By: ruiu, rnk
Differential Revision: http://reviews.llvm.org/D21410

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272926 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 18:00:28 +00:00
Daniel Sanders
0b8fc77698 [llvm-objdump] Support detection of feature bits from the object and implement this for Mips.
Summary:
The Mips implementation only covers the feature bits described by the ELF
e_flags so far. Mips stores additional feature bits such as MSA in the
.MIPS.abiflags section.

Also fixed a small bug this revealed where microMIPS wouldn't add the
EF_MIPS_MICROMIPS flag when using -filetype=obj.

Reviewers: echristo, rafael

Subscribers: rafael, mehdi_amini, dsanders, sdardis, llvm-commits

Differential Revision: http://reviews.llvm.org/D21125

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272880 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 09:17:03 +00:00
Justin Lebar
b570d71127 [Bugpoint] Erase comdat annotations after removing a global's initializer.
Summary:
This is necessary to keep the verifier happy after bugpoint removes an
initializer from a global variable with a comdat annotation, because
globals without initializers may not have comdats.

Reviewers: majnemer, rnk

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21274

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272854 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-15 23:20:12 +00:00
Kevin Enderby
04195353af Fix llvm-objdump when disassembling a stripped Mach-O binary with the -macho option.
It was printing out nothing in this case.

llvm-objdump tries to disassemble sections a symbol at a time.  In the case of a
fully stripped Mach-O executable the only symbol remaining in the (__TEXT,__text)
section is the special linker defined symbol __mh_execute_header . This
symbol is special in that while it is N_SECT symbol in the (__TEXT,__text)
its address is before the start of the (__TEXT,__text).  It’s address is the
start of the __TEXT segment which is where the mach header is statically
linked. So the code in DisassembleMachO() needs to deal with this case specially.

rdar://26778273


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272837 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-15 21:14:01 +00:00
Patrik Hagglund
bed36c4198 Use FPasses in opt exactly when it is initialized.
Previously, there was a discrepancy between the population of function
passes in FPasses, and their invocation. Function passes specified on
the command line, after an optimizaton level was simply discared. This
fix PR27509.

Patch by Jesper Antonsson.

Differential Review: http://reviews.llvm.org/D20725

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272770 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-15 10:32:00 +00:00
Amaury Sechet
4e14c8337b Add support for callsite in the new C API for attributes
Summary: The second consumer of attributes.

Reviewers: Wallbraker, whitequark, echristo, rafael, jyknight

Subscribers: mehdi_amini

Differential Revision: http://reviews.llvm.org/D21266

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272754 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-15 05:14:29 +00:00
Peter Collingbourne
63b34cdf34 IR: Introduce local_unnamed_addr attribute.
If a local_unnamed_addr attribute is attached to a global, the address
is known to be insignificant within the module. It is distinct from the
existing unnamed_addr attribute in that it only describes a local property
of the module rather than a global property of the symbol.

This attribute is intended to be used by the code generator and LTO to allow
the linker to decide whether the global needs to be in the symbol table. It is
possible to exclude a global from the symbol table if three things are true:
- This attribute is present on every instance of the global (which means that
  the normal rule that the global must have a unique address can be broken without
  being observable by the program by performing comparisons against the global's
  address)
- The global has linkonce_odr linkage (which means that each linkage unit must have
  its own copy of the global if it requires one, and the copy in each linkage unit
  must be the same)
- It is a constant or a function (which means that the program cannot observe that
  the unique-address rule has been broken by writing to the global)

Although this attribute could in principle be computed from the module
contents, LTO clients (i.e. linkers) will normally need to be able to compute
this property as part of symbol resolution, and it would be inefficient to
materialize every module just to compute it.

See:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160509/356401.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160516/356738.html
for earlier discussion.

Part of the fix for PR27553.

Differential Revision: http://reviews.llvm.org/D20348

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272709 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 21:01:22 +00:00
Zachary Turner
7d35b2d2b1 Resubmit "[pdb] Actually write a PDB to disk from YAML.""
Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21220

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272708 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 20:48:36 +00:00
Zachary Turner
bf3c011ba7 Revert "[pdb] Actually write a PDB to disk from YAML."
This reverts commit 879139e1c6.

This was committed accidentally when I blindly typed git svn
dcommit instead of the command to generate a patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272693 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 18:51:35 +00:00
Zachary Turner
879139e1c6 [pdb] Actually write a PDB to disk from YAML.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272692 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 18:49:36 +00:00
Benjamin Kramer
13c42d2b20 Run clang-tidy's performance-unnecessary-copy-initialization over LLVM.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272516 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-12 17:30:47 +00:00
Amaury Sechet
ca669104bf Make sure we have a Add/Remove/Has function for various thing that can have attribute.
Summary: This also deprecated the get attribute function familly.

Reviewers: Wallbraker, whitequark, joker.eph, echristo, rafael, jyknight

Subscribers: axw, joker.eph, llvm-commits

Differential Revision: http://reviews.llvm.org/D19181

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272504 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-12 06:17:24 +00:00
Zachary Turner
90005b6d83 Make PDBFile take a StreamInterface instead of a MemBuffer.
This is the next step towards being able to write PDBs.
MemoryBuffer is immutable, and StreamInterface is our replacement
which can be any combination of read-only, read-write, or write-only
depending on the particular implementation.

The one place where we were creating a PDBFile (in RawSession) is
updated to subclass ByteStream with a simple adapter that holds
a MemoryBuffer, and initializes the superclass with the buffer's
array, so that all the functionality of ByteStream works
transparently.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272370 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-10 05:10:19 +00:00
Zachary Turner
579bef0ca2 Add support for writing through StreamInterface.
This adds method and tests for writing to a PDB stream.  With
this, even a PDB stream which is discontiguous can be treated
as a sequential stream of bytes for the purposes of writing.

Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21157

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272369 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-10 05:09:12 +00:00
Quentin Colombet
7f8e1c60de [llc] Do not create the pass config several times for run-pass.
Thanks to Matthias Braun for spotting this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272358 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-10 01:12:06 +00:00
Quentin Colombet
aef5f640f7 [llc] Add support for several run-pass options.
Previously we could run only one machine pass with the run-pass option.
With that patch, we can now specify several passes with several run-pass
options (or just one option with a list of comma separated passes) and
llc will build the related pipeline.
This is great to test the interaction of two passes that are not
necessarily next to each other in the pipeline, or play with pass
ordering.
Now, we should be at parity with opt for the flexibility of running
passes.

Note: I also moved the run pass option from CommandFlags.h to llc.cpp
because, really, this is needed only there!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272356 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-10 00:52:10 +00:00
Diana Picus
1063f931d5 [llc] Remove exit-on-error flag from MIR tests (PR27770)
This is made possible by removing an assert in llc that assumed
MIRParser::parseLLVMModule would exit on error. MIRParser's documentation states
that it returns null if a parsing error occurs, so there's no reason to assert.
We can instead just fall through to where the check for a module is performed
and exit if it is null.

This commit is part of the clean-up after r269655.

Fixes PR27770

Differential Revision: http://reviews.llvm.org/D20371

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272254 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 10:31:05 +00:00
Teresa Johnson
875352d9b1 [ThinLTO/gold] Enable summary-based internalization
Summary: Enable existing summary-based importing support in the gold-plugin.

Reviewers: mehdi_amini

Subscribers: llvm-commits, mehdi_amini

Differential Revision: http://reviews.llvm.org/D21080

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272239 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 01:14:13 +00:00
Richard Smith
0eeb3d4004 Search for llvm-symbolizer binary in the same directory as argv[0], before
looking for it along $PATH. This allows installs of LLVM tools outside of
$PATH to find the symbolizer and produce pretty backtraces if they crash.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272232 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 00:53:21 +00:00
Zachary Turner
22ca3e86a7 [pdbdump-fuzzer] Try to fix build errors in fuzzer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272230 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 00:21:37 +00:00
Chris Bieneman
0fd0a998e1 [CMake] Cleanup uses of USES_TERMINAL
Now that we are on CMake 3.4.3 we no longer need a version check around this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272211 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 22:19:25 +00:00
Benjamin Kramer
36538ffe93 Apply most suggestions of clang-tidy's performance-unnecessary-value-param
Avoids unnecessary copies. All changes audited & pass tests with asan.
No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272190 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 19:09:22 +00:00
Zachary Turner
99272168e0 [pdb] Handle stream index errors better.
Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21128

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272172 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:26:39 +00:00
Benjamin Kramer
04a303b821 Avoid copies of std::strings and APInt/APFloats where we only read from it
As suggested by clang-tidy's performance-unnecessary-copy-initialization.
This can easily hit lifetime issues, so I audited every change and ran the
tests under asan, which came back clean.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272126 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 10:01:20 +00:00
Zachary Turner
44e9b3090f [pdb] Try to fix use after free.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272078 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 00:25:08 +00:00
Rui Ueyama
5ae402a784 [pdbdump] Print out # of hash buckets.
In the reference code, the field name is `cHashBuckets`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272075 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 23:53:43 +00:00
Rui Ueyama
650053d1ce [pdbdump] Print out TPI hash key size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272073 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 23:44:27 +00:00
Vedant Kumar
192404027d Retry^4 "[llvm-profdata] Add option to ingest filepaths from a file"
Changes since the initial commit:
- Use echo instead of printf. This should side-step the character
  escaping issues on Windows.

Differential Revision: http://reviews.llvm.org/D20980

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272068 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 22:47:31 +00:00
George Rimar
df40105b52 [llvm-readobj] - Teach llvm-readobj to dump .gnu.version_r sections
SHT_GNU_verneed (.gnu.version_r) is a version dependency section.
It was the last symbol versioning relative section that was not dumped,
now it is.

Differential revision: http://reviews.llvm.org/D21024

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271998 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 11:04:49 +00:00
Zachary Turner
6e00ec14d5 [pdb] Use MappedBlockStream to parse the PDB directory.
In order to efficiently write PDBs, we need to be able to make a
StreamWriter class similar to a StreamReader, which can transparently deal
with writing to discontiguous streams, and we need to use this for all
writing, similar to how we use StreamReader for all reading.

Most discontiguous streams are the typical numbered streams that appear in
a PDB file and are described by the directory, but the exception to this,
that until now has been parsed by hand, is the directory itself.
MappedBlockStream works by querying the directory to find out which blocks
a stream occupies and various other things, so naturally the same logic
could not possibly work to describe the blocks that the directory itself
resided on.

To solve this, I've introduced an abstraction IPDBStreamData, which allows
the client to query for the list of blocks occupied by the stream, as well
as the stream length. I provide two implementations of this: one which
queries the directory (for indexed streams), and one which queries the
super block (for the directory stream).

This has the side benefit of vastly simplifying the code to parse the
directory. Whereas before a mini state machine was rolled by hand, now we
simply use FixedStreamArray to read out the stream sizes, then build a
vector of FixedStreamArrays for the stream map, all in just a few lines of
code.

Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21046

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271982 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 05:28:55 +00:00
Vedant Kumar
4333164ff3 Revert "Retry^2 "[llvm-profdata] Add option to ingest filepaths from a file""
This reverts commit r271953. It's still breaking on Windows, though the
list initialization issue is fixed:

http://bb.pgr.jp/builders/ninja-clang-i686-msc19-R/builds/3751

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271963 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:43:56 +00:00
Vedant Kumar
6039b79bbe Retry^2 "[llvm-profdata] Add option to ingest filepaths from a file"
Changes since the initial commit:
- Normalize file paths read from the file to prevent Windows path
  separators from escaping parts of the path.
- Since we need to store the normalized file paths in WeightedFile,
  don't do tricky things to keep the source MemoryBuffer alive.
- Don't use list-initialization for a std::string in WeightedFile.

Differential Revision: http://reviews.llvm.org/D20980

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271953 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:17:22 +00:00
Vedant Kumar
acd5f5a519 Revert "Retry "[llvm-profdata] Add option to ingest filepaths from a file"
This reverts commit r271949. It breaks the Windows build:

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/12796

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271952 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:01:42 +00:00
Vedant Kumar
8771e1714b Retry "[llvm-profdata] Add option to ingest filepaths from a file"
Changes since the initial commit:
- Normalize file paths read from the file to prevent Windows path
  separators from escaping parts of the path.
- Since we need to store the normalized file paths in WeightedFile,
  don't do tricky things to keep the source MemoryBuffer alive.

Differential Revision: http://reviews.llvm.org/D20980

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271949 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 22:39:22 +00:00
Rui Ueyama
1895d4095b [pdbdump] Print section header flags.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271943 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 21:34:55 +00:00
Chris Bieneman
ce66300bb0 [yaml2obj] Get rid of MachO header union
This is based on post-commit feedback from Sean Silva.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271942 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 21:18:43 +00:00
Zachary Turner
4efa5e541f [llvm-pdbdump] Dump stream sizes and stream blocks to yaml.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271940 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 20:37:17 +00:00
Zachary Turner
61e0e2783c [llvm-pdbdump] Dump MSF headers to YAML.
This is the simplest possible patch to get some kind of YAML
output.  All it dumps is the MSF header fields so that in
theory an empty MSF file could be reconstructed.

Reviewed By: ruiu, majnemer
Differential Revision: http://reviews.llvm.org/D20971

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271939 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 20:37:05 +00:00
Rui Ueyama
24ef682bfb [pdbdump] Print out New FPO stream contents.
The data strucutre in the new FPO stream is described in the
PE/COFF spec. There is one record per function if frame pointer
is omitted.

Differential Revision: http://reviews.llvm.org/D20999

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271926 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 18:39:21 +00:00
Chandler Carruth
557c624777 [llvm-profdata] Revert r271709 and the 3 subsequent commits - the code
and/or tests aren't working on Windows currently.

There seems to be some problem with quoting the file paths. I don't
understand the test structure here or the code well enough to try to
come up with a way to correctly handle paths with back slashes in them,
and this has caused the Windows builds to be failing for 7 hours now, so
I'm reverting the whole thing to bring them back to life. Sorry for the
disruption, but a couple of these were bug fixes anyways that can be
folded into a fresh commit.

Reverts the following patches:

r271756: Clean up the way we create the input filenames buffer (NFC)
r271748: Fix use-after-free from discarded MemoryBuffer (NFC)
r271710: Fix option description (NFC)
r271709: Add option to ingest filepaths from a file

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271760 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-04 03:08:01 +00:00
Vedant Kumar
ae73627d2a [llvm-profdata] Clean up the way we create the input filenames buffer (NFC)
Create the buffer before calling parseInputFilenamesFile(), and add a
comment explaining why this is done.

Thanks to David Li for the suggestion!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-04 00:36:28 +00:00
Vedant Kumar
8288f17aa3 [llvm-profdata] Fix use-after-free from discarded MemoryBuffer (NFC)
Thanks to Justin Bogner for pointing this out!

Caught by ASAN.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271748 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 23:12:38 +00:00
Rui Ueyama
e5f15a26d7 pdbdump: print out TPI hashes.
Differential Revision: http://reviews.llvm.org/D20945

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271736 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 20:48:51 +00:00
Teresa Johnson
ca03c97596 [ThinLTO/gold] Pass import lists by reference (NFC)
In my earlier patch r271690 I missed passing a map by reference in one
place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271732 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 20:46:32 +00:00
Reid Kleckner
1ac3f3eb9d [Symbolize] Check if the PE file has a PDB and emit an error if we can't load it
Summary:
Previously we would try to load PDBs for every PE executable we tried to
symbolize. If that failed, we would fall back to DWARF. If there wasn't
any DWARF, we'd print mostly useless symbol information using the export
table.

With this change, we only try to load PDBs for executables that claim to
have them. If that fails, we can now print an error rather than falling
back silently. This should make it a lot easier to diagnose and fix
common symbolization issues, such as not having DIA or not having a PDB.

Reviewers: zturner, eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D20982

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271725 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 20:25:09 +00:00
Zachary Turner
041e9f2c56 [llvm-pdbdump] Introduce an abstraction for the output style.
This opens the door to introducing a YAML outputter which can be
used for machine consumption.  Currently the yaml output style
is unimplemented and returns an error if you try to use it.

Reviewed By: rnk, ruiu
Differential Revision: http://reviews.llvm.org/D20967

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271712 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 19:28:33 +00:00
Vedant Kumar
c992504387 [llvm-profdata] Fix option description (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271710 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 19:10:25 +00:00
Vedant Kumar
c80b40eaea [llvm-profdata] Add option to ingest filepaths from a file
Differential Revision: http://reviews.llvm.org/D20980

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271709 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 19:05:20 +00:00
Teresa Johnson
7afe8bff4c [ThinLTO/gold] Pass down the imports lists from the thin link (NFC)
No longer need to compute the imports in each backend thread.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271690 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 17:15:54 +00:00
Chris Bieneman
b7daa1728d [yaml2obj] Sort MachO LinkEdit write operations based on offset
This re-applies r271611, and hopefully the bots won't break this time.

Although ld64 always outputs linkedit data in the same order, it isn't actually required to. This change makes yaml2obj resilient if the offsets are in arbitrary order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271687 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 16:58:05 +00:00
Vedant Kumar
ae4bf05906 Trim some spaces (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271681 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 15:58:59 +00:00
Zachary Turner
f7d0c1f9cf [pdb] Print out file names instead of file offsets.
When printing line information and file checksums, we were printing
the file offset field from the struct header.  This teaches
llvm-pdbdump how to turn those numbers into the filename.  In the
case of file checksums, this is done by looking in the global
string table.  In the case of line contributions, this is done
by indexing into the file names buffer of the DBI stream.  Why
they use a different technique I don't know.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271630 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 05:52:57 +00:00
Zachary Turner
c5689fd37c [pdb] Dump file checksums from pdb codeview line info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271622 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 04:01:48 +00:00
Zachary Turner
7e17f48869 [codeview] Dump line number and column information.
To facilitate this, a couple of changes had to be made:

1. `ModuleSubstream` got moved from `DebugInfo/PDB` to
`DebugInfo/CodeView`, and various codeview related types are defined
there.  It turns out `DebugInfo/CodeView/Line.h` already defines many of
these structures, but this is really old code that is not endian aware,
doesn't interact well with `StreamInterface` and not very helpful for
getting stuff out of a PDB.  Eventually we should migrate the old readobj
`COFFDumper` code to these new structures, or at least merge their
functionality somehow.

2. A `ModuleSubstream` visitor is introduced.  Depending on where your
module substream array comes from, different subsets of record types can
be expected.  We are already hand parsing these substream arrays in many
places especially in `COFFDumper.cpp`.  In the future we can migrate these
paths to the visitor as well, which should reduce a lot of code in
`COFFDumper.cpp`.

Differential Revision: http://reviews.llvm.org/D20936
Reviewed By: ruiu, majnemer

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 03:25:59 +00:00
Rui Ueyama
a4bbfe5926 Fix indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271620 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 02:42:30 +00:00
Chris Bieneman
865444b50d Revert "[yaml2obj] Sort MachO LinkEdit write operations based on offset"
This reverts commit r271611 because it broke a bot:

http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/38184

I don't currently have a handle on what went wrong, so I'll revert while I investigate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271613 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 23:58:13 +00:00
Chris Bieneman
a83a726efc [yaml2obj] Sort MachO LinkEdit write operations based on offset
Although ld64 always outputs linkedit data in the same order, it isn't actually required to. This change makes yaml2obj resilient if the offsets are in arbitrary order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271611 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 23:52:08 +00:00
Chris Bieneman
4aa4497a7d [obj2yaml] [yaml2obj] Support for MachO nlist and string table
This commit adds round tripping for MachO symbol data. Symbols are entries in the name list, that contain offsets into the string table which is at the end of the __LINKEDIT segment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 22:54:06 +00:00
NAKAMURA Takumi
ba1a4e2c28 Fixup r271533, or check-clang didn't find llvm-lto as the target.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271585 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 20:39:24 +00:00
Zachary Turner
b36db5aff2 [llvm-pdbdump] Dump CodeView line information.
This first pass only splits apart the records and dumps the line
info kinds and binary data.  Subsequent patches will parse out
the binary data into more useful information and dump it in
detail.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271576 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 20:11:22 +00:00
Rui Ueyama
698e829b29 pdbdump: print out COFF section headers.
Unlike other sections that can grow to any size, the COFF section header
stream has maximum length because each record is fixed size and the COFF
file format limits the maximum number of sections. So I decided to not
create a specific stream class for it. Instead, I added a member function
to DbiStream class which returns a vector of COFF headers.

Differential Revision: http://reviews.llvm.org/D20717

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271557 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 18:20:20 +00:00
David Majnemer
2dffc15239 Rename IMAGE_DEBUG_TYPE_NO_TIMESTAMP to IMAGE_DEBUG_TYPE_REPRO
This matches the COFF spec

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271549 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 17:32:11 +00:00
Reid Kleckner
fb1a91169a [COFF] Expose the PE debug data directory and dump it
This directory is used to find if there is a PDB associated with an
executable. I plan to use this functionality to teach llvm-symbolizer
whether it should use DIA or DWARF to symbolize a given DLL.

Reviewers: majnemer

Differential Revision: http://reviews.llvm.org/D20885

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271539 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 17:10:43 +00:00
Vedant Kumar
706cb9d996 [llvm-cov] Use string getters (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271537 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 17:00:50 +00:00
Zachary Turner
8839a0f88f [pdb] Parse and dump section map and section contribs
Differential Revision: http://reviews.llvm.org/D20876
Reviewed By: rnk, ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271488 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 05:07:49 +00:00
Tamas Berghammer
d9d9726dd8 Add new LLVM_EXTERNAL_PROJECTS option to cmake
The new option makes it possible to build external projects as part of
the llvm build without copying (or symlinking) then into llvm/tool with
specifying a few additional cmake variables.

Example usage (2 additional project called foo and bar):
-DLLVM_EXTERNAL_PROJECTS="Foo;Bar"
-DLLVM_EXTERNAL_FOO_SOURCE_DIR=/src/foo
-DLLVM_EXTERNAL_BAR_SOURCE_DIR=/src/bar

Note: This is the extension of the approach we already support for
clang/lldb/poly with adding an option to specify additional supported
projects.

Differential revision: http://reviews.llvm.org/D20838

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271440 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-01 23:00:45 +00:00
Petr Hosek
ac42e994d0 [MC] Rename EmitFill to emitFill
This is to match the overloaded variants as well as the new style.

Differential Revision: http://reviews.llvm.org/D20690

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271359 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-01 01:59:58 +00:00
Kostya Serebryany
4d3c482d43 llvm-pdbdump-fuzzer: fix the build
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271352 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 23:39:31 +00:00
Lang Hames
1fa1983597 [Orc] Add conversion to/from RuntimeDyld::SymbolInfo for JITSymbol.
This tidies up some code that was manually constructing RuntimeDyld::SymbolInfo
instances from JITSymbols. It will save more mess in the future when
JITSymbol::getAddress is extended to return an Expected<TargetAddress> rather
than just a TargetAddress, since we'll be able to embed the error checking in
the conversion.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271350 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 23:14:26 +00:00
Reid Kleckner
c59038317a Speculative build fix for codeview type dumper API change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271344 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 22:32:54 +00:00
Kevin Enderby
e9ddf3a4a7 Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error
when the object is from a slice of a Mach-O Universal Binary use something like
"foo.o (for architecture i386)" as part of the error message when expected.

Also fixed places in these tools that were ignoring object file errors from
MachOUniversalBinary::getAsObjectFile() when the code moved on to see if
the slice was an archive.

To do this MachOUniversalBinary::getAsObjectFile() and
MachOUniversalBinary::getObjectForArch() were changed from returning
ErrorOr<...> to Expected<...> then that was threaded up to its users.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now the use of
errorToErrorCode() is still used in two places yet to be fully converted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271332 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 20:35:34 +00:00
Reid Kleckner
25565d97e7 [codeview] Improve readability of type record assembly
Adds the method MCStreamer::EmitBinaryData, which is usually an alias
for EmitBytes. In the MCAsmStreamer case, it is overridden to emit hex
dump output like this:
        .byte   0x0e, 0x00, 0x08, 0x10
        .byte   0x03, 0x00, 0x00, 0x00
        .byte   0x00, 0x00, 0x00, 0x00
        .byte   0x00, 0x10, 0x00, 0x00

Also, when verbose asm comments are enabled, this patch prints the dump
output for each comment before its record, like this:
        # ArgList (0x1000) {
        #   TypeLeafKind: LF_ARGLIST (0x1201)
        #   NumArgs: 0
        #   Arguments [
        #   ]
        # }
        .byte   0x06, 0x00, 0x01, 0x12
        .byte   0x00, 0x00, 0x00, 0x00

This should make debugging easier and testing more convenient.

Reviewers: aaboud

Subscribers: majnemer, zturner, amccarth, aaboud, llvm-commits

Differential Revision: http://reviews.llvm.org/D20711

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271313 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 18:45:36 +00:00
Reid Kleckner
cb4d52f619 [codeview] Add a CVTypeDumper::dump(ArrayRef<uint8_t>) overload
This is a convenient wrapper when the type record is already laid out as
bytes in memory.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271309 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 18:15:23 +00:00
Chris Bieneman
7e74f7a10f [obj2yaml][yaml2obj] Support for reading and dumping the MachO export trie
The MachO export trie is a serially encoded trie keyed by symbol name. This code parses the trie and preserves the structure so that it can be dumped again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271300 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 17:26:36 +00:00
David Majnemer
692eabeda0 [llvm-pdbdump-fuzzer] Add a fuzzer for llvm-pdbdump
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271243 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 01:24:40 +00:00
David Majnemer
84d13f89fd [llvm-dwarfdump-fuzzer] Get this compiling again
Looks like the dwarfdump fuzzer has bitrotted, update it to take into
account updates to the libobject API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271242 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 01:24:33 +00:00
Benjamin Kramer
ac307e44e3 Remove some 'const' specifiers that do nothing but prevent moving the argument.
Found by clang-tidy's misc-move-const-arg. While there drop some
obsolete c_str() calls.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271181 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-29 10:46:35 +00:00
David Majnemer
02cabd40cd Don't dereference a symbol iterator before checking for the end case
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271173 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-29 06:18:08 +00:00
Rafael Espindola
c615a826fd Move RelaxELFRel out to llvm-mc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271160 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-29 01:11:00 +00:00
David Majnemer
52b8c95368 [COFFDumper] Validate that the next offset is not too large
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271147 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 20:04:50 +00:00
David Majnemer
03348eaac6 [COFFDumper] Make sure there is sufficient padding left in the string table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271146 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 20:04:48 +00:00
David Majnemer
f535fa1a36 [COFFDumper] Make sure there is sufficient padding left in the checksum
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271143 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 19:45:58 +00:00
David Majnemer
d0404d3057 [llvm-readobj] Validate the string table offset before using it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271139 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 19:45:49 +00:00
David Majnemer
baa5e7155c Use consume instead of manually using drop_front
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271137 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 19:17:48 +00:00
David Majnemer
872acbc405 llvm-pdbdump should have a non-zero exit code on error
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271132 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 18:25:15 +00:00
Zachary Turner
5cfb6469b8 [pdb] Finish conversion to zero copy pdb access.
This converts remaining uses of ByteStream, which was still
left in the symbol stream and type stream, to using the new
StreamInterface zero-copy classes.

RecordIterator is finally deleted, so this is the only way left
now.  Additionally, more error checking is added when iterating
the various streams.

With this, the transition to zero copy pdb access is complete.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271101 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 05:21:57 +00:00
Benjamin Kramer
14aae01bc3 Apply clang-tidy's misc-move-constructor-init throughout LLVM.
No functionality change intended, maybe a tiny performance improvement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270997 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 14:27:24 +00:00
Benjamin Kramer
b397ac432d Avoid some copies by using const references.
clang-tidy's performance-unnecessary-copy-initialization with some manual
fixes. No functional changes intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270988 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 12:30:51 +00:00
George Rimar
ec285af61c Recommit 270977 - [llvm-mc] - Teach llvm-mc to generate zlib styled compression sections.
Fix: updated clang code which was not updated by mistake.

Original commit message:
[llvm-mc] - Teach llvm-mc to generate zlib styled compression sections.

This patch is strongly based on previously reverted D20331.
(because of gnuutils < 2.26 does not support compressed debug sections in non zlib-gnu style)

Difference that this patch supports both zlib and zlib-gnu styles.

-compress-debug-sections option now supports next values:

-compress-debug-sections=zlib-gnu
-compress-debug-sections=zlib
-compress-debug-sections=none
Previously specifying -compress-debug-sections enabled zlib-gnu compression,
so anyone can put "-compress-debug-sections=zlib-gnu" to restore the behavior
that was before this patch for case when compression was enabled.

Differential revision: http://reviews.llvm.org/D20676

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270987 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 12:27:32 +00:00
George Rimar
8ab5c74bc0 Revert r270977 ([llvm-mc] - Teach llvm-mc to generate zlib styled compression sections.)
It broke buildbot:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/13585/steps/build/logs/stdio

Initial commit message:
[llvm-mc] - Teach llvm-mc to generate zlib styled compression sections.

This patch is strongly based on previously reverted D20331.
(because of gnuutils < 2.26 does not support compressed debug sections in non zlib-gnu style)

Difference that this patch supports both zlib and zlib-gnu styles.

-compress-debug-sections option now supports next values:

-compress-debug-sections=zlib-gnu
-compress-debug-sections=zlib
-compress-debug-sections=none
Previously specifying -compress-debug-sections enabled zlib-gnu compression,
so anyone can put "-compress-debug-sections=zlib-gnu" to restore the behavior
that was before this patch for case when compression was enabled.

Differential revision: http://reviews.llvm.org/D20676

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270978 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 10:06:16 +00:00
George Rimar
dd4101a976 [llvm-mc] - Teach llvm-mc to generate zlib styled compression sections.
This patch is strongly based on previously reverted D20331.
(because of gnuutils < 2.26 does not support compressed debug sections in non zlib-gnu style)

Difference that this patch supports both zlib and zlib-gnu styles.

-compress-debug-sections option now supports next values:

-compress-debug-sections=zlib-gnu
-compress-debug-sections=zlib
-compress-debug-sections=none
Previously specifying -compress-debug-sections enabled zlib-gnu compression,
so anyone can put "-compress-debug-sections=zlib-gnu" to restore the behavior
that was before this patch for case when compression was enabled.

Differential revision: http://reviews.llvm.org/D20676

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270977 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 09:58:08 +00:00
Peter Collingbourne
b7bfc99302 Linker: teach the IR mover to return llvm::Error.
This will be needed in order to consistently return an Error
to clients of the API being developed in D20268.

Differential Revision: http://reviews.llvm.org/D20550

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270967 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 05:21:35 +00:00
Zachary Turner
9cc0faee65 [codeview] Remove StreamReader copying method.
Since we want to move toward zero-copy access to stream data, we
want to remove all instances of copying operations.  So get rid
of some of those here.

Differential Revision: http://reviews.llvm.org/D20720
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270960 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 03:51:53 +00:00
Zachary Turner
0212bc82e0 [codeview,pdb] Try really hard to conserve memory when reading.
PDBs can be extremely large.  We're already mapping the entire
PDB into the process's address space, but to make matters worse
the blocks of the PDB are not arranged contiguously.  So, when
we have something like an array or a string embedded into the
stream, we have to make a copy.  Since it's convenient to use
traditional data structures to iterate and manipulate these
records, we need the memory to be contiguous.

As a result of this, we were using roughly twice as much memory
as the file size of the PDB, because every stream was copied
out and re-stitched together contiguously.

This patch addresses this by improving the MappedBlockStream
to allocate from a BumpPtrAllocator only when a read requires
a discontiguous read.  Furthermore, it introduces some data
structures backed by a stream which can iterate over both
fixed and variable length records of a PDB.  Since everything
is backed by a stream and not a buffer, we can read almost
everything from the PDB with zero copies.

Differential Revision: http://reviews.llvm.org/D20654
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 01:54:44 +00:00
Rui Ueyama
4c87e7cf1a pdbdump: print out the name of the stream 0.
Differential Revision: http://reviews.llvm.org/D20712

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270943 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 00:32:07 +00:00
Rui Ueyama
3438b38d19 pdbdump: Add -raw-all to enable all -raw-* flags.
Differential Revision: http://reviews.llvm.org/D20707

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270937 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 23:26:55 +00:00
Rui Ueyama
5b155a0d90 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270934 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 23:01:05 +00:00
Chris Bieneman
7593509c1b [obj2yaml][yaml2obj] Support for MachO lazy bindings
This adds support for YAML round tripping dyld info lazy bindings. The storage and format of these is the same as regular bind opcodes, they are just interpreted differently by dyld, and can have DONE opcodes in the middle of the opcode lists.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270920 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 21:29:39 +00:00
Chris Bieneman
429d7a4cff [obj2yaml][yaml2obj] Support for MachO weak bindings
This adds support for YAML round tripping dyld info weak bindings. The storage and format of these is the same as regular bind opcodes, they are just interpreted differently by dyld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270911 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 20:50:05 +00:00
Chris Bieneman
7ad3d3b16b [obj2yaml][yaml2obj] Support for MachO bind opcodes
This adds support for YAML round tripping dyld info bind opcodes. Bind opcodes can have signed or unsigned LEB128 data, and they can have symbols associated with them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270901 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 20:06:14 +00:00
Lang Hames
69bb6054b5 [Orc] Merge some common code for creating CompileCallbackManagers and
IndirectStubsManagers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270874 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 17:20:35 +00:00
Chris Bieneman
26cbd17577 [CMake] Restrict libxar linkage to just llvm-objdump
At some point we're going to need libObject to have this dependency, but as it is now this is causing too many headaches. This commit will reduce the linkage to just llvm-objdump where it is strictly needed, and we'll cross the libObject bridge later when we need it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270866 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 16:32:40 +00:00
Steven Wu
c1beab651a Revert "[CMake] LINK_LIBS need to be public for Darwin dylib targets"
This reverts r270723. This commit breaks greendragon.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 04:35:35 +00:00
Teresa Johnson
bb83f899dc [ThinLTO/gold] Handle bitcode archives
Summary:
Several changes were required for ThinLTO links involving bitcode
archive static libraries. With this patch clang/llvm bootstraps with
ThinLTO and gold.

The first is that the gold callbacks get_input_file and
release_input_file can normally be used to get file information for
each constituent bitcode file within an archive. However, these
interfaces lock the underlying file and can't be for each archive
constituent for ThinLTO backends where we get all the input files up
front and don't release any until after the backend threads complete.
However, it is sufficient to only get and release once per file, and
then each consituent bitcode file can be accessed via get_view. This
required saving some information to identify which file handle is the
"leader" for each claimed file sharing the same file descriptor, and
other information so that get_input_file isn't necessary later when
processing the backends.

Second, the module paths in the index need to distinguish between
different constituent bitcode files within the same archive file,
otherwise they will all end up with the same archive file path.
Do this by appending the offset within the archive for the start of the
bitcode file, returned by get_input_file when we claim each bitcode file,
and saving that along with the file handle.

Third, rather than have the function importer try to load a file based
on the module path identifier (which now contains a suffix to
distinguish different bitcode files within an archive), use a custom
module loader. This is the same approach taken in libLTO, and I am using
the support refactored into the new LTO.h header in r270509. The module
loader parses the bitcode files out of the memory buffers returned from
gold via the get_view callback and saved in a map. This also means that
we call the function importer directly, rather than add it to the pass
pipeline (which was in the plan to do already for other reasons).

Reviewers: pcc, joker.eph

Subscribers: llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D20559

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270814 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 01:46:41 +00:00
Saleem Abdulrasool
3eda57ba2f llvm-objdump: support dumping AUX records for weak externals
This is a support COFF feature.  Ensure that we can display the weak externals
auxiliary symbol.  It contains useful information (such as the default binding
and how to resolve the symbol).

This reapplies the previous patch with a modification which hopefully should fix
the endianness issues.  The variadic call would promote the ulittle32_t to a
uint32_t which would lose the byte-swapping behaviour desired.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270813 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 01:45:12 +00:00
David Blaikie
fe303ed1b8 llvm-dwp: Ensure uncompressed sections are not relocated during processing of later inputs
Richard Smith identified this in post commit review of r270466. The
string sections in particular (in the future, possibly all sections - so
I'm not going to bother pulling out just the string sections for the
extra lifetime handling right now) need to remain valid during
processing of all inputs so that elements of the DWPStringPool can be
looked up repeatedly without having to make in-memory copies of string
contents in the noncompressed case (more common in dwp+dwp merge steps
where the memory is a bigger problem because the files are larger).

Using the SmallVector (or any vector) a reallocation on push_back could
cause any of the nested SmallStrings in small mode to move in memory and
invalid pointers to their contents. Using a deque the SmallStrings will
never move around since no elements are removed from the container.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270797 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 23:37:06 +00:00
Zachary Turner
213d3d3c81 [codeview] Move StreamInterface and StreamReader to libcodeview.
We have need to reuse this functionality, including making
additional generic stream types that are smarter about how and
when they copy memory versus referencing the original memory.
So all of these structures belong in the common library
rather than being pdb specific.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270751 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 20:37:03 +00:00
Zachary Turner
f50e8cdfbd [llvm-pdbdump] Dump raw stream contents as binary block.
Dumping it as ASCII makes it fairly useless.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270742 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 18:32:07 +00:00
Chris Bieneman
4877ca745f [obj2yaml] [yaml2obj] MachO support for rebase opcodes
This is the first bit of support for MachO __LINKEDIT segment data.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270724 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 17:09:07 +00:00
Chris Bieneman
fdd7755743 [CMake] LINK_LIBS need to be public for Darwin dylib targets
This should actually address PR27855. This results in adding references to the system libs inside generated dylibs so that they get correctly pulled in when linking against the dylib.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270723 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 17:08:43 +00:00
Lang Hames
45400ad477 [RuntimeDyld] Call the SymbolResolver::findSymbolInLogicalDylib method when
searching for external symbols, and fall back to the SymbolResolver::findSymbol
method if the former returns null.

This makes RuntimeDyld behave more like a static linker: Symbol definitions
from within the current module's "logical dylib" will be preferred to
external definitions. We can build on this behavior in the future to properly
support weak symbol handling.

Custom symbol resolvers that override the findSymbolInLogicalDylib method may
notice changes due to this patch. Clients who have not overridden this method
should generally be unaffected, however users of the OrcMCJITReplacement class
may notice changes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270716 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 16:23:59 +00:00
Zachary Turner
4f4018ce2c [llvm-pdbdump] Decipher the remaining PDB streams.
We know at least know the meaning of every stream of the
PDB file.  Yay!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270669 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 05:49:48 +00:00
Saleem Abdulrasool
9c894139a0 Revert "llvm-objdump: support dumping AUX records for weak externals"
Revert it until we can figure out the endianness issue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270667 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 05:45:02 +00:00
Zachary Turner
fbbe74464a [llvm-pdbdump] Dump the IPI stream and all records.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270661 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 04:35:22 +00:00
Zachary Turner
3b27e60206 [llvm-pdbdump] Stream 0 isn't actually the MSF superblock.
Oddly enough, I realized we don't actually know what stream
0 is (if anything).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270655 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 03:53:16 +00:00
Zachary Turner
ec842a3379 [llvm-pdbdump] Dump stream summary list.
Try to figure out what each stream is, and dump its name.

This gives us a better picture of what streams we still don't
understand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270653 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 03:43:17 +00:00
Saleem Abdulrasool
d51855e21d llvm-objdump: support dumping AUX records for weak externals
This is a support COFF feature.  Ensure that we can display the weak externals
auxiliary symbol.  It contains useful information (such as the default binding
and how to resolve the symbol).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270648 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 01:59:32 +00:00
Zachary Turner
2d4f33a508 [codeview] Add support for new type records.
This adds support for parsing and dumping the following
symbol types:

S_LPROCREF
S_ENVBLOCK
S_COMPILE2
S_REGISTER
S_COFFGROUP
S_SECTION
S_THUNK32
S_TRAMPOLINE

As of this patch, the test PDB files no longer have any unknown
symbol types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270628 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 22:58:46 +00:00
Zachary Turner
db7b818057 Remove unused global variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270610 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 20:48:18 +00:00
Zachary Turner
45ab259f8d [llvm-pdbdump] Rework command line options.
When dumping huge PDB files, too many of the options were grouped
together so you would get neverending spew of output.  This patch
introduces more granular display options so you can only dump the
fields you actually care about.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270607 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 20:31:48 +00:00
Peter Collingbourne
84e27c2068 Add FIXMEs to all derived classes of std::error_category.
This helps make clear that we're moving away from std::error_code.

Differential Revision: http://reviews.llvm.org/D20592

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 20:13:46 +00:00
Zachary Turner
653eb429f5 [codeview, pdb] Dump symbol records in publics stream
Differential Revision: http://reviews.llvm.org/D20580
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270597 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 18:55:14 +00:00
Zachary Turner
fe03e32b28 Dump symbol record details in llvm-pdbdump
This makes use of the newly introduced `CVSymbolVisitor` to dump details
of each type of symbol record in the symbol streams.  Future patches will
bring this visitor based dumping to the publics stream, as well as
creating a `SymbolDumpDelegate` to print more information about
relocations etc.

Differential Revision: http://reviews.llvm.org/D20545
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270585 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 17:30:25 +00:00
Zachary Turner
ad25a60d24 Remove unused variable breaking -Werror builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270529 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 03:32:34 +00:00
Zachary Turner
24466fcd2c Make a symbol visitor and use it to dump CV symbols.
Differential Revision: http://reviews.llvm.org/D20534
Reviewed By: rnk

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270511 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 23:41:13 +00:00
David Blaikie
632d568d2e llvm-dwp: Reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270507 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 22:38:06 +00:00
David Blaikie
7bac6e8629 llvm-dwp: Split out processing of input sections to improve readability
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270503 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 22:21:10 +00:00
Kevin Enderby
f0a99b9f68 Tweak to change in r270491 to deal with the lld-x86_64-darwin13 bot having a old xar.h header.
Reviewed the change with Chris Bieneman and Pete Cooper.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270502 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 22:18:59 +00:00
David Blaikie
16017f941b llvm-dwp: Pull out compression handling helper
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270496 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 21:58:58 +00:00
Kevin Enderby
866cdd590d Add the printing the Mach-O (__LLVM,__bundle) xar archive file section "verbosely"
to llvm-objdump. This section is created with -fembed-bitcode option.

This requires the use of libxar and the Cmake and lit support were crafted by
Chris Bieneman!

rdar://26202242


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270491 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 21:34:12 +00:00
Zachary Turner
dc38d33d03 [codeview] Refactor symbol records to use same pattern as types.
This will pave the way to introduce a full fledged symbol visitor
similar to how we have a type visitor, thus allowing the same
dumping code to be used in llvm-readobj and llvm-pdbdump.

Differential Revision: http://reviews.llvm.org/D20384
Reviewed By: rnk

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270475 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 18:49:06 +00:00
David Blaikie
27665308ff llvm-dwp: More error handling around invalid compressed sections
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270466 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 17:59:17 +00:00
David Blaikie
fb4915b806 llvm-dwp: Ensure compressed sections are preserved long enough for use in the string pool
Now that the string pool is referential rather than maintaining its own
copy of string data, compressed sections (well, technically only the
debug_str section*) need to be preserved for the lifetime of the pool to
match.

* I'm not currently optimizing for memory footprint with compressed
  input - the major memory limit I'm hitting is on dwp+dwp merge steps
  and we aren't currently compressing contents in dwp files, just in the
  .dwo inputs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270462 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 17:35:51 +00:00
David Blaikie
5131c267e1 llvm-dwp: Fix the build by moving DWPStringPool into the llvm namespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270453 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 16:45:00 +00:00
Xinliang David Li
1386ead074 [profile] show more statistics
Add value profile statistics with the 'show' command.





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270450 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 16:36:11 +00:00
David Blaikie
018cdc89a0 llvm-dwp: Add an abstraction for the DWP string pool
Also reference strings in the memory mapped file, reduces memory usage
on a large test case by 18.5%.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270449 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 16:32:11 +00:00
George Rimar
e73be5ff27 [llvm-readobj] - Teach readobj to recognize SHF_COMPRESSED flag.
Main problem here was that SHF_COMPRESSED has the same value with
XCORE_SHF_CP_SECTION, which was included as standart (common) flag.
As far I understand xCore is a family of controllers and it that
means it's constant should be processed separately,
only if e_machine == EM_XCORE, otherwise llvm-readobj would output
different constants twice for compressed section:

Flags [
..
SHF_COMPRESSED (0x800)
..
XCORE_SHF_CP_SECTION (0x800)
..
]

what probably does not make sence if you're not working with xcore file.

Differential revision: http://reviews.llvm.org/D20273

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270320 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-21 10:16:58 +00:00
Chris Bieneman
d60c9c7025 [yaml2obj] [MachO] Fill Segment and Section data
This fills section data with 0xDEADBEEF and segment data not inside a section with 0xBAADDA7A. This results in yaml2obj generating a matching size object file. Any additional bytes in the file are zero'd.

This is a starting point for populating the remaining segment data, and provides a hex viewable file that you can easily see the missing data in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270286 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 22:31:50 +00:00
Adrian Prantl
d492dcbc14 dsymutil/modules: Reword the warning for static libraries without module caches
In addition to clarifying the warning message this contains a minor functional
change in that it now warns if the *immediate* parent directory in which the
missing PCM is expected to be isn't found.

This patch also includes a more comprehensive testcase.

rdar://problem/25860711

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270269 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 20:36:06 +00:00
Rui Ueyama
59427f6dc7 pdbdump: print out symbol names referred by publics stream.
DBI stream contains a stream number of the symbol record stream.
Symbol record streams is an array of length-type-value members.
Each member represents one symbol.

Publics stream contains offsets to the symbol record stream.
This patch is to print out all symbols that are referenced by
the publics stream.

Note that even with this patch, llvm-pdbdump cannot dump all the
information in a publics stream since it contains more information
than symbol names. I'll improve it in followup patches.

Differential Revision: http://reviews.llvm.org/D20480

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270262 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 19:55:17 +00:00
Chris Bieneman
e90cbf6c44 [yaml2obj] Removing debug code that scribbled 0xDEADBEEF
Now that MachO load command fields are fully covered we can fill unaccounted for bytes with 0. That allows us to sparsely specify YAML to simplify tests.

Simplifying load_commands test accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270158 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 23:26:31 +00:00
Easwaran Raman
30c760d801 Remove specializations of ProfileSummary
This removes the subclasses of ProfileSummary, moves the members of the derived classes to the base class.

Differential Revision: http://reviews.llvm.org/D20390



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270143 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 21:53:28 +00:00
Easwaran Raman
17e7f1191f Move ProfileSummary to IR.
This splits ProfileSummary into two classes: a ProfileSummary class that has methods to convert from/to metadata and a ProfileSummaryBuilder class that computes the profiles summary which is in ProfileData.

Differential Revision: http://reviews.llvm.org/D20314



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270136 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 21:07:12 +00:00
Chris Bieneman
09166ea25b [obj2yaml] [yaml2obj] Support for MachO Load Command data
This re-applies r270115.

Many of the MachO load commands can have data appended after the command structure. This data is frequently strings, but can actually be anything. This patch adds support for three optional fields on load command yaml descriptions.

The new PayloadString YAML field is populated with the data after load commands known to have strings as extra data.

The new ZeroPadBytes YAML field is a count of zero'd bytes after the end of the load command structure before the next command. This can apply anywhere in the file. MachO2YAML verifies that bytes are zero before populating this field, and YAML2MachO will add zero'd bytes.

The new PayloadBytes YAML field stores all bytes after the end of the load command structure before the next command if they are non-zero. This is a catch all for all unhandled bytes. If MachO2Yaml populates PayloadBytes it will not populate ZeroPadBytes, instead zero'd bytes will be in the PayloadBytes structure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270124 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 20:54:43 +00:00
Chris Bieneman
ac5b9174b6 Revert "[obj2yaml] [yaml2obj] Support for MachO Load Command data"
This reverts commit r270115.

This failed on several builders using GCC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270121 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 20:48:54 +00:00
Chris Bieneman
dadbde9f38 [obj2yaml] [yaml2obj] Support for MachO Load Command data
Many of the MachO load commands can have data appended after the command structure. This data is frequently strings, but can actually be anything. This patch adds support for three optional fields on load command yaml descriptions.

The new PayloadString YAML field is populated with the data after load commands known to have strings as extra data.

The new ZeroPadBytes YAML field is a count of zero'd bytes after the end of the load command structure before the next command. This can apply anywhere in the file. MachO2YAML verifies that bytes are zero before populating this field, and YAML2MachO will add zero'd bytes.

The new PayloadBytes YAML field stores all bytes after the end of the load command structure before the next command if they are non-zero. This is a catch all for all unhandled bytes. If MachO2Yaml populates PayloadBytes it will not populate ZeroPadBytes, instead zero'd bytes will be in the PayloadBytes structure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270115 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 20:40:03 +00:00
Matthew Simpson
d06ea8a8f4 [ARM, AArch64] Properly initialize InterleavedAccessPass
InterleavedAccessPass is an IR-level pass, so this change will enable testing
it with opt. This is part of D20250.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270101 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 20:08:32 +00:00
Rui Ueyama
cc76d42fd3 pdbdump: Rename NumberOfSymbols -> SymbolRecordStreamIndex.
Differential Revision: http://reviews.llvm.org/D20441

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270088 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 18:05:58 +00:00
Peter Collingbourne
28f667b461 CodeGen: Make the global-merge pass independently testable, and add a test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270023 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 04:38:56 +00:00
Vedant Kumar
c77570e062 Retry^3 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

Changes since the initial commit:
- Fix error message printing in llvm-profdata.
- Check errors in loadTestingFormat() + annotateAllFunctions().
- Defer error handling in InstrProfIterator to InstrProfReader.
- Remove the base ProfError class to work around an MSVC ICE.

Differential Revision: http://reviews.llvm.org/D19901

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270020 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 03:54:45 +00:00
Chris Bieneman
5963742178 [obj2yaml] Refactoring of dumping MachO section structs
This refactoring is to reduce code duplication between the 32-bit and 64-bit code paths. This refactoring will also make the special casing for other data after load commands cleaner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270001 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 23:22:53 +00:00
Rafael Espindola
ac8db59598 Delete Reloc::Default.
Having an enum member named Default is quite confusing: Is it distinct
from the others?

This patch removes that member and instead uses Optional<Reloc> in
places where we have a user input that still hasn't been maped to the
default value, which is now clear has no be one of the remaining 3
options.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269988 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 22:04:49 +00:00
Rui Ueyama
17e3d064b5 pdbdump: Print out section offsets in the publics stream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269955 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 16:24:16 +00:00
Chris Bieneman
7ec0ea16b7 Re-apply: [obj2yaml] [yaml2obj] Support MachO section and section_64
This re-applies r269845, r269846, and r269850 with an included fix for a crash reported by zturner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269953 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 16:17:23 +00:00
Rafael Espindola
2dc637165b Don't pass a Reloc::Model to MC.
MC only needs to know if the output is PIC or not. It never has to
decide about creating GOTs and PLTs for example. The only thing that
MC itself uses this information for is expanding "macros" in sparc and
mips. The rest I am pretty sure could be moved to CodeGen.

This is a cleanup and isolates the code from future changes to
Reloc::Model.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269909 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 11:58:50 +00:00
Igor Kudrin
24466cded7 [Coverage] Ensure that coverage mapping data has an expected alignment in 'covmapping' files.
Coverage mapping data is organized in a sequence of blocks, each of which is expected
to be aligned by 8 bytes. This feature is used when reading those blocks, see
VersionedCovMapFuncRecordReader::readFunctionRecords(). If a misaligned covearge
mapping data has more than one block, it causes llvm-cov to fail.

Differential Revision: http://reviews.llvm.org/D20285


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269887 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 07:43:27 +00:00
Rafael Espindola
36f243d8fa Delete default in fully covered switch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269872 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 00:31:06 +00:00
Zachary Turner
60ce11fcce [codeview] Some cleanup of Symbol Records.
* Reworks the CVSymbolTypes.def to work similarly to TypeRecords.def.
* Moves some enums from SymbolRecords.h to CodeView.h to maintain
  consistency with how we do type records.
* Generalize a few simple things like the record prefix
* Define the leaf enum and the kind enum similar to how we do with tyep
  records.

Differential Revision: http://reviews.llvm.org/D20342
Reviewed By: amccarth, rnk

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269867 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 23:50:21 +00:00
David Blaikie
f84af69256 llvm-dwp: remove some unused error handling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269866 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 23:44:13 +00:00
Zachary Turner
8e5ffc9803 Revert "[obj2yaml] [yaml2obj] Support MachO section and section_64
structs"

This reverts commits r269845, r269846, and r269850 as they
introduce a crash in obj2yaml when trying to do a roundtrip.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269865 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 23:38:22 +00:00
David Blaikie
34ab13fd25 llvm-dwp: Move error handling code closer to use
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269864 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 23:37:44 +00:00
Rui Ueyama
dce33b5457 pdbdump: Print out more strcutures.
I don't yet fully understand the meaning of these data strcutures,
but at least it seems that their sizes and types are correct.
With this change, we can read publics streams till end.

Differential Revision: http://reviews.llvm.org/D20343

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269861 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 23:07:48 +00:00
David Blaikie
7fdce00ff3 llvm-dwp: Add error handling for multiple type sections in a dwp file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269851 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 22:00:57 +00:00
Chris Bieneman
b04144c7d6 [obj2yaml] [yaml2obj] Support MachO section and section_64 structs
This patch adds round trip support for MachO section structs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269845 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 21:31:02 +00:00
Chris Bieneman
0865cea8c3 Reapply r269782 "[obj2yaml] [yaml2obj] Support for MachO load command structures""
This adds support for all the MachO *_command structures. The load_command payloads still are not represented, but that will come next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269808 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 19:44:06 +00:00
David Blaikie
293233a048 llvm-dwp: Simplify duplicate DWO ID error handling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269805 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 19:40:28 +00:00
Reid Kleckner
4e35fa54a6 [ThinLTO] Use semicolon to separate path prefix replacement
Summary:
Colons can appear in Windows paths after drive letters. Both colon and
semicolon are valid characters in filenames, but neither are very
common. Semicolon seems just as good, and makes the test pass on
Windows.

Reviewers: tejohnson

Subscribers: joker.eph, llvm-commits

Differential Revision: http://reviews.llvm.org/D20332

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269798 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 18:43:22 +00:00
Chris Bieneman
923a9ba5c6 Revert "[obj2yaml] [yaml2obj] Support for MachO load command structures"
This reverts commit r269782 because it broke bots with -fpermissive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269785 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 17:13:50 +00:00
Kevin Enderby
77be094e2f Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error
when the object is in an archive to use something like libx.a(foo.o) as part of
the error message.

Also changed llvm-objdump and llvm-size to be like llvm-nm and ignore non-object
files in archives and not produce any error message.

To do this Archive::Child::getAsBinary() was changed from ErrorOr<...> to
Expected<...> then that was threaded up to its users.

Converting this interface to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now the use of
errorToErrorCode() is still used in one place yet to be fully converted.

Again there some were bugs in the existing code that did not deal with the
old ErrorOr<> return values.  So now with Expected<> since they must be
checked and the error handled, I added a TODO and a comments for those.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269784 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 17:10:12 +00:00
Chris Bieneman
4a038a7aac [obj2yaml] [yaml2obj] Support for MachO load command structures
This adds support for all the MachO *_command structures. The load_command payloads still are not represented, but that will come next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269782 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 17:03:28 +00:00
Teresa Johnson
a486381660 [ThinLTO] Option to control path of distributed backend files
Summary:
Add support to control where files for a distributed backend (the
individual index files and optional imports files) are created.

This is invoked with a new thinlto-prefix-replace option in the gold
plugin and llvm-lto. If specified, expects a string of the form
"oldprefix:newprefix", and instead of generating these files in the
same directory path as the corresponding bitcode file, will use a path
formed by replacing the bitcode file's path prefix matching oldprefix
with newprefix.

Also add a new replace_path_prefix helper to Path.h in libSupport.

Depends on D19636.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D19644

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269771 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 14:45:30 +00:00