Commit Graph

8232 Commits

Author SHA1 Message Date
Benjamin Kramer dbbe5756c1 [gold-plugin] Use more StringRef. No functionality change intended.
llvm-svn: 310652
2017-08-10 19:28:00 +00:00
Benjamin Kramer 74fbf45f4c [gold-plugin] Avoid race condition when creating temporary files.
This is both a potential security issue and a potential functionality
issue because we create temporary files from multiple threads. Use
the safe version of createTemporaryFile instead.

llvm-svn: 310636
2017-08-10 17:38:41 +00:00
Simon Pilgrim c3e546fe42 Fix 'not all control paths return' warning on windows builds. NFCI.
llvm-svn: 310631
2017-08-10 17:20:09 +00:00
Marek Sokolowski d0c5bfa233 Fixup for r310621: Hint the compilers about unreachable code.
llvm-svn: 310623
2017-08-10 16:46:52 +00:00
Marek Sokolowski 719e22d4f4 Add .rc scripts tokenizer.
This extends the shell of llvm-rc tool with the ability of tokenization
of the input files. Currently, ASCII and ASCII-compatible UTF-8 files
are supported.

Thanks to Nico Weber (thakis) for his original work in this area.

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

llvm-svn: 310621
2017-08-10 16:21:44 +00:00
Eli Friedman c0c182cce1 [llvm-cov] Rearrange entries in report index.
Files which don't contain any functions are likely useless; don't
include them in the main table. Put the links at the bottom of the
page, in case someone wants to figure out coverage for code inside
a macro.

Not sure if this is the best solution, but it seems like an
improvement.

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

llvm-svn: 310518
2017-08-09 20:43:31 +00:00
Zachary Turner 5448dabbdd [PDB] Fix an issue writing the publics stream.
In the refactor to merge the publics and globals stream, a bug
was introduced that wrote the wrong value for one of the fields
of the PublicsStreamHeader.  This caused debugging in WinDbg
to break.

We had no way of dumping any of these fields, so in addition to
fixing the bug I've added dumping support for them along with a
test that verifies the correct value is written.

llvm-svn: 310439
2017-08-09 04:23:59 +00:00
Zachary Turner 59e3ae827d [PDB] Fix linking of function symbols and local variables.
The compiler outputs PROC32_ID symbols into the object files
for functions, and these symbols have an embedded type index
which, when copied to the PDB, refer to the IPI stream.  However,
the symbols themselves are also converted into regular symbols
(e.g. S_GPROC32_ID -> S_GPROC32), and type indices in the regular
symbol records refer to the TPI stream.  So this patch applies
two fixes to function records.
  1. It converts ID symbols to the proper non-ID record type.
  2. After remapping the type index from the object file's index
     space to the PDB file/IPI stream's index space, it then
     remaps that index to the TPI stream's index space by.

Besides functions, during the remapping process we were also
discarding symbol record types which we did not recognize.
In particular, we were discarding S_BPREL32 records, which is
what MSVC uses to describe local variables on the stack.  So
this patch fixes that as well by copying them to the PDB.

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

llvm-svn: 310394
2017-08-08 18:34:44 +00:00
Adrian Prantl e502f00538 dsymutil: support dwarf version mismatches between object and clang module
This adds a missing call to maybeUpdateMaxDwarfVersion when visitng a
clang module. Failing to do so will cause a failure when emitting
DWARF 4 forms into a CU that AsmPrinter believes to be DWARF 2.

rdar://problem/33666528

llvm-svn: 310392
2017-08-08 18:26:12 +00:00
Zachary Turner 489a7a09ad [llvm-pdbutil] Don't crash when a section contrib's isect is invalid.
llvm-svn: 310298
2017-08-07 20:24:01 +00:00
Simon Dardis 3886705689 [llvm-objdump] Use PRIx64 for output of ARM64_RELOC_ADDEND
llvm-svn: 310250
2017-08-07 12:29:38 +00:00
Petr Hosek d53951d2ef [llvm][llvm-objcopy] When outputting to binary don't output segments that cover no sections
Sometimes LLD will produce a PT_LOAD segment that only covers the
headers (and covers no sections). GNU objcopy does not output the
segment contents for these sections. In particular this is an issue in
building magenta because the final link step for the kernel would
produce just such a PT_LOAD segment. This change is to support this case
and to match what GNU objcopy does in this case.

