Commit Graph

59 Commits

Author SHA1 Message Date
Chris Bieneman
f079d1b63c [CMake] llvm-dwp depends on intrinsics_gen
llvm-dwp.cpp has the following include chain:

llvm/CodeGen/AsmPrinter.h
llvm/CodeGen/MachineFunctionPass.h
llvm/CodeGen/MachineFunction.h
llvm/CodeGen/MachineBasicBlock.h
llvm/CodeGen/MachineInstr.h
llvm/Analysis/AliasAnalysis.h
llvm/IR/CallSite.h
llvm/IR/Attributes.h
llvm/IR/Attributes.gen

This means llvm-dwp needs to depend on intrinsics_gen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287429 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-19 02:33:42 +00:00
Greg Clayton
f5acbc29d8 Clean up DWARFFormValue by reducing duplicated code and removing DWARFFormValue::getFixedFormSizes()
In preparation for a follow on patch that improves DWARF parsing speed, clean up DWARFFormValue so that we have can get the fixed byte size of a form value given a DWARFUnit or given the version, address byte size and dwarf32/64.

This patch cleans up code so that everyone is using one of the new DWARFFormValue functions:

static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, const DWARFUnit *U = nullptr);
static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, uint16_t Version, uint8_t AddrSize, bool Dwarf32);

This patch changes DWARFFormValue::skipValue() to rely on the output of DWARFFormValue::getFixedByteSize(...) instead of duplicating the code in each function. This will reduce the number of changes we need to make to DWARF to fewer places in DWARFFormValue when we add support for new form.

This patch also starts to support DWARF64 so that we can get correct byte sizes for forms that vary according the DWARF 32/64.

To reduce the code duplication a new FormSizeHelper pure virtual class was created that can be created as a FormSizeHelperDWARFUnit when you have a DWARFUnit, or FormSizeHelperManual where you manually specify the DWARF version, address byte size and DWARF32/DWARF64. There is now a single implementation of a function that gets the fixed byte size (instead of two where one took a DWARFUnit and one took the DWARF version, address byte size and DWARFFormat enum) and one function to skip the form values.

https://reviews.llvm.org/D26526




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286597 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11 16:21:37 +00:00
Mehdi Amini
df0b8bce48 Make the Error class constructor protected
This is forcing to use Error::success(), which is in a wide majority
of cases a lot more readable.

Differential Revision: https://reviews.llvm.org/D26481

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286561 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11 04:28:40 +00:00
Greg Clayton
07e9e1a518 Switch all DWARF variables for tags, attributes and forms over to use the llvm::dwarf enumerations instead of using raw uint16_t values. This allows easier debugging as users can see the values of the enumerations in the variables view that will show the enumeration string instead of just a number.
https://reviews.llvm.org/D26013



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285309 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27 16:32:04 +00:00
Joel Jones
8a39975ebd MC] Provide an MCTargetOptions to implementors of MCAsmBackendCtorTy, NFC
Some targets, notably AArch64 for ILP32, have different relocation encodings
based upon the ABI. This is an enabling change, so a future patch can use the
ABIName from MCTargetOptions to chose which relocations to use. Tested using
check-llvm.

The corresponding change to clang is in: http://reviews.llvm.org/D16538

Patch by: Joel Jones