Patch by Jake Ehrlich

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

llvm-svn: 310149
2017-08-04 23:18:18 +00:00
Adrian McCarthy b41f03e768 Enable llvm-pdbutil to list enumerations using native PDB reader
This extends the native reader to enable llvm-pdbutil to list the enums in a
PDB and it includes a simple test. It does not yet list the values in the
enumerations, which requires an actual implementation of
NativeEnumSymbol::FindChildren.

To exercise this code, use a command like:

    llvm-pdbutil pretty -native -enums foo.pdb

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

llvm-svn: 310144
2017-08-04 22:37:58 +00:00
Zachary Turner 92e584cb48 [pdbutil] When dumping section contribs, show the section name.
llvm-svn: 310128
2017-08-04 21:10:04 +00:00
Petr Hosek c4df10e139 Reland "[llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy"
This change adds the "-O binary" flag which directs llvm-objcopy to
output the object file to the same format as GNU objcopy does when given
the flag "-O binary". This was done by splitting the Object class into
two subclasses ObjectELF and ObjectBianry which each output a different
format but relay on the same code to read in the Object in Object.

Patch by Jake Ehrlich

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

llvm-svn: 310127
2017-08-04 21:09:26 +00:00
Zachary Turner fb1cd5090c [llvm-pdbutil] Dump image section headers.
Image section headers are stored in the DBI stream, but we
had no way to dump them.  This patch adds dumping support,
along with some tests that LLD actually dumps them correctly.

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

llvm-svn: 310107
2017-08-04 20:02:38 +00:00
Philip Pfaffe 59d690b96c [Polly][PM] Register polly passes with the opt tool for the new-pm path
Summary: When polly is linked into the tools because of the LLVM_POLLY_LINK_INTO_TOOLS option being set, we need to register its passes with the PassBuilder. Because polly is linked in, we can directly call its callback registration method, which registers the appropriate callbacks with the new PM's PassBuilder. This essentially follows exactly the way it worked with the legacy PM.

Reviewers: grosser, chandlerc, bollu

Reviewed By: grosser

Subscribers: pollydev, llvm-commits

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

llvm-svn: 310043
2017-08-04 09:28:09 +00:00
Petr Hosek b1bb3e542e Revert "[llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy"
This breaks the build on clang-s390x-linux.

This reverts commit r310018.

llvm-svn: 310026
2017-08-04 05:33:44 +00:00
Petr Hosek 10fbc733d0 Reland "[llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy"
This change adds the "-O binary" flag which directs llvm-objcopy to
output the object file to the same format as GNU objcopy does when given
the flag "-O binary". This was done by splitting the Object class into
two subclasses ObjectELF and ObjectBianry which each output a different
format but relay on the same code to read in the Object in Object.

Patch by Jake Ehrlich

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

llvm-svn: 310018
2017-08-04 03:17:37 +00:00
Vedant Kumar 846b985a92 [llvm-cov] Ignore unclosed line segments when setting line counts
This patch makes a slight change to the way llvm-cov determines line
execution counts. If there are multiple line segments on a line, the
line count is the max count among the regions which start *and* end on
the line. This avoids an issue posed by deferred regions which start on
the same line as a terminated region, e.g:

  if (false)
    return; //< The line count should be 0, even though a new region
            //< starts at the semi-colon.
  foo();

Another change is that counts from line segments which don't correspond
to region entries are considered. This enables the first change, and
corrects an outstanding issue (see the showLineExecutionCounts.cpp test
change).

This is related to D35925.

Testing: check-profile, llvm-cov lit tests

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

llvm-svn: 310012
2017-08-04 00:36:24 +00:00
Vedant Kumar 8a6223887c [llvm-cov] NFC: make_unique-ify two allocations
llvm-svn: 310011
2017-08-04 00:36:24 +00:00
Zachary Turner 5869936844 [llvm-pdbutil] Add an option to only dump specific module indices.
Often something interesting (like a symbol) is in a particular
module, and you don't want to dump symbols from all other 300
modules to see the one you want.  This adds a -modi option so that
we only dump the specified module.

llvm-svn: 310000
2017-08-03 23:11:52 +00:00
Quentin Colombet 250e050a50 [GlobalISel] Make GlobalISel a non-optional library.
With this change, the GlobalISel library gets always built. In
particular, this is not possible to opt GlobalISel out of the build
using the LLVM_BUILD_GLOBAL_ISEL variable any more.

llvm-svn: 309990
2017-08-03 21:52:25 +00:00
Zachary Turner 33eee1911a [llvm-pdbutil] Allow diff to force module equivalencies.
Sometimes the normal module equivalence detection algorithm doesn't
quite work.  For example, you might build the same program with
MSVC and clang-cl, outputting to different object files, exes, and
PDBs, then compare them.  If the object files have different names
though, then they won't be treated as equivalent.  This way we
can force specific module indices to be treated as equivalent.

llvm-svn: 309983
2017-08-03 20:30:09 +00:00
Rafael Espindola 79e238afee Delete Default and JITDefault code models
IMHO it is an antipattern to have a enum value that is Default.

At any given piece of code it is not clear if we have to handle
Default or if has already been mapped to a concrete value. In this
case in particular, only the target can do the mapping and it is nice
to make sure it is always done.

This deletes the two default enum values of CodeModel and uses an
explicit Optional<CodeModel> when it is possible that it is
unspecified.

llvm-svn: 309911
2017-08-03 02:16:21 +00:00
Vedant Kumar dde19c5a73 [Coverage] Add an API to retrive all instantiations of a function (NFC)
The CoverageMapping::getInstantiations() API retrieved all function
records corresponding to functions with more than one instantiation (e.g
template functions with multiple specializations). However, there was no
simple way to determine *which* function a given record was an
instantiation of. This was an oversight, since it's useful to aggregate
coverage information over all instantiations of a function.

llvm-cov works around this by building a mapping of source locations to
instantiation sets, but this duplicates logic that libCoverage already
has (see FunctionInstantiationSetCollector).

This change adds a new API, CoverageMapping::getInstantiationGroups(),
which returns a list of InstantiationGroups. A group contains records
for each instantiation of some particular function, and also provides
utilities to get the total execution count within the group, the source
location of the common definition, etc.

This lets removes some hacky logic in llvm-cov by reusing
FunctionInstantiationSetCollector and makes the CoverageMapping API
friendlier for other clients.

llvm-svn: 309904
2017-08-02 23:35:25 +00:00
Vedant Kumar 79554e450e [llvm-cov] Respect the value of the -show-instantiations option
Make `-show-instantiations=false` actually skip displaying instantiation
sub-views, instead of simply ignoring the option.

llvm-svn: 309903
2017-08-02 23:35:24 +00:00
Zachary Turner c3d8eec9e9 [pdbutil] Add a command to dump the FPM.
Recently problems have been discovered in the way we write the FPM
(free page map).  In order to fix this, we first need to establish
a baseline about what a correct FPM looks like using an MSVC
generated PDB, so that we can then make our own generated PDBs
match.  And in order to do this, the dumper needs a mode where it
can dump an FPM so that we can write tests for it.

This patch adds a command to dump the FPM, as well as a test against
a known-good PDB.

llvm-svn: 309894
2017-08-02 22:25:52 +00:00
Rafael Espindola 9f92995781 Don't pass the code model to MC
I was surprised to see the code model being passed to MC. After all,
it assembles code, it doesn't create it.

The one place it is used is in the expansion of .cfi directives to
handle .eh_frame being more that 2gb away from the code.

As far as I can tell, gnu assembler doesn't even have an option to
enable this. Compiling a c file with gcc -mcmodel=large produces a
regular looking .eh_frame. This is probably because in practice linker
parse and recreate .eh_frames.