Differential Revision: https://reviews.llvm.org/D16213


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276654 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 17:18:28 +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
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
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
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
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
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
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
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
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
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
David Blaikie
4945c5367f llvm-dwp: Provide error handling for invalid string field forms
This diagnostic could be improved by adding the name of the input file
containing the invalid data and/or some information about how to
identify the specific offending attribute/tag in the input. But that's
not an immediate priority as these corner cases of invalid input
shouldn't come up too often.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269727 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 00:07:10 +00:00
David Blaikie
dd6e786ff7 llvm-dwp: Add error handling for invalid (non-CU) top level tag in debug_info.dwo
The diagnostic could be improved a bit to include information about
which input file had the mistake (& which unit (counted, since the name
of the unit won't be accessible) within the input).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269723 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 23:26:29 +00:00
David Blaikie
119b9304a9 llvm-dwp: Streamline duplicate DWO ID diagnostic handling
Actually use the error return path rather than printing the duplicate
information then a separate error. But also just tidy up/deduplicate
some of the code for generating the diagnostic text.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269692 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 20:42:27 +00:00
David Blaikie
13dad4bbfc llvm-dwp: Use llvm::Error to improve diagnostic quality/error handling in llvm-dwp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269339 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12 19:59:54 +00:00
Mehdi Amini
f6071e14c5 [NFC] Header cleanup
Removed some unused headers, replaced some headers with forward class declarations.

Found using simple scripts like this one:
clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap'

Patch by Eugene Kosov <claprix@yandex.ru>

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266595 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 09:17:29 +00:00
David Blaikie
7b4c09a3e3 llvm-dwp: Add assert text
Post-commit feedback from Eric Christopher on r265452.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266225 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 18:38:33 +00:00
Kevin Enderby
c6bf9be16d Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message
Produce the first specific error message for a malformed Mach-O file describing
the problem instead of the generic message for object_error::parse_failed of
"Invalid data was encountered while parsing the file”.  Many more good error
messages will follow after this first one.

This is built on Lang Hames’ great work of adding the ’Error' class for
structured error handling and threading Error through MachOObjectFile
construction.  And making createMachOObjectFile return Expected<...> .

So to to get the error to the llvm-obdump tool, I changed the stack of
these methods to also return Expected<...> :

  object::ObjectFile::createObjectFile()
  object::SymbolicFile::createSymbolicFile()
  object::createBinary()

Then finally in ParseInputMachO() in MachODump.cpp the error can
be reported and the specific error message can be printed in llvm-objdump
and can be seen in the existing test case for the existing malformed binary
but with the updated error message.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now use of
errorToErrorCode() and errorOrToExpected() are used where the callers
are yet to be converted.

Also 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 comment:
“// TODO: Actually report errors helpfully” and a call something like
consumeError(ObjOrErr.takeError()) so the buggy code will not crash
since needed to deal with the Error.

Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along
with this that I will commit right after this.  So expect lld not to built
after this commit and before the next one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265606 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 22:14:09 +00:00
David Blaikie
46c3acf600 llvm-dwp: Handle GCC's use of multiple debug_types.dwo sections in a single .dwo file
(also includes the .test file missing from my previous commit, r265452)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265457 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 20:26:50 +00:00
David Blaikie
fe34a372e1 llvm-dwp: Handle dwo files produced by GCC
To start with, handle DW_FORM_string names. Follow up commit will handle
the interesting quirk with type units I was originally aiming for here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265452 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 20:16:38 +00:00
David Blaikie
037ba978f5 llvm-dwp: Simplify hashing code a bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265426 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 17:51:40 +00:00
David Blaikie
3bcdc18cae llvm-dwp: Include the dwo name (if available) when diagnosing duplicate CU IDs from dwp input files
If you're building dwps from other dwps, it can be hard to track down a
duplicate CU ID if it comes from two compilations of the same file in
different modes, etc. By including the .dwo path (which is hopefully
more unique than the file path) it can help track down where the
duplicates came from.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264520 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-26 20:32:14 +00:00
David Blaikie
dfb4013c58 llvm-dwp: Coalesce code for reading the CU's DW_AT_GNU_dwo_id and DW_AT_name
Going to be reading the DW_AT_GNU_dwo_name shortly as well, and there
was already enough duplication here that it was worth refactoring
rather than adding even more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264350 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24 22:17:08 +00:00
David Blaikie
7ade1db315 llvm-dwp: Add missing copyright notice to llvm-dwp.cpp
Addressing feedback on IRC by Sean Silva.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262416 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 22:29:00 +00:00
David Blaikie
c9b39e6bdd Revert "llvm-dwp: Keep ObjectFiles alive until object emission their contents can be referenced directly rather than copied"
Accidentally committed.

This reverts commit r262389.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262395 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 21:24:04 +00:00
David Blaikie
6475ea0b50 llvm-dwp: Keep ObjectFiles alive until object emission their contents can be referenced directly rather than copied
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262389 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 20:40:02 +00:00
David Blaikie
6802c0801c llvm-dwp: provide diagnostics for duplicate DWO IDs
These diagnostics aren't perfect - in the case of merging several dwos
into dwps and those dwps into more dwps - just getting the message about
the original source file name might not be much help (since it's the
same in both dwos, by definition - but doesn't tell you which chain of
dwps to backtrack)

It might be worth adding the DW_AT_dwo_id to the split debug info to
improve the diagnostic experience - might help track down the duplicates
better.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261988 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-26 07:30:15 +00:00
David Blaikie
132af4d0cd llvm-dwp: Support empty .dwo files
Though a bit odd, this is handy for a few reasons - for example, in a
build system that wants consistent input/output of build steps, but
where split-dwarf might be overriden/disabled by the user on a per-file
basis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261987 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-26 07:04:58 +00:00
David Blaikie
ff94d6e4ff llvm-dwp: Improve performance (N^2 to amortized N) by using a MapVector instead of linear searches through a vector
Figured this would be a problem, but didn't want to jump the gun - large
inputs demonstrate it pretty easily (mostly for type units, but might as
well do the same for CUs too). A random sample 6m27s -> 27s change.

Also, by checking this up-front for CUs (rather than when building the
cu_index) we can probably provide better error messages (see FIXMEs),
hopefully providing the name of the CUs rather than just their
signature.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261364 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-19 21:09:26 +00:00
David Blaikie
8e4a86a83f llvm-dwp: Don't test compression when zlib isn't available
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261298 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-19 02:03:45 +00:00
David Blaikie
fb07a71142 llvm-dwp: Support compressed input
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261296 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-19 01:51:44 +00:00
Benjamin Kramer
1af94fd91c Add parentheses around arithmetic in operand of '|'.
This avoids a operator precedence warning for mixing + and | in an
expression. I checked that this matches the definition in the Split
DWARF proposal.

Patch by Cong Liu!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261207 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-18 13:23:17 +00:00
David Blaikie
11dc371299 llvm-dwp: Support for type units when merging DWPs into larger DWPs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261072 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-17 07:00:24 +00:00
David Blaikie
2697fc5688 Fix the hash function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261071 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-17 07:00:22 +00:00
David Blaikie
2060375d7c [llvm-dwp] Merge cu_index from DWPs
This is almost feature complete - just missing tu_index merging now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259971 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-06 01:15:26 +00:00
Chris Bieneman
caeade4234 Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

"I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened."
- Obi Wan Kenobi

Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark

Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258861 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 21:29:08 +00:00
David Majnemer
56afa6e660 [MC, COFF] Support link /incremental conditionally
Today, we always take into account the possibility that object files
produced by MC may be consumed by an incremental linker.  This results
in us initialing fields which vary with time (TimeDateStamp) which harms
hermetic builds (e.g. verifying a self-host went well) and produces
sub-optimal code because we cannot assume anything about the relative
position of functions within a section (call sites can get redirected
through incremental linker thunks).

Let's provide an MCTargetOption which controls this behavior so that we
can disable this functionality if we know a-priori that the build will
not rely on /incremental.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256203 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-21 22:09:27 +00:00
David Blaikie
cd49eb3fa1 [llvm-dwp] Deduplicate type units
It's O(N^2) because it does a simple walk through the existing types to
find duplicates, but that will be fixed in a follow-up commit to use a
mapping data structure of some kind.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255482 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-14 07:42:00 +00:00
David Blaikie
ce4a723916 [llvm-dwp] Sink debug_types.dwo emission into the code parsing the type signatures (NFC)
This is a preliminary change towards deduplicating type units based on
their signatures. Next change will skip emission of types when their
signature has already been seen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255154 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-09 21:02:33 +00:00
David Blaikie
2b76269756 [llvm-dwp] Add coverage for both the presence and absence of type units, and fix/remove the emission of a broken tu_index when no type units are present
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254833 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-05 03:41:53 +00:00
David Blaikie
32ad075fd5 [llvm-dwp] clang-format this to catch anything I've missed along the way
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254828 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-05 03:06:30 +00:00
David Blaikie
543e02b438 [llvm-dwp] Support debug_tu_index
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254827 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-05 03:05:45 +00:00
David Blaikie
a2b2c5abb0 [llvm-dwp] Implement the required on-disk probed hash table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254770 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04 21:30:23 +00:00