In llvm this is used because the JIT can place the code and .eh_frame
very far apart. Ideally we would fix the jit and delete this
option. This is hard.

Apart from confusion another problem with the current interface is
that most callers pass CodeModel::Default, which is bad since MC has
no way to map it to the target default if it actually needed to.

This patch then replaces the argument with a boolean with a default
value. The vast majority of users don't ever need to look at it. In
fact, only CodeGen and llvm-mc use it and llvm-mc just to enable more
testing.

llvm-svn: 309884
2017-08-02 20:32:26 +00:00
Dehao Chen 3246dc3df1 Fix the bug that parseAAPipeline is not invoked in runNewPMPasses in release compiler.
Summary: The logic is guarded by "assert".

Reviewers: davidxl, davide, chandlerc

Reviewed By: davide, chandlerc

Subscribers: sanjoy, llvm-commits, mehdi_amini

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

llvm-svn: 309787
2017-08-02 03:03:19 +00:00
Petr Hosek 37c052f503 Revert "Reland "[llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy""
This is failing to compile on 32-bit ARM bots.

This reverts commit r309768.

llvm-svn: 309771
2017-08-02 00:03:33 +00:00
Petr Hosek 0e60b2e777 Reland "[llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy"
This change adds the "-O binary" flag which directs llvm-objcopy to
output the object file to the same format as GNU objcopy does when given
the flag "-O binary". This was done by splitting the Object class into
two subclasses ObjectELF and ObjectBianry which each output a different
format but relay on the same code to read in the Object in Object.

Patch by Jake Ehrlich

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

llvm-svn: 309768
2017-08-01 23:46:33 +00:00
Vedant Kumar 4b102c3d5c [llvm-cov] Allow specifying distinct architectures for each loaded binary
The coverage tool needs to know which slice to look at when it's handed
a universal binary. Some projects need to look at aggregate coverage
reports for a variety of slices in different binaries: this patch adds
support for these kinds of projects to llvm-cov.

rdar://problem/33579007

llvm-svn: 309747
2017-08-01 21:23:26 +00:00
Petr Hosek 35fdbd56b7 Revert "[llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy"
The change seems to be failing on bots which are using gcc and bfd.ld
as a host compiler and linker.

This reverts commit r309658.

llvm-svn: 309660
2017-08-01 05:31:50 +00:00
Petr Hosek 8882ac2ac9 [llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy
This change adds the "-O binary" flag which directs llvm-objcopy to
output the object file to the same format as GNU objcopy does when given
the flag "-O binary". This was done by splitting the Object class into
two subclasses ObjectELF and ObjectBianry which each output a different
format but relay on the same code to read in the Object in Object.

Patch by Jake Ehrlich

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

llvm-svn: 309658
2017-08-01 05:18:30 +00:00
Petr Hosek 05a04cbedd Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things started"
As discussed on llvm-dev I've implemented the first basic steps towards
llvm-objcopy/llvm-objtool (name pending).

This change adds the ability to copy (without modification) 64-bit
little endian ELF executables that have SHT_PROGBITS, SHT_NOBITS,
SHT_NULL and SHT_STRTAB sections.

Patch by Jake Ehrlich

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

llvm-svn: 309643
2017-08-01 00:33:58 +00:00
Quentin Colombet f22c578d67 [llc][NFC] Update message in assert.
llvm-svn: 309600
2017-07-31 18:31:04 +00:00
Quentin Colombet 15f6ffbf7c [TargetPassConfig] Feature generic options to setup start/stop-after/before
This patch refactors the code used in llc such that all the users of the
addPassesToEmitFile API have access to a homogeneous way of handling
start/stop-after/before options right out of the box.

In particular, just invoking addPassesToEmitFile will set the proper
pipeline without additional effort (modulo parsing a .mir file if the
start-before/after options are used.

NFC.

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

llvm-svn: 309599
2017-07-31 18:24:07 +00:00
NAKAMURA Takumi b4b4c0ae17 [Modules] llvm-config: Exclude CMAKE_CFG_INTDIR. It isn't used in headers.
This is part of https://reviews.llvm.org/D35559

llvm-svn: 309552
2017-07-31 10:07:13 +00:00
NAKAMURA Takumi d19b960a13 gold/CMakeLists.txt: Prune (-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64).
They are handled in HandleLLVMOptions.cmake for -m32.
They are not required for -m64.

llvm-svn: 309532
2017-07-31 00:39:22 +00:00
NAKAMURA Takumi ebe04da06d Prune trailing linefeed at eof.
llvm-svn: 309531
2017-07-31 00:39:19 +00:00
David Blaikie e5adb68e04 DebugInfo: Provide option for explicitly specifying the name of the DWP file
If you've archived the DWP file somewhere it's probably useful to be
able to just tell llvm-symbolizer where it is when you're symbolizing
stack traces from the binary.

This only provides a mechanism for specifying a single DWP file, good if
you're symbolizing a program with a single DWP file, but it's likely if
the program is dynamically linked that you might have a DWP for each
dynamic library - in which case this feature won't help (at least as
it's surfaced in llvm-symbolizer for now) - in theory it could be
extended to specify a collection of DWP files that could all be
consulted for split CU hash resolution.

llvm-svn: 309498
2017-07-30 01:34:08 +00:00
Alexander Shaposhnikov e574034f28 [llvm] Update MachOObjectFile::exports interface
This diff removes the second argument of the method MachOObjectFile::exports.
In all in-tree uses this argument is equal to "this" and 
without this argument the interface seems to be cleaner.

Test plan: make check-all

llvm-svn: 309462
2017-07-29 00:30:45 +00:00
Tobias Edler von Koch 819d84032e [LTO] llvm-lto2: Add option to load sample profile
Summary:
This exposes LTO's Conf.SampleProfile as a command line option
(-lto-sample-profile-file) for testing via the llvm-lto2 utility.

Reviewers: pcc, danielcdh

Subscribers: mehdi_amini, inglorion, llvm-commits

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

llvm-svn: 309456
2017-07-28 23:43:22 +00:00
Reid Kleckner dd853e5406 [llvm-pdbutil] Clean up ExitOnError usage to add ": " to our errors
The banner parameter is supposed to end in a separator, like ": ".
Otherwise, we get ugly errors like:

Error while reading publics streamNative error: blah blah

llvm-svn: 309332
2017-07-27 23:13:18 +00:00
Petr Hosek 88ac9a8c07 Revert "Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things started""
This change is failing tests on Windows bots due to permissions.

This reverts commit r309249.

llvm-svn: 309251
2017-07-27 06:02:05 +00:00
Petr Hosek 27bcf6a680 Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things started"
As discussed on llvm-dev I've implemented the first basic steps towards
llvm-objcopy/llvm-objtool (name pending).

This change adds the ability to copy (without modification) 64-bit
little endian ELF executables that have SHT_PROGBITS, SHT_NOBITS,
SHT_NULL and SHT_STRTAB sections.

Patch by Jake Ehrlich

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

llvm-svn: 309249
2017-07-27 04:35:30 +00:00
Dehao Chen e90d0153ca Make new PM honor -fdebug-info-for-profiling
Summary: The new PM needs to invoke add-discriminator pass when building with -fdebug-info-for-profiling.

Reviewers: chandlerc, davidxl

Reviewed By: chandlerc

Subscribers: sanjoy, llvm-commits

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

llvm-svn: 309121
2017-07-26 15:01:20 +00:00
Alexander Kornienko a45648b9dd Follow up for r307085: a better fix for a dangling StringRef.
llvm-svn: 309092
2017-07-26 10:14:55 +00:00
Dehao Chen 7b05a2712a Add test coverage for new PM PGOOpt handling.
Summary: This patch adds flags and tests to cover the PGOOpt handling logic in new PM.

Reviewers: chandlerc, davide

Reviewed By: chandlerc

Subscribers: sanjoy, llvm-commits

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

llvm-svn: 309076
2017-07-26 02:00:43 +00:00