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

1054 Commits

Author SHA1 Message Date
Reid Kleckner
fe03e9f133 [codeview] Fix dumping VFTables, stop when we see LF_PAD*
Also stop visiting type records when we encounter an error.

llvm-svn: 269374
2016-05-12 22:46:41 +00:00
David Blaikie
c96658e3f3 llvm-dwp: Use llvm::Error to improve diagnostic quality/error handling in llvm-dwp
llvm-svn: 269339
2016-05-12 19:59:54 +00:00
Teresa Johnson
e31605427f [ThinLTO] Add option to emit imports files for distributed backends
Summary:
Add support for emission of plaintext lists of the imported files for
each distributed backend compilation. Used for distributed build file
staging.

Invoked with new gold-plugin thinlto-emit-imports-files option, which is
only valid with thinlto-index-only (i.e. for distributed builds), or
from llvm-lto with new -thinlto-action=emitimports value.

Depends on D19556.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

llvm-svn: 269067
2016-05-10 15:54:09 +00:00
Teresa Johnson
4147326797 Restore "[ThinLTO] Emit individual index files for distributed backends"
This restores commit r268627:
    Summary:
    When launching ThinLTO backends in a distributed build (currently
    supported in gold via the thinlto-index-only plugin option), emit
    an individual index file for each backend process as described here:
    http://lists.llvm.org/pipermail/llvm-dev/2016-April/098272.html

    ...

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

Address msan failures by avoiding std::prev on map.end(), the
theory is that this is causing issues due to some known UB problems
in __tree.

llvm-svn: 269059
2016-05-10 13:48:23 +00:00
Frederic Riss
9572f5c72f [dsymutil] Prevent use-after-free
The BinaryHolder would query the archive member MemoryBuffer name
to check if the current open archive also contains the next requested
objectfile. This comparison was using a StringRef to a temporary
buffer. It only happened with fat archives. This commit adds long-lived
storage along with the MemoryBuffers for the fat archive filename.

The added test would fail during an ASAN build without the fix.

llvm-svn: 268924
2016-05-09 14:44:14 +00:00
Frederic Riss
ca05ea2936 [dsymutil] Fix -arch option for thumb variants.
r267249 removed the dual ARM/Thumb interface from MachOObjectFile,
simplifying llvm-dsymutil's code. This unfortunately also regressed
llvm-dsymutil's ability to select thumb slices, because the simplified
code was also dealing with the discrepency between the slice arch
(eg. armv7m) and the triple arch name (eg. thumbv7m).

llvm-svn: 268894
2016-05-09 06:01:12 +00:00
Xinliang David Li
ece172beb5 [profile] Remove another unneeded field in raw profile reader
DataValueSize is now removed. The change is consolidated
with previous raw version bump.

llvm-svn: 268703
2016-05-06 02:13:00 +00:00
Vitaly Buka
a10eb05536 Revert "[ThinLTO] Emit individual index files for distributed backends"
MemorySanitizer: use-of-uninitialized-value in lib/Bitcode/Writer/BitcodeWriter.cpp:364:70
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12544/steps/check-llvm%20msan/logs/stdio

This reverts commit 0c4a898ea550699d1b2f4fe3767251c8f9a48d52.

llvm-svn: 268660
2016-05-05 18:31:00 +00:00
Teresa Johnson
960ebc706f [ThinLTO] Emit individual index files for distributed backends
Summary:
When launching ThinLTO backends in a distributed build (currently
supported in gold via the thinlto-index-only plugin option), emit
an individual index file for each backend process as described here:
http://lists.llvm.org/pipermail/llvm-dev/2016-April/098272.html

The individual index file encodes the summary and module information
required for implementing the importing/exporting decisions made
for a given module in the thin link step.
This is in place of the current mechanism that uses the combined index
to make importing decisions in each back end independently. It is an
enabler for doing global summary based optimizations in the thin link
step (which will be recorded in the individual index files), and reduces
the size of the index that must be sent to each backend process, and
the amount of work to scan it in the backends.

Rather than create entirely new ModuleSummaryIndex structures (and all
the included unique_ptrs) for each backend index file, a map is created
to record all of the GUID and summary pointers needed for a particular
index file. The IndexBitcodeWriter walks this map instead of the full
index (hiding the details of managing the appropriate summary iteration
in a new iterator subclass). This is more efficient than walking the
entire combined index and filtering out just the needed summaries during
each backend bitcode index write.

Depends on D19481.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

llvm-svn: 268627
2016-05-05 13:44:56 +00:00
Igor Kudrin
f5fc8f3eae [Coverage] Combine counts of expansion regions if there are no code regions for the same area.
Differential Revision: http://reviews.llvm.org/D18831

llvm-svn: 268620
2016-05-05 09:39:45 +00:00
Mehdi Amini
5e5633cf8a LTOCodeGenerator: add linkonce(_odr) to "llvm.compiler.used" when present in "MustPreserve" set
If the linker requested to preserve a linkonce function, we should
honor this even if we drop all uses.
We explicitely avoid turning them into weak_odr (unlike the first
version of this patch in r267644), because the codegen can be
different on Darwin: because of `llvm::canBeOmittedFromSymbolTable()`
we may emit the symbol as weak_def_can_be_hidden instead of
weak_definition.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 268607
2016-05-05 05:14:24 +00:00
Mehdi Amini
e7edfc94c8 Revert "LTOCodeGenerator: turns linkonce(_odr) into weak_(odr) when present "MustPreserve" set"
This reverts commit r267644. Turning linkonce_odr into weak_odr is
a sementic change on Darwin: because of
`llvm::canBeOmittedFromSymbolTable()` we may emit the symbol as
weak_def_can_be_hidden instead of weak_definition.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 268606
2016-05-05 05:14:20 +00:00
Xinliang David Li
3bfeece63b [Profile] Raw profile header clean up
Remove dead ValueDataBegin field in raw header.

llvm-svn: 268602
2016-05-05 04:07:30 +00:00
Simon Atanasyan
eba22b7e3c [llvm-readobj] Print MIPS .MIPS.options section content
.MIPS.options section specifies miscellaneous options to be applied
to an object file. LLVM as well as modern versions of GNU tools emit
the only type of the options - ODK_REGINFO. The patch teaches llvm-readobj
to print details of the ODK_REGINFO and skip contents of other options.

llvm-svn: 268478
2016-05-04 05:58:57 +00:00
Kevin Enderby
961a187a7a Fix llvm-size to exit with non zero when it can’t open a file.
rdar://26027819

llvm-svn: 268313
2016-05-02 21:41:03 +00:00
Frederic Riss
bf4e97e3be [dsymutil] Create the temporary files in the system temp directory.
llvm-dsymutil used to create the temporary files in the output directory.
This works fine except when the output directory contains a '%' char, which
is then replaced by llvm::sys::fs::createUniqueFile() generating an invalid
path.
Just use the default temp dir for those files.

llvm-svn: 268304
2016-05-02 21:06:14 +00:00
Davide Italiano
92ff603010 [llvm-readobj] Dump hash as part of -version-info.
llvm-svn: 268210
2016-05-02 02:30:18 +00:00
Vedant Kumar
37bef9dfdc [llvm-cov] Don't emit 'nan%' in reports
llvm-svn: 267971
2016-04-29 01:31:49 +00:00
Kevin Enderby
211d6a827a Fix a bug in llvm-objdump for -private-headers printing the LC_CODE_SIGNATURE Mach-O load command.
rdar://25985653

llvm-svn: 267940
2016-04-28 21:07:20 +00:00
Kevin Enderby
57a8fdd741 Update llvm-objdump for disassembly of ARM Mach-O files to always include the opcode bytes.
As this is the expected behavior of the old darwin otool(1) for ARM Mach-O files.

rdar://25896249

llvm-svn: 267929
2016-04-28 20:14:13 +00:00
Kevin Enderby
b798753bdb Fix bugs in llvm-objdump printing the last word for -section in non i386 and x86 files.
Two problems, 1) for the last 4 bytes it would print them as separate bytes not a word
and 2) it would print the same last byte for those bytes less than a word.

rdar://25938224

llvm-svn: 267819
2016-04-27 23:43:00 +00:00
Kevin Enderby
41f6b232d1 Fix a bug in llvm-objdump printing of 32-bit addresses for -section in non i386 and x86 files.
rdar://25896202

llvm-svn: 267807
2016-04-27 22:36:18 +00:00
Kevin Enderby
3c1e719ae1 Add a test case for the crash fixed with r267037. David Blaikie said it would be nice to have!
This was crashing llvm-objdump with -macho -objc-meta-data when trying dump a non-existent section.
So the test binary is simply created from an empty .s file compiled with: clang -arch armv7 empty.s -c

llvm-svn: 267782
2016-04-27 20:37:06 +00:00
Reid Kleckner
d8e7f2f768 [PDB] Fix function names for private symbols in PDBs
Summary:
llvm-symbolizer wants to get linkage names of functions for historical
reasons. Linkage names are only recorded in the PDB for public symbols,
and the linkage name is apparently stored separately in some "public
symbol" record. We had a workaround in PDBContext which would look for
such symbols when the user requested linkage names.

However, when given an address that was truly in a private function and
public funciton, we would accidentally find nearby public symbols and
return those function names. The fix is to look for both function
symbols and public symbols and only prefer the public symbol name if the
addresses of the symbols agree.

Fixes PR27492

Reviewers: zturner

Subscribers: llvm-commits

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

llvm-svn: 267732
2016-04-27 16:10:29 +00:00
Kristof Beyls
28b8dc2f09 Remove size 1 from check as that isn't part of what the test is meant to be testing.
This test also runs on e.g. ARM-native builds when the X86 backend is also
built.  This test produces code for the default instruction set, even though it
is in a "X86" sub-directory. Given that this test doesn't seem to be testing
anything architecture-specific, it seems it's best to adapt the check to not
check for an architecture-dependent value (the size of the function), rather
than hard-code the test to target x86.

llvm-svn: 267722
2016-04-27 15:03:09 +00:00
Teresa Johnson
1ec75cc513 [ThinLTO] Use valueid instead of bitcode offsets in combined index file
Summary:
With the removal of support for lazy parsing of combined index summary
records (e.g. r267344), we no longer need to include the summary record
bitcode offset in the VST entries for definitions. Change the combined
index format to be similar to the per-module index format in using value
ids to cross-reference from the summary record to the VST entry (rather
than the summary record bitcode offset to cross-reference in the other
direction).

The visible changes are:
1) Add the value id to the combined summary records
2) Remove the summary offset from the combined VST records, which has
the following effects:
- No longer need the VST_CODE_COMBINED_GVDEFENTRY record, as all
  combined index VST entries now only contain the value id and
  corresponding GUID.
- No longer have duplicate VST entries in the case where there are
  multiple definitions of a symbol (e.g. weak/linkonce), as they all
  have the same value id and GUID.

An implication of #2 above is that in order to hook up an alias to the
correct aliasee based on the value id of the aliasee recorded in the
combined index alias record, we need to scan the entries in the index
for that GUID to find the one from the same module (i.e. the case where
there are multiple entries for the aliasee). But the reader no longer
has to maintain a special map to hook up the alias/aliasee.

Reviewers: joker.eph

Subscribers: joker.eph, llvm-commits

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

llvm-svn: 267712
2016-04-27 13:28:35 +00:00
Mehdi Amini
01648c823a LTOCodeGenerator: turns linkonce(_odr) into weak_(odr) when present "MustPreserve" set
Summary:
If the linker requested to preserve a linkonce function, we should
honor this even if we drop all uses.

Reviewers: dexonsmith

Subscribers: llvm-commits, joker.eph

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 267644
2016-04-27 00:32:02 +00:00
Evgeniy Stepanov
1e42bd82e8 [gold] Fix linkInModule and extend common.ll test.
Fix early exit from linkInModule. IRMover::move returns false on
success and true on error.

Add a few more cases of merged common linkage variables with
different sizes and alignments.

llvm-svn: 267437
2016-04-25 18:23:29 +00:00
Adrian Prantl
5d07243529 dsymutil: Only warn about clang module DWO id mismatches in verbose mode.
Until PR27449 (https://llvm.org/bugs/show_bug.cgi?id=27449) is fixed in
clang this warning is pointless, since ASTFileSignatures will change
randomly when a module is rebuilt.

rdar://problem/25610919

llvm-svn: 267427
2016-04-25 17:04:32 +00:00
Igor Kudrin
7e40f64026 [Coverage] Restore the correct count value after processing a nested region in case of combined regions.
If several regions cover the same area of code, we have to restore
the combined value for that area when return from a nested region.

This patch achieves that by combining regions before calling buildSegments.

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

llvm-svn: 267390
2016-04-25 09:43:37 +00:00
Rafael Espindola
feeb4744f9 Also check the IR.
llvm-svn: 267367
2016-04-24 21:42:56 +00:00
Rafael Espindola
5305051507 Add a test for how we handle protected visibility.
llvm-svn: 267366
2016-04-24 21:30:18 +00:00
NAKAMURA Takumi
013ddcd61c llvm/test/tools/gold/X86/thinlto.ll: Possible fix corresponding to r267318.
llvm-svn: 267334
2016-04-24 08:02:00 +00:00
Mehdi Amini
e000bb6ae8 Add a version field in the bitcode for the summary
Differential Revision: http://reviews.llvm.org/D19456

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 267318
2016-04-24 03:18:11 +00:00
Teresa Johnson
d9e21e2b3b [gold] Gate value name discarding under save-temps
Summary:
This removes a couple of flags added to control this behavior, and
simply keeps all value names when save-temps is specified.

Reviewers: rafael

Subscribers: llvm-commits, pcc, davide

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

llvm-svn: 267279
2016-04-23 05:15:59 +00:00
Tim Northover
2b39bb5c9b llvm-objdump: deal with invalid ARM encodings slightly better.
Before we printed a warning to stderr and left the actual output stream in a
mess. This tries to print a .long or .short representation of what we saw (as
if there was a data-in-code directive).

This isn't guaranteed to restore synchronization in Thumb-mode (if the invalid
instruction was supposed to be 32-bits, we may be off-by-16 for the rest of the
function). But there's no certain way to deal with that, and it's invalid code
anyway (if the data really wasn't an instruction, the user can add proper
.data_in_code directives if they care)

llvm-svn: 267250
2016-04-22 23:23:31 +00:00
Tim Northover
5cc375dd3c MachO: remove weird ARM/Thumb interface from MachOObjectFile
Only one consumer (llvm-objdump) actually cared about the fact that there were
two triples. Others were actively working around the fact that the Triple
returned by getArch might have been invalid. As for llvm-objdump, it needs to
be acutely aware of both Triples anyway, so being generic in the exposed API is
no benefit.

Also rename the version of getArch returning a Triple. Users were having to
pass an unwanted nullptr to disambiguate the two, which was nasty.

The only functional change here is that armv7m and armv7em object files no
longer crash llvm-objdump.

llvm-svn: 267249
2016-04-22 23:21:13 +00:00
Mike Aizatsky
27db5e9a0c [sancov] using normalized filenames for blacklist checks.
Differential Revision: http://reviews.llvm.org/D19395

llvm-svn: 267078
2016-04-21 23:38:45 +00:00
Teresa Johnson
ff13fea2b3 Re-enable "[gold-plugin] Disable name for values other than GlobalValue"
This restores r266871 with a fix for gold tests relying on the value
names, when using a release compiler, by adding a way to disable the
default discarding. Update affected tests to use the new mechanism so
that value names are preserved as expected, regardless of how the
compiler was built.

llvm-svn: 266881
2016-04-20 15:16:57 +00:00
Teresa Johnson
9f8bde4940 Revert "[gold-plugin] Disable name for values other than GlobalValue"
This reverts commit r266871. Setting the default based on the NDEBUG
flag is causing test failures. Need to figure out whether to change this
approach or update tests.

llvm-svn: 266872
2016-04-20 13:18:47 +00:00
Teresa Johnson
485edc2952 [gold-plugin] Disable name for values other than GlobalValue
Summary:
Applies Mehdi's optimization (r263086) to disable value names other than
for GlobalValues to LTO/ThinLTO performed via the gold-plugin, in the
same manner as it is applied in libLTO.

Reviewers: rafael, joker-eph

Subscribers: llvm-commits

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

llvm-svn: 266871
2016-04-20 13:01:37 +00:00
Mandeep Singh Grang
28ddad394b [LLVM] Remove unwanted --check-prefix=CHECK from unit tests. NFC.
Summary: Removed unwanted --check-prefix=CHECK from numerous unit tests.

Reviewers: t.p.northover, dblaikie, uweigand, MatzeB, tstellarAMD, mcrosier

Subscribers: mcrosier, dsanders

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

llvm-svn: 266834
2016-04-19 23:51:52 +00:00
Mehdi Amini
f24757c4b7 Fix Gold test after r266750 (ModuleLinker: Do not import linkonce/weak as "external_weak")
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266752
2016-04-19 16:21:37 +00:00
Igor Kudrin
32058f8126 Reapply "[Coverage] Prevent detection of false instantiations in case of macro expansion."
The root of the problem was that findMainViewFileID(File, Function)
could return some ID for any given file, even though that file
was not the main file for that function.

This patch ensures that the result of this function is conformed
with the result of findMainViewFileID(Function).

This commit reapplies r266436, which was reverted by r266458,
with the .covmapping file serialized in v1 format.

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

llvm-svn: 266620
2016-04-18 15:36:30 +00:00
Igor Kudrin
6d8bf78f13 Revert "[Coverage] Prevent detection of false instantiations in case of macro expansion."
This reverts commit r266436 as it broke buildbot.

llvm-svn: 266458
2016-04-15 17:53:48 +00:00
Adrian Prantl
fb3abba237 [PR27284] Reverse the ownership between DICompileUnit and DISubprogram.
Currently each Function points to a DISubprogram and DISubprogram has a
scope field. For member functions the scope is a DICompositeType. DIScopes
point to the DICompileUnit to facilitate type uniquing.

Distinct DISubprograms (with isDefinition: true) are not part of the type
hierarchy and cannot be uniqued. This change removes the subprograms
list from DICompileUnit and instead adds a pointer to the owning compile
unit to distinct DISubprograms. This would make it easy for ThinLTO to
strip unneeded DISubprograms and their transitively referenced debug info.

Motivation
----------

Materializing DISubprograms is currently the most expensive operation when
doing a ThinLTO build of clang.

We want the DISubprogram to be stored in a separate Bitcode block (or the
same block as the function body) so we can avoid having to expensively
deserialize all DISubprograms together with the global metadata. If a
function has been inlined into another subprogram we need to store a
reference the block containing the inlined subprogram.

Attached to https://llvm.org/bugs/show_bug.cgi?id=27284 is a python script
that updates LLVM IR testcases to the new format.

http://reviews.llvm.org/D19034
<rdar://problem/25256815>

llvm-svn: 266446
2016-04-15 15:57:41 +00:00
Igor Kudrin
4f06b09bd9 [Coverage] Prevent detection of false instantiations in case of macro expansion.
The root of the problem was that findMainViewFileID(File, Function)
could return some ID for any given file, even though that file
was not the main file for that function.

This patch ensures that the result of this function is conformed
with the result of findMainViewFileID(Function).

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

llvm-svn: 266436
2016-04-15 14:56:50 +00:00
Mehdi Amini
03a2cdacee Move summary creation out of llvm-as into opt
Summary:
Let keep llvm-as "dumb": it converts textual IR to bitcode. This
commit removes the dependency from llvm-as to libLLVMAnalysis.
We'll add back summary in llvm-as if we get to a textual
representation for it at some point. In the meantime, opt seems
like a better place for that.

Reviewers: tejohnson

Subscribers: joker.eph, llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266131
2016-04-12 21:35:18 +00:00
Hemant Kulkarni
6e8f9c1c5f [llvm-readobj] Add ELF hash histogram printing
Differential Revision: http://reviews.llvm.org/D18907

llvm-svn: 265967
2016-04-11 17:15:30 +00:00
Colin LeMahieu
ed62b97b18 Revert r265817
lld tests need to be addressed.

llvm-svn: 265822
2016-04-08 18:15:37 +00:00
Colin LeMahieu
eaba356a61 [llvm-objdump] Printing hex instead of dec by default
Differential Revision: http://reviews.llvm.org/D18770

llvm-svn: 265817
2016-04-08 17:55:03 +00:00
Kevin Enderby
a6534d0295 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.

llvm-svn: 265606
2016-04-06 22:14:09 +00:00
Evgeniy Stepanov
b733622b8b [gold] Save bitcode for module partitions (save-temps + split codegen).
llvm-svn: 265583
2016-04-06 18:32:13 +00:00
David Blaikie
864a44e979 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)

llvm-svn: 265457
2016-04-05 20:26:50 +00:00
David Blaikie
fdb380b214 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.

llvm-svn: 265452
2016-04-05 20:16:38 +00:00
Adrian Prantl
1653aa9f14 testcase gardening: update the emissionKind enum to the new syntax. (NFC)
llvm-svn: 265081
2016-04-01 00:16:49 +00:00
Evgeniy Stepanov
5fe6dfe713 Preserve blockaddress use edges in the module splitter.
"blockaddress" can not apply to an external function. All
blockaddress constant uses must belong to the same module as the
definition of the target function.

llvm-svn: 265061
2016-03-31 21:55:11 +00:00
Evgeniy Stepanov
e383f522a4 Preserve extern_weak linkage in CloneModule.
Only force "extern" linkage if the function used to be a definition
in the source module. Declarations keep their original linkage.

llvm-svn: 265043
2016-03-31 20:21:31 +00:00
Kevin Enderby
3a6cb0f262 Fix some bugs in the posix output of llvm-nm. Which is documented on
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/nm.html .

1) For Mach-O files the code was not printing the values in hex as is the default.
2) The values printed had leading zeros which they should not have.
3) The address for undefined symbols was printed as spaces instead of 0.
4) With the -A option with posix output for an archive did not use square
brackets around the archive member name.

rdar://25311883 and rdar://25299678

llvm-svn: 264778
2016-03-29 20:18:07 +00:00
Vedant Kumar
c7131e8b97 [Coverage] Fix the expected counts in instrprof-comdat.h
llvm-svn: 264675
2016-03-28 22:10:40 +00:00
Evgeniy Stepanov
730f156c56 Remove personality for declarations in CloneModule.
Personality is copied as part of copyFunctionAttributes, but it is
invalid on a declaration. Remove the personality attribute it the
function body is not cloned.

Also add a verifier run over output modules in the llvm-split tool.

llvm-svn: 264667
2016-03-28 21:37:02 +00:00
Vedant Kumar
24844831b5 Reapply (2x) "[PGO] Fix name encoding for ObjC-like functions"
Function names in ObjC can have spaces in them. This interacts poorly
with name compression, which uses spaces to separate PGO names. Fix the
issue by using a different separator and update a test.

I chose "\01" as the separator because 1) it's non-printable, 2) we
strip it from PGO names, and 3) it's the next natural choice once "\00"
is discarded (that one's overloaded).

What's changed since the original commit?

- I fixed up the covmap-V2 binary format tests using a linux VM.
- I weakened the CHECK lines in instrprof-comdat.h to account for the
  fact that there have been bugfixes to clang coverage. These will be
  fixed up in a follow-up.
- I added an assert to make sure we don't get bitten by this again.
- I constructed the c-general.profraw file without name compression
  enabled to appease some bots.

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

llvm-svn: 264658
2016-03-28 21:06:42 +00:00
Vedant Kumar
ef4c4640e2 Revert "Reapply "[PGO] Fix name encoding for ObjC-like functions""
This reverts commit r264641 to investigate why c-general.test is failing
on the bots.

llvm-svn: 264643
2016-03-28 20:20:40 +00:00
Vedant Kumar
7d48607b4b Reapply "[PGO] Fix name encoding for ObjC-like functions"
Function names in ObjC can have spaces in them. This interacts poorly
with name compression, which uses spaces to separate PGO names. Fix the
issue by using a different separator and update a test.

I chose "\01" as the separator because 1) it's non-printable, 2) we
strip it from PGO names, and 3) it's the next natural choice once "\00"
is discarded (that one's overloaded).

This reverts the revert commit beaf3d18. What's changed?

- I fixed up the covmap-V2 binary format tests using a linux VM.
- I updated the expected counts in instrprof-comdat.h to account for
  the fact that there have been bugfixes to clang coverage.
- I added an assert to make sure we don't get bitten by this again.

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

llvm-svn: 264641
2016-03-28 20:12:07 +00:00
Hemant Kulkarni
89e38a8027 [llvm-size] Implement --common option
Differential Revision: http://reviews.llvm.org/D16820

llvm-svn: 264591
2016-03-28 16:48:10 +00:00
David Blaikie
8f12838248 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.

llvm-svn: 264520
2016-03-26 20:32:14 +00:00
Richard Smith
5a858ce8f1 Stop testing the unspecified order in which the OnDiskHashTable stores entries.
llvm-svn: 264487
2016-03-26 02:02:59 +00:00
Hemant Kulkarni
8b63e79e81 [llvm-readobj] Impl GNU style program headers print
readelf -lW

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

llvm-svn: 264415
2016-03-25 16:04:48 +00:00
David Blaikie
0feb27005d 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.

llvm-svn: 264350
2016-03-24 22:17:08 +00:00
Mike Aizatsky
3edddc591b [sancov] renaming statistics fields.
llvm-svn: 264349
2016-03-24 21:49:55 +00:00
Rafael Espindola
f2350e6ece Fix gold tests for llvm-readobj format change.
llvm-svn: 264306
2016-03-24 16:45:41 +00:00
Simon Atanasyan
a5a68b8d26 [llvm-readobj] Decode st_other symbol's flags
The patch supports common STV_xxx visibility flags and MIPS specific
STO_MIPS_xxx flags.

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

llvm-svn: 264300
2016-03-24 16:10:37 +00:00
James Molloy
cfba21c833 [llvm-nm] Correct -P ELF output
Correctly add a space between the address and size when outputting in posix mode (-P).

llvm-svn: 264247
2016-03-24 09:18:09 +00:00
Mike Aizatsky
09a14f0340 [sancov] -print-coverage-stats option to print various coverage statistics.
Differential Revision: http://reviews.llvm.org/D18418

llvm-svn: 264222
2016-03-24 00:00:08 +00:00
Rafael Espindola
e66d2ebd4e Revert "[llvm-objdump] Printing relocations in executable and shared object files. This partially reverts r215844 by removing test objdump-reloc-shared.test which stated GNU objdump doesn't print relocations, it does."
This reverts commit r263971.
It produces the wrong results for .rela.dyn. I will add a test.

llvm-svn: 263987
2016-03-21 20:59:15 +00:00
Colin LeMahieu
e744635d27 [llvm-objdump] Printing relocations in executable and shared object files. This partially reverts r215844 by removing test objdump-reloc-shared.test which stated GNU objdump doesn't print relocations, it does.
In executable and shared object ELF files, relocations in the file contain the final virtual address rather than section offset so this is adjusted to display section offset.

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

llvm-svn: 263971
2016-03-21 19:14:50 +00:00
Hemant Kulkarni
863937f139 [llvm-readobj] Impl GNU style symbols printing
Implements "readelf -sW and readelf -DsW"

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

llvm-svn: 263952
2016-03-21 17:18:23 +00:00
Mehdi Amini
ae08bbd16d Add a test for r263577: "Add missing error handling in llvm-lto"
On Rafael's suggestion!
(also fix a discrepancy between this error message format and the others)

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 263860
2016-03-19 00:17:32 +00:00
Simon Atanasyan
b6706f5d72 [llvm-objdump] Move test case to the X86 sub-directory because it depends on X86 target supporting. NFC.
llvm-svn: 263781
2016-03-18 09:52:12 +00:00
Simon Atanasyan
efe48d8197 [llvm-objdump] Add REQUIRES x86 directive to fix buildbots
llvm-svn: 263708
2016-03-17 11:09:21 +00:00
Simon Atanasyan
fbf5381724 [llvm-objdump] Add '0x' prefix to a target displacement number to accent its hex format
It might be hard to recognize a hexadecimal number without '0x' prefix.
Besides that '0x' prefix corresponds to GNU objdump behaviour.

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

llvm-svn: 263705
2016-03-17 10:43:44 +00:00
Hemant Kulkarni
46e5dcc160 [llvm-readobj] Impl GNU style printing of sections and relocations
Differential Revision: http://reviews.llvm.org/D17523

llvm-svn: 263561
2016-03-15 17:25:31 +00:00
David Majnemer
227230fb16 [llvm-objdump] Add support for dumping the PE TLS directory
The PE TLS directory contains information about where the TLS data
resides in the image, what functions should be executed when threads are
created, etc.

llvm-svn: 263537
2016-03-15 06:14:01 +00:00
Teresa Johnson
89e5e1dadb [ThinLTO] Renaming of function index to module summary index (NFC)
(Resubmitting after fixing missing file issue)

With the changes in r263275, there are now more than just functions in
the summary. Completed the renaming of data structures (started in
r263275) to reflect the wider scope. In particular, changed the
FunctionIndex* data structures to ModuleIndex*, and renamed related
variables and comments. Also renamed the files to reflect the changes.

A companion clang patch will immediately succeed this patch to reflect
this renaming.

llvm-svn: 263513
2016-03-15 00:04:37 +00:00
Teresa Johnson
6632706d71 Revert "[ThinLTO] Renaming of function index to module summary index (NFC)"
This reverts commit r263490. Missed a file.

llvm-svn: 263493
2016-03-14 21:18:10 +00:00
Teresa Johnson
7f5c7bac22 [ThinLTO] Renaming of function index to module summary index (NFC)
With the changes in r263275, there are now more than just functions in
the summary. Completed the renaming of data structures (started in
r263275) to reflect the wider scope. In particular, changed the
FunctionIndex* data structures to ModuleIndex*, and renamed related
variables and comments. Also renamed the files to reflect the changes.

A companion clang patch will immediately succeed this patch to reflect
this renaming.

llvm-svn: 263490
2016-03-14 21:05:56 +00:00
Mike Aizatsky
ef7178d5f3 [sancov] using md5 for anchors in attempt to reduce file size.
Differential Revision: http://reviews.llvm.org/D18102

llvm-svn: 263308
2016-03-11 23:28:28 +00:00
Teresa Johnson
e1affa2f8c [ThinLTO] Support for reference graph in per-module and combined summary.
Summary:
This patch adds support for including a full reference graph including
call graph edges and other GV references in the summary.

The reference graph edges can be used to make importing decisions
without materializing any source modules, can be used in the plugin
to make file staging decisions for distributed build systems, and is
expected to have other uses.

The call graph edges are recorded in each function summary in the
bitcode via a list of <CalleeValueIds, StaticCount> tuples when no PGO
data exists, or <CalleeValueId, StaticCount, ProfileCount> pairs when
there is PGO, where the ValueId can be mapped to the function GUID via
the ValueSymbolTable. In the function index in memory, the call graph
edges reference the target via the CalleeGUID instead of the
CalleeValueId.

The reference graph edges are recorded in each summary record with a
list of referenced value IDs, which can be mapped to value GUID via the
ValueSymbolTable.

Addtionally, a new summary record type is added to record references
from global variable initializers. A number of bitcode records and data
structures have been renamed to reflect the newly expanded scope of the
summary beyond functions. More cleanup will follow.

Reviewers: joker.eph, davidxl

Subscribers: joker.eph, llvm-commits

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

llvm-svn: 263275
2016-03-11 18:52:24 +00:00
Evgeniy Stepanov
b83b93bff0 [gold] Fix common symbols handling.
LLVM Gold plugin decides which instance of a common symbol it wants
based on the symbol size in claim_file_hook. If the file that
contains the chosen instance is later dropped from the link, we end
up with an undefined reference.

This change delays this decision until the set of the included files
is known.

llvm-svn: 263180
2016-03-11 00:51:57 +00:00
Hemant Kulkarni
d5ee8e8e81 [llvm-readobj] Enable GNU style section group print
Differential Revision: http://reviews.llvm.org/D17822

llvm-svn: 263050
2016-03-09 19:16:13 +00:00
Teresa Johnson
904406f866 Fix new gold test to specify emulation mode.
The thinlto_linkonceresolution.ll gold linker test introduced in r262727
included a target triple, but didn't set the emulation mode, which is
necessary since the default linker target may be different.

Patch by H.J. Lu

llvm-svn: 262745
2016-03-04 21:19:08 +00:00
Teresa Johnson
215f45b06e [ThinLTO] Ensure prevailing linkonce emitted as weak in ThinLTO backends
Summary:
Since IR files are all compiled into separate independent object files
in ThinLTO mode, the prevailing linkonce symbols must be emitted in its
object file even if it is no longer referenced there, e.g. if no
references remain in the module after inlining, since it may be
referenced by another ThinLTO compiled object file. This is done by
changing LDPR_PREVAILING_DEF_IRONLY* symbols to LDPR_PREVAILING_DEF,
which converts the prevailing linkonce to weak. We also don't need the
other prevailing IRONLY handling for internalization, which is not
currently performed for ThinLTO.

Test case included.

Reviewers: davidxl, rafael

Subscribers: rafael, joker.eph, llvm-commits

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

llvm-svn: 262727
2016-03-04 17:48:35 +00:00
Teresa Johnson
b00a3e6034 [ThinLTO] Launch importing backends in parallel threads from gold plugin
Summary:
Launch ThinLTO backends (LTO and codegen pipelines with importing) in
parallel using a ThreadPool, after creating the combined index.
The number of threads is controlled by the existing -jobs gold plugin
option, or the hardware concurrency if not specified.

The old behavior of exiting after creating the combined index can be
invoked via a new thinlto-index-only plugin option.

This commit involves just the ThinLTO-specific pieces of D15390, the NFC
and other restructuring pieces were committed independently:
  r262677: Add hardware_concurrency interface to llvm::thread (NFC)
  r262719: Change split code gen to use ThreadPool
  r262721: Refactor gold-plugin codegen to prepare for ThinLTO threads (NFC)

Reviewers: pcc, joker.eph, rafael

Subscribers: rafael, davidxl, llvm-commits, joker.eph

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

llvm-svn: 262724
2016-03-04 17:06:02 +00:00
Jacques Pienaar
ea54ef2b77 [lanai] Add ELF enum value and relocations.
Add ELF enum value and relocations for Lanai backed.

General Lanai backend discussion on llvm-dev thread "[RFC] Lanai backend" (http://lists.llvm.org/pipermail/llvm-dev/2016-February/095118.html).

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

llvm-svn: 262394
2016-03-01 21:21:42 +00:00
Simon Atanasyan
1c312f2b01 [DebugInfo] Dump CIE augmentation data as a list of hex bytes
CIE augmentation data might contain non-printable characters.
The patch prints the data as a list of hex bytes.

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

llvm-svn: 262361
2016-03-01 18:38:05 +00:00
Petr Pavlu
324853823b [LTO] Fix error reporting from lto_module_create_in_local_context()
Function lto_module_create_in_local_context() would previously
rely on the default LLVMContext being created for it by
LTOModule::makeLTOModule(). This context exits the program on
error and is not arranged to update sLastStringError in
tools/lto/lto.cpp.

Function lto_module_create_in_local_context() now creates an
LLVMContext by itself, sets it up correctly to its needs and then
passes it to LTOModule::createInLocalContext() which takes
ownership of the context and keeps it present for the lifetime of
the returned LTOModule.

Function LTOModule::makeLTOModule() is modified to take a
reference to LLVMContext (instead of a pointer) and no longer
creates a default context when nullptr is passed to it. Method
LTOModule::createInContext() that takes a pointer to LLVMContext
is removed because it allows to pass a nullptr to it. Instead
LTOModule::createFromBuffer() (that takes a reference to
LLVMContext) should be used.

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

llvm-svn: 262330
2016-03-01 13:13:49 +00:00
Mike Aizatsky
82adfc84dc [sancov] print_coverage_points command.
Differential Revision: http://reviews.llvm.org/D17670

llvm-svn: 262104
2016-02-27 02:21:44 +00:00
Paul Robinson
119632fa81 Fix tests that used CHECK-NEXT-NOT and CHECK-DAG-NOT.
FileCheck actually doesn't support combo suffixes.

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

llvm-svn: 262054
2016-02-26 19:40:34 +00:00
David Blaikie
f8f826e596 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.

llvm-svn: 261988
2016-02-26 07:30:15 +00:00
David Blaikie
97ae473a6b 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.

llvm-svn: 261987
2016-02-26 07:04:58 +00:00
Hemant Kulkarni
4d7cb7c1de Reverts change r261907 and r261918
llvm-svn: 261927
2016-02-25 20:47:07 +00:00
Hemant Kulkarni
616aef8e81 [llvm-readobj] Enable GNU style sections and relocations printing
http://reviews.llvm.org/D17523

llvm-svn: 261907
2016-02-25 18:02:00 +00:00
NAKAMURA Takumi
26ceb67a9c Revert r260064, "Disable llvm/test/tools/llvm-profdata/value-prof.proftext on win32 for now. Investigating."
It seems unreproducible any more for me.

llvm-svn: 261842
2016-02-25 08:50:26 +00:00
David Blaikie
0051e7eb36 llvm-dwp: Don't test compression when zlib isn't available
llvm-svn: 261298
2016-02-19 02:03:45 +00:00
David Blaikie
f4edf4b3fe llvm-dwp: Support compressed input
llvm-svn: 261296
2016-02-19 01:51:44 +00:00
David Blaikie
8c7405f20a llvm-dwp: Support for type units when merging DWPs into larger DWPs
llvm-svn: 261072
2016-02-17 07:00:24 +00:00
Adam Nemet
f3d8c27701 Fix test from r261013
llvm-svn: 261027
2016-02-16 22:50:19 +00:00
Adam Nemet
e39424112f [LTO] Support Statistics
Summary:
I thought -Xlinker -mllvm -Xlinker -stats worked at some point but maybe
it never did.

For clang, I believe that stats are printed from cc1_main.  This patch
also prints them for LTO, specifically right after codegen happens.

I only looked at the C API for LTO briefly to see if this is a good
place.  Probably there are still cases where this wouldn't be printed
but it seems to be working for the common case.  I also experimented
putting this in the LTOCodeGenerator destructor but that didn't trigger
for me because ld64 does not destroy the LTOCodeGenerator.

Reviewers: dexonsmith, joker.eph

Subscribers: rafael, joker.eph, llvm-commits

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

llvm-svn: 261013
2016-02-16 21:41:51 +00:00
Rafael Espindola
5c95668155 This reverts commit r260488 and r260489.
Original messages:
    Revert "[readobj] Handle ELF files with no section table or with no program headers."
    Revert "[readobj] Dump DT_JMPREL relocations when outputting dynamic relocations."

r260489 depends on r260488 and among other issues r260488 deleted error
handling code.

llvm-svn: 260962
2016-02-16 14:17:48 +00:00
NAKAMURA Takumi
edec212b66 Make llvm/test/tools/llvm-symbolizer/pdb/pdb.test Py3-compatible.
llvm-svn: 260887
2016-02-15 13:19:13 +00:00
Davide Italiano
e227c6b3fe [llvm-size] Make error handling uniform.
llvm-svn: 260786
2016-02-13 01:38:16 +00:00
Mike Aizatsky
9bd27f7534 [sancov] improved object files handling.
Multi-dso programs result in multiple coverage files dumped of the form
'<module_name>.<pid>.sancov'. When analyzing these coverage files it is
important to use correct corresponding object file.

This change removes the "-obj" sancov flag and lets user specify object
file names alongside coverage files. Sancov tool would match them using
<module_name> part of coverage file and short file name of the object
file.

Corresponding changes:
- compiler-rt: http://reviews.llvm.org/D17171
- docs: http://reviews.llvm.org/D17175

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

llvm-svn: 260628
2016-02-12 00:29:07 +00:00
Michael J. Spencer
e7d9c3a84d [readobj] Dump DT_JMPREL relocations when outputting dynamic relocations.
llvm-svn: 260489
2016-02-11 04:59:53 +00:00
Michael J. Spencer
4b64c43150 [readobj] Handle ELF files with no section table or with no program headers.
This adds support for finding the dynamic table and dynamic symbol table via
the section table or the program header table. If there's no section table an
attempt is made to figure out the length of the dynamic symbol table.

llvm-svn: 260488
2016-02-11 04:59:45 +00:00
Hemant Kulkarni
bac539b6a6 Make llvm-nm test consistent with other tests
llvm-svn: 260464
2016-02-10 23:28:43 +00:00
Xinliang David Li
e8b540f343 Fix buildbot failure (hosts without zlib)
llvm-svn: 260446
2016-02-10 22:05:41 +00:00
Teresa Johnson
c47e95e1b1 Restore "[ThinLTO] Use MD5 hash in function index." with fix
This restores commit r260408, along with a fix for a bot failure.

The bot failure was caused by dereferencing a unique_ptr in the same
call instruction parameter list where it was passed via std::move.
Apparently due to luck this was not exposed when I built the compiler
with clang, only with gcc.

llvm-svn: 260442
2016-02-10 21:55:02 +00:00
Hemant Kulkarni
2e703c67d0 [llvm-readobj] Option to emit readelf like output
New option --elf-output-style=LLVM or GNU
Enables -file-headers in readelf style when elf-output-style=GNU

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

llvm-svn: 260430
2016-02-10 20:40:55 +00:00
Xinliang David Li
3e7ea000e2 [Coverage] add covmap v2 binary format regression test
llvm-svn: 260428
2016-02-10 20:14:04 +00:00
Teresa Johnson
02e161e44f Revert "[ThinLTO] Use MD5 hash in function index." due to bot failure
This reverts commit r260408. Bot failure that I need to investigate.

llvm-svn: 260412
2016-02-10 19:11:15 +00:00
Teresa Johnson
b1e839beb3 [ThinLTO] Use MD5 hash in function index.
Summary:
This patch uses the lower 64-bits of the MD5 hash of a function name as
a GUID in the function index, instead of storing function names. Any
local functions are first given a global name by prepending the original
source file name. This is the same naming scheme and GUID used by PGO in
the indexed profile format.

This change has a couple of benefits. The primary benefit is size
reduction in the combined index file, for example 483.xalancbmk's
combined index file was reduced by around 70%. It should also result in
memory savings for the index file in memory, as the in-memory map is
also indexed by the hash instead of the string.

Second, this enables integration with indirect call promotion, since the
indirect call profile targets are recorded using the same global naming
convention and hash. This will enable the function importer to easily
locate function summaries for indirect call profile targets to enable
their import and subsequent promotion.

The original source file name is recorded in the bitcode in a new
module-level record for use in the ThinLTO backend pipeline.

Reviewers: davidxl, joker.eph

Subscribers: llvm-commits, joker.eph

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

llvm-svn: 260408
2016-02-10 18:57:54 +00:00
Hemant Kulkarni
7bee7c2cd0 Revert "[llvm-readobj] Option to emit readelf like output"
This reverts commit a58765909660a7195b32e0cc8c7476168b913750.

llvm-svn: 260397
2016-02-10 18:21:01 +00:00
Hemant Kulkarni
bb26477ebd [llvm-nm] Add -radix option
Differential Revision: http://reviews.llvm.org/D16822

llvm-svn: 260392
2016-02-10 17:51:39 +00:00
Hemant Kulkarni
212037f7cf [llvm-readobj] Option to emit readelf like output
New option --elf-output-style=LLVM or GNU
Enables -file-headers in readelf style when elf-output-style=GNU

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

llvm-svn: 260391
2016-02-10 17:51:28 +00:00
Ehsan Akhgari
e16e097859 Disable all llvm-config tests for now, will investigate later
llvm-svn: 260386
2016-02-10 17:29:50 +00:00
Peter Collingbourne
54e8749794 WholeProgramDevirt: introduce.
This pass implements whole program optimization of virtual calls in cases
where we know (via bitset information) that the list of callees is fixed. This
includes the following:

- Single implementation devirtualization: if a virtual call has a single
  possible callee, replace all calls with a direct call to that callee.

- Virtual constant propagation: if the virtual function's return type is an
  integer <=64 bits and all possible callees are readnone, for each class and
  each list of constant arguments: evaluate the function, store the return
  value alongside the virtual table, and rewrite each virtual call as a load
  from the virtual table.

- Uniform return value optimization: if the conditions for virtual constant
  propagation hold and each function returns the same constant value, replace
  each virtual call with that constant.

- Unique return value optimization for i1 return values: if the conditions
  for virtual constant propagation hold and a single vtable's function
  returns 0, or a single vtable's function returns 1, replace each virtual
  call with a comparison of the vptr against that vtable's address.

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

llvm-svn: 260312
2016-02-09 22:50:34 +00:00
Rafael Espindola
f2a7a6879a This brings back commit r259578.
But now it follows the llvm style, uses an early return and doesn't
include a file named 1.o.

llvm-svn: 260293
2016-02-09 21:39:49 +00:00
Rafael Espindola
d8ee2fc3b7 Revert "Correct size calculations for ELF files"
This reverts commit r259578.

There are enough issues with this small patch that it is better to
revert and then commit a fixed version (will be committed shortly).

llvm-svn: 260285
2016-02-09 21:30:10 +00:00
Ehsan Akhgari
638983e561 Remove system-libs.test for now
This test fails in the ninja-x64-msvc-RA-centos6 builder, so the
UNSUPPORTED: system-windows condition is insufficient.  Removing it
for now; I will investigate how this can be fixed later.

llvm-svn: 260281
2016-02-09 21:17:58 +00:00
Ehsan Akhgari
3cc7d4398a Fix a test added in r260263
llvm-svn: 260280
2016-02-09 21:10:22 +00:00
Ehsan Akhgari
f9c82ec597 Fix a typo in r260263
llvm-svn: 260269
2016-02-09 20:02:35 +00:00
Ehsan Akhgari
48aefced4b llvm-config: Add preliminary Windows support
Summary:
This patch adds Windows support for a few of the llvm-config commands,
including cflags, ldflags, libs, and system-libs.

Currently llvm-config is untested, so this patch adds tests for the
commands that it fixes as well.

Reviewers: rnk

Subscribers: llvm-commits

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

llvm-svn: 260263
2016-02-09 19:41:14 +00:00
Simon Atanasyan
9bb8f93c03 [llvm-readobj][ELF] Show MIPS GOT content when there is another zero-sized section at the same address
It is possible to have .got section and one or more zero-sized section
at the same address. This patch first checks that GOT (or GOT PLT)
section should have non-zero size using corresponding dynamic tags. Then
it looks up not empty section at the specified address.

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

llvm-svn: 260245
2016-02-09 18:45:35 +00:00
Kevin Enderby
56ebb01b61 Fix a formatting problems with llvm-size and the -m option.
It was using format() with a string for 64-bit types but was
passed a 32-bit type in places when printing values for
32-bit Mach-O files.

rdar://24542509

llvm-svn: 260243
2016-02-09 18:33:15 +00:00
Justin Bogner
072ef25de8 llvm-cov: Fix reading gcov data that does not have function names
In order for recent gcov versions to read the coverage data, you have
to use UseCfgChecksum=true and FunctionNamesInData=false options for
coverage profiling pass. This is because gcov is expecting the
function section in .gcda to be exactly 3 words in size, containing
ident and two checksums.

While llvm-cov is compatible with UseCfgChecksum=true, it always
expects a function name in .gcda function sections (it's not
compatible with FunctionNamesInData=false). Thus it's currently
impossible to generate one set of coverage files that works with both
gcov and llvm-cov.

This change fixes the reading of coverage information to only read the
function name if it's present.

Patch by Arseny Kapoulkine. Thanks!

llvm-svn: 260162
2016-02-08 22:49:40 +00:00
Xinliang David Li
5f473ff0ae Fix build bot failure
llvm-svn: 260138
2016-02-08 20:08:21 +00:00
Xinliang David Li
a698273397 [PGO] Enable compression in pgo instrumentation
This reduces sizes of instrumented object files, final binaries,
process images, and raw profile data.

The format of the indexed profile data remain the same.

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

llvm-svn: 260117
2016-02-08 18:13:49 +00:00
NAKAMURA Takumi
7dc931109e Disable llvm/test/tools/llvm-profdata/value-prof.proftext on win32 for now. Investigating.
llvm-svn: 260064
2016-02-07 23:03:38 +00:00
David Blaikie
25a5770c88 [llvm-dwp] Merge cu_index from DWPs
This is almost feature complete - just missing tu_index merging now.

llvm-svn: 259971
2016-02-06 01:15:26 +00:00
Xinliang David Li
987cdb1169 Add a compatibility test
llvm-svn: 259632
2016-02-03 06:27:38 +00:00
Hemant Kulkarni
944f75148f Correct size calculations for ELF files
llvm-svn: 259578
2016-02-02 21:41:49 +00:00
Frederic Riss
e4eb654c9f [dsymutil] Support scattered relocs.
Although it seems like clang will never emit scattered relocations in
the debug information (at least I couldn't find a way), we have too
support them for the benefit of other compilers.
As clang doesn't generate them, the included testcase was produced
from hacked up assembly.

llvm-svn: 259339
2016-02-01 03:44:22 +00:00
Frederic Riss
fa5f95611b [dsymutil] Fix FileCheck command.
Damn case-insensitive filesystem...

llvm-svn: 259319
2016-01-31 04:39:16 +00:00
Frederic Riss
f067530e7a [dsymutil] Fix handling of common symbols.
llvm-dsymutil was misinterpreting the value of common symbols as their
address when it actually contains their size. This didn't impact
llvm-dsymutil's ability to link the debug information for common symbols
because these are always found by name and not by address. Things could
however go wrong when the size of a common object matched the object
file address of another symbol. Depending on the link order of the symbols
the common object might incorrectly evict this other object from the
address to symbol mapping, and then link the evicted symbol with a wrong
binary address.

Use the new ability to have symbols without an object file address to fix
this.

llvm-svn: 259318
2016-01-31 04:29:34 +00:00
Vedant Kumar
e1a3d86600 [Profiling] Add a -sparse mode to llvm-profdata merge
Add an option to llvm-profdata merge for writing out sparse indexed
profiles. These profiles omit InstrProfRecords for functions which are
never executed.

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

llvm-svn: 259258
2016-01-29 22:54:45 +00:00
Sergei Larin
6eb351346a [SplitModule] In split module utility we should never separate alias with its aliasee.
Summary: When splitting module with preserving locals, we currently do not handle case of global alias being separated with its aliasee.

Subscribers: llvm-commits

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

llvm-svn: 259075
2016-01-28 18:59:28 +00:00
Davide Italiano
9af52352cb [llvm-nm] Remove redundant check for file validity.
We already perform it at the beginning of the function so we can't
arrive here with an invalid object. Also, add a test so that bugs
won't sneak in the future.

llvm-svn: 258982
2016-01-27 20:27:44 +00:00
Igor Laevsky
730e8cf8fe [DebugInfo] Support zero-length CIE in the _eh_frame parser
MCJIT emits zero-length CIE at the end of the _eh_frame section. This change
ensures that parser inside DebugInfo will not crash and correctly record such cases.
We are now recording DW_EH_PE_omit as a default value for FDE and LSDA encodings.
Also Offset != EndAugmentationOffset assertion check will only happen if augmentation 
string had 'z' letter in it.

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

llvm-svn: 258931
2016-01-27 14:05:35 +00:00
Hemant Kulkarni
e89fec8eee [llvm-readobj] Add -elf-section-groups option
Adds a way to inspect SHT_GROUP sections in ELF objects.
Displays signature, member sections of these sections.

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

llvm-svn: 258845
2016-01-26 19:46:39 +00:00
Igor Laevsky
7660fa06ad Re-submit r256008 "Improve DWARFDebugFrame::parse to also handle __eh_frame."
Originally this change was causing failures on windows buildbots.
But those problems were fixed in r258806.

llvm-svn: 258811
2016-01-26 15:09:42 +00:00
Bradley Smith
849b958836 [ARM] Add DSP build attribute and extension targeting
This patch was originally committed as r257885, but was reverted due to windows
failures. The cause of these failures has been fixed under r258677, hence
re-committing the original patch.

llvm-svn: 258683
2016-01-25 11:26:11 +00:00
Xinliang David Li
45d037347b re-submit test case (withright format-version)
llvm-svn: 258384
2016-01-21 02:35:59 +00:00
Xinliang David Li
c16f1f078e Revert 258376 -- wrong version
llvm-svn: 258377
2016-01-21 01:21:00 +00:00
Xinliang David Li
7a6b4b2882 [Coverage] Add a test case for comdat
The binary contains two (merged) covmap sections which
have duplicate CovMapRecords from comdat (template instantation).
This test makes sure the reader reads it properly. It also
tests that the coverage data from different instantiations
of the same template function are properly merged in show
output.

llvm-svn: 258376
2016-01-21 00:57:42 +00:00
Simon Atanasyan
65cb28f51e [llvm-readobj][ELF] Teach llvm-readobj to show arch specific ELF section's flags
Some architecture specific ELF section flags might have the same value
(for example SHF_X86_64_LARGE and SHF_HEX_GPREL) and we have to check
machine architectures to select an appropriate set of possible flags.

The patch selects architecture specific flags into separate arrays
`ElfxxxSectionFlags` and combines `ElfSectionFlags` and `ElfxxxSectionFlags`
before pass to the `StreamWriter::printFlags()` method.

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

llvm-svn: 258334
2016-01-20 19:15:18 +00:00
Sergei Larin
72115d5fb6 Add to the split module utility an SCC based method which allows not to globalize any local variables.
Summary:
    Currently llvm::SplitModule as the first step globalizes all local objects, which might not be desirable in some scenarios.
    This change adds a new flag to llvm::SplitModule that uses SCC approach to search for a balanced partition without the need to externalize symbols.
    Such partition might not be possible or fully balanced for a given number of partitions, and is a function of the module properties (global/local dependencies within the module).
    
    Joint development Tobias Edler von Koch (tobias@codeaurora.org) and Sergei Larin (slarin@codeaurora.org)
    
    Subscribers: llvm-commits, joker.eph
    
    Differential Revision: http://reviews.llvm.org/D16124

llvm-svn: 258083
2016-01-18 21:07:13 +00:00
George Rimar
2c81d923b3 Fixed CRLF->LF line endings from r257914. NFC.
llvm-svn: 257990
2016-01-16 10:38:32 +00:00
Davide Italiano
2af46a6b49 [llvm-readobj] Dump DT_RELACOUNT correctly.
llvm-svn: 257988
2016-01-16 06:06:36 +00:00
Xinliang David Li
121c2832bb [PGO] fix a bug in profile summary computation
Entry block count was not counted and is corrected. Also
introduce a new metric that is MaxInternalBlockCount which
show command shows (as before).

llvm-svn: 257987
2016-01-16 05:29:49 +00:00
Peter Collingbourne
0fcf3c17e0 Introduce sanstats tool and llvm::CreateSanitizerStatReport function.
This is part of a new statistics gathering feature for the sanitizers.
See clang/docs/SanitizerStats.rst for further info and docs.

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

llvm-svn: 257970
2016-01-16 00:31:11 +00:00
Reid Kleckner
1df6da7658 [codeview] Handle multiple frame descriptions in readobj
llvm-svn: 257943
2016-01-15 22:09:13 +00:00
Reid Kleckner
3937bf8e5a # This is a combination of 2 commits.
# The first commit's message is:

Revert "[ARM] Add DSP build attribute and extension targeting"

This reverts commit b11cc50c0b4a7c8cdb628abc50b7dc226ff583dc.

# This is the 2nd commit message:

Revert "[ARM] Add new system registers to ARMv8-M Baseline/Mainline"

This reverts commit 837d08454e3e5beb8581951ac26b22fa07df3cd5.

llvm-svn: 257916
2016-01-15 18:31:29 +00:00
George Rimar
4f2e6d2b92 Recommit r257912
Added forgotten ELFDumper.cpp to commit.

Initial commit message:
[llvm-readobj] Add support for TLSDESC_PLT and TLSDESC_GOT dynamic section tags to the llvm-readobj.

If module uses uses lazy TLSDESC relocations it should define DT_TLSDESC_PLT and DT_TLSDESC_GOT entries.
They were unknown for llvm-readobj before this patch.

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

llvm-svn: 257914
2016-01-15 18:21:34 +00:00
George Rimar
359783171e Revert r257912 - forgot to commit one file.
Initial commit message:
[llvm-readobj] Add support for TLSDESC_PLT and TLSDESC_GOT dynamic section tags to the llvm-readobj.

If module uses uses lazy TLSDESC relocations it should define DT_TLSDESC_PLT and DT_TLSDESC_GOT entries.
They were unknown for llvm-readobj before this patch.

Differential revision: http://reviews.llvm.org/D16224
----
Added : /llvm/trunk/test/tools/llvm-readobj/Inputs/dynamic-table-so.aarch64
Modified : /llvm/trunk/test/tools/llvm-readobj/Inputs/dynamic-table.c
Modified : /llvm/trunk/test/tools/llvm-readobj/dynamic.test

llvm-svn: 257913
2016-01-15 18:19:06 +00:00
George Rimar
390f572ef5 [llvm-readobj] Add support for TLSDESC_PLT and TLSDESC_GOT dynamic section tags to the llvm-readobj.
If module uses uses lazy TLSDESC relocations it should define DT_TLSDESC_PLT and DT_TLSDESC_GOT entries.
They were unknown for llvm-readobj before this patch.

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

llvm-svn: 257912
2016-01-15 18:13:59 +00:00
Rafael Espindola
28c80c9c7f Add a test showing when ld64 can hide linkonce_odr symbols.
llvm-svn: 257903
2016-01-15 16:40:20 +00:00
Rafael Espindola
2a68a0ecfa Make sure this test is actually executed.
Before it was always unsupported.

llvm-svn: 257899
2016-01-15 16:16:46 +00:00
Bradley Smith
8c53f2fbdf [ARM] Add DSP build attribute and extension targeting
llvm-svn: 257885
2016-01-15 10:28:25 +00:00
Reid Kleckner
6237bdd778 [codeview] Translate file table offsets to filenames and print them
llvm-svn: 257846
2016-01-15 00:11:21 +00:00
Mike Aizatsky
c4cbbdf6fc [sancov] html report
Differential Revision: http://reviews.llvm.org/D16161

llvm-svn: 257824
2016-01-14 22:34:11 +00:00
Reid Kleckner
fc79a7dd17 [codeview] Dump CodeView inlinee lines subsection
llvm-svn: 257790
2016-01-14 19:20:17 +00:00
Adrian Prantl
c706175b3a dsymutil: Provide better warnings when clang modules cannot be found.
rdar://problem/22823264

llvm-svn: 257784
2016-01-14 18:31:07 +00:00
Easwaran Raman
be7342fab7 Display detailed profile summary in llvm-profdata tool.
This adds a detailed profile summary in llvm-profdata. The summary is in the
form of one or more triples of the form (P, N, M) which is interpreted as if
we look at the Top-N counts in the profile, their sum accounts for P percentage
of the sum of all counts in the program and the minimum count in the Top-N is M.

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

llvm-svn: 257680
2016-01-13 21:44:36 +00:00
Adrian Prantl
0bd16ca04c Relax testcase so it works on Windows.
llvm-svn: 257667
2016-01-13 21:09:48 +00:00
Adrian Prantl
1438194582 dsymutil: Only warn about missing clang modules once.
rdar://problem/22269336

llvm-svn: 257664
2016-01-13 20:26:00 +00:00
Reid Kleckner
0f638161ba [readobj] Expand CodeView dumping functionality
This rewrites and expands the existing codeview dumping functionality in
llvm-readobj using techniques similar to those in lib/Object. This defines a
number of new records and enums useful for reading memory mapped codeview
sections in COFF objects.

The dumper is intended as a testing tool for LLVM as it grows more codeview
output capabilities.

Reviewers: majnemer

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

llvm-svn: 257658
2016-01-13 19:32:35 +00:00
Davide Italiano
baadd9459c [llvm-objdump] Use report_error() and improve error coverage.
llvm-svn: 257561
2016-01-13 02:03:31 +00:00
David Majnemer
32661ec901 [CodeView] Improve the line table dumper
This change has us print out fields we didn't previously understand.  To
improve readability, we now group column information with it's
respective line.

llvm-svn: 257552
2016-01-13 01:05:16 +00:00
Kevin Enderby
3f9a07c662 For llvm-objdump, add the option -private-header (without the trailing ’s’)
to only print the first private header.

Which for Mach-O files only prints the Mach header and not the subsequent load
commands.  Which is used by scripts to match what the darwin otool(1) with the
-h flag does without the -l flag.

For non-Mach-O files it has the same functionality as -private-headers (with
the trailing ’s’).

rdar://24158331

llvm-svn: 257548
2016-01-13 00:25:36 +00:00
Rafael Espindola
b1cab51c6f Fix test on windows.
llvm-svn: 257475
2016-01-12 14:58:40 +00:00
Rafael Espindola
59ed1d964f Add a missing error handling to llvm-lto.
llvm-svn: 257395
2016-01-11 22:08:22 +00:00
Mike Aizatsky
d03c218611 [llvm-symbolizer] -print-source-context-lines option to print source code around the line.
Differential Revision: http://reviews.llvm.org/D15909

llvm-svn: 257236
2016-01-09 00:14:35 +00:00
Xinliang David Li
1561504810 [PGO] Ensure vp data in indexed profile always sorted
Done in  InstrProfWriter to eliminate the need for client
code to do the sorting. The operation is done once and reused 
many times so it is more efficient. Update unit test to remove
sorting. Also update expected output of affected tests.

llvm-svn: 257145
2016-01-08 05:45:21 +00:00
Mike Aizatsky
a5855c0f74 [llvm-symbolizer] Print out non-address lines verbatim.
Differential Revision: http://reviews.llvm.org/D15876

llvm-svn: 257115
2016-01-07 23:57:41 +00:00
Dimitry Andric
053841f2e3 Fix one file that I didn't convert properly in r256707.
llvm-svn: 256720
2016-01-03 22:33:32 +00:00
Dimitry Andric
0614f2a55e Fix several accidental DOS line endings in source files
Summary:
There are a number of files in the tree which have been accidentally checked in with DOS line endings.  Convert these to native line endings.

There are also a few files which have DOS line endings on purpose, and I have set the svn:eol-style property to 'CRLF' on those.

Reviewers: joerg, aaron.ballman

Subscribers: aaron.ballman, sanjoy, dsanders, llvm-commits

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

llvm-svn: 256707
2016-01-03 17:22:03 +00:00
James Y Knight
30e7ad8b6b Fix gold test after r256465.
That commit added a new pass, and this test is sensitive to what the
first pass after verify is called.

llvm-svn: 256532
2015-12-29 03:48:37 +00:00
Adrian Prantl
3787e623ca llvm-dwarfdump: Add support for dumping .dSYM bundles.
This replicates the logic of Darwin dwarfdump for manually opening up
.dSYM bundles without introducing any new dependencies.
<rdar://problem/20491670>

llvm-svn: 256350
2015-12-23 21:51:13 +00:00
Teresa Johnson
4fc9fb1957 Handle empty Subprogram list when linking metadata.
Use an iterator that handles an empty subprogram list.

Fixes PR25915.

llvm-svn: 256224
2015-12-22 01:17:19 +00:00
Teresa Johnson
34957cd924 Add testcase for r256161 (PR25907)
llvm-svn: 256174
2015-12-21 18:24:35 +00:00
Xinliang David Li
6fb8766a59 Fix a bug in test case -- duplicate entries
llvm-svn: 256117
2015-12-20 08:49:31 +00:00
Pete Cooper
cda523f460 Revert "Improve DWARFDebugFrame::parse to also handle __eh_frame."
This reverts commit r256008.

Its breaking multiple buildbots, although works for me locally.

llvm-svn: 256013
2015-12-18 19:45:38 +00:00
Pete Cooper
70c961d67d Improve DWARFDebugFrame::parse to also handle __eh_frame.
LLVM MC has single methods which can handle the output of EH frame and DWARF CIE's and FDE's.

This code improves DWARFDebugFrame::parse to do the same for parsing.

This also allows llvm-objdump to support the --dwarf=frames option which objdump supports.  This
option dumps the .eh_frame section using the new code in DWARFDebugFrame::parse.

http://reviews.llvm.org/D15535

Reviewed by Rafael Espindola.

llvm-svn: 256008
2015-12-18 18:51:08 +00:00
Teresa Johnson
a03b8bd4f9 [ThinLTO/LTO] Don't link in unneeded metadata
Summary:
Third patch split out from http://reviews.llvm.org/D14752.

Only map in needed DISubroutine metadata (imported or otherwise linked
in functions and other DISubroutine referenced by inlined instructions).
This is supported for ThinLTO, LTO and llvm-link --only-needed, with
associated tests for each one.

Depends on D14838.

Reviewers: dexonsmith, joker.eph

Subscribers: davidxl, llvm-commits, joker.eph

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

llvm-svn: 256003
2015-12-18 17:51:37 +00:00
Rafael Espindola
fced76b6f1 Pass -m elf_x84_64 to gold invocations.
Fixes pr25868.

llvm-svn: 255930
2015-12-17 21:56:27 +00:00
Nathan Slingerland
648ea4f74f [PGO] Handle and report overflow during profile merge for all types of data
Summary: Surface counter overflow when merging profile data. Merging still occurs on overflow but counts saturate to the maximum representable value. Overflow is reported to the user.

Reviewers: davidxl, dnovillo, silvas

Subscribers: llvm-commits

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

llvm-svn: 255825
2015-12-16 21:45:43 +00:00
Mike Aizatsky
f3003a8493 [sancov] blacklist support.
Summary:
Using the blacklist the user can filter own unwanted functions
from all outputs. By default blacklist contains "fun:__sancov*" line.

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

llvm-svn: 255732
2015-12-16 00:31:48 +00:00
Xinliang David Li
791996b600 Test cleanup -- remove duplicate run lines
llvm-svn: 255673
2015-12-15 21:15:06 +00:00
Nathan Slingerland
b95c2eec31 [llvm-profdata] Add support for weighted merge of profile data (2nd try)
Summary:
This change adds support for specifying a weight when merging profile data with the llvm-profdata tool.
Weights are specified by using the --weighted-input=<weight>,<filename> option. Input files not specified
with this option (normal positional list after options) are given a default weight of 1.

Adding support for arbitrary weighting of input profile data allows for relative importance to be placed on the
input data from multiple training runs.

Both sampled and instrumented profiles are supported.

Reviewers: davidxl, dnovillo, bogner, silvas

Subscribers: silvas, davidxl, llvm-commits

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

llvm-svn: 255659
2015-12-15 17:37:09 +00:00
Reid Kleckner
0c98151b50 [llvm-readobj] s/FunctionName/LinkageName/ for codeview dumping
The symbol being printed in this field comes from the main symbol table,
not 0xF1 subsection. Use LinkageName to make that a lot clearer.

llvm-svn: 255596
2015-12-15 01:23:55 +00:00
Pete Cooper
9826aaba7a Start implementing FDE dumping when printing the eh_frame.
This code adds some simple decoding of the FDE's in an eh_frame.

There's still more to be done in terms of error handling and verification.

Also, we need to be able to decode the CFI's.

llvm-svn: 255550
2015-12-14 21:49:49 +00:00
Pete Cooper
91dbcd5e25 Print the eh_frame section in MachoDump.
This is the start of work to dump the contents of the eh_frame section.

It currently emits CIE entries.  FDE entries will come later.

It also needs improved error checking which will follow soon.

http://reviews.llvm.org/D15502

Reviewed by Kevin Enderby and Lang Hames.

llvm-svn: 255546
2015-12-14 21:39:27 +00:00
Xinliang David Li
2ab348ba60 [PGO] Value profiling text format reader/writer support
This patch adds the missing functionality in parsable
text format support for value profiling.

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

llvm-svn: 255523
2015-12-14 18:44:01 +00:00
David Blaikie
bf4705c1bc [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.

llvm-svn: 255482
2015-12-14 07:42:00 +00:00
David Blaikie
b64e80ae57 [llvm-dwp] Remove some unused test code
llvm-svn: 255481
2015-12-14 07:41:56 +00:00
Xinliang David Li
2cad28318a [PGO] Revert r255365: solution incomplete, not handling lambda yet
llvm-svn: 255369
2015-12-11 20:23:22 +00:00
Xinliang David Li
de46641441 [PGO] Stop using invalid char in instr variable names.
Before the patch, -fprofile-instr-generate compile will fail
if no integrated-as is specified when the file contains
any static functions (the -S output is also invalid).

This patch fixed the issue. With the change, the index format
version will be bumped up by 1. Backward compatibility is 
preserved with this change.

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

llvm-svn: 255365
2015-12-11 19:53:19 +00:00
Frederic Riss
1db2534294 [dsymutil] Ignore absolute symbols in the debug map
Quoting from the comment added to the code:

    // Objective-C on i386 uses artificial absolute symbols to
    // perform some link time checks. Those symbols have a fixed 0
    // address that might conflict with real symbols in the object
    // file. As I cannot see a way for absolute symbols to find
    // their way into the debug information, let's just ignore those.

llvm-svn: 255350
2015-12-11 17:50:37 +00:00
Rafael Espindola
c944447e56 Slit lib/Linker in two.
A linker normally has two stages: symbol resolution and "moving stuff".

In lib/Linker there is the complication of lazy linking some globals,
but it was still far more mixed than it needed to.

This splits the linker into a lower level IRMover and the linker proper.
The IRMover just takes a list of globals to move and a callback that
lets the user control what is lazy linked.

The main motivation is that now tools/gold (and soon lld) can use their
own symbol resolution to instruct IRMover what to do.

llvm-svn: 255254
2015-12-10 14:19:35 +00:00
David Blaikie
626fda51d2 [llvm-dwp] Restructure inputs for test case so they're all grouped together
llvm-svn: 254922
2015-12-07 18:46:41 +00:00
David Blaikie
7190459ba5 [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
llvm-svn: 254833
2015-12-05 03:41:53 +00:00
David Blaikie
55484cdbd7 [llvm-dwp] Fix the type_units.test since I renamed its inputs as well
llvm-svn: 254830
2015-12-05 03:11:17 +00:00
David Blaikie
986cfea13e [llvm-dwp] Rename the sufficiently-modified test to reflect it's non-simplicity
llvm-svn: 254829
2015-12-05 03:10:05 +00:00
David Blaikie
09b741f7b6 [llvm-dwp] Support debug_tu_index
llvm-svn: 254827
2015-12-05 03:05:45 +00:00
David Blaikie
e43f28015a [llvm-dwp] Remove some out of date comments
llvm-svn: 254772
2015-12-04 21:38:39 +00:00
David Blaikie
138abe01f5 [llvm-dwp] Implement the required on-disk probed hash table
llvm-svn: 254770
2015-12-04 21:30:23 +00:00
David Blaikie
d59ffbc983 [llvm-dwp] Include the debug_line.dwo section
This probably shouldn't be generated in the .dwo file for CUs, only for
TUs, but it's in the sample .dwos (generated by clang) so dwp should
reflect that.

Arguably the DWP tool could be smart enough to know that the CUs
shouldn't need a debug_line.dwo section and skip that even when it's
legitimately generated for TUs, but that's a bit more off-book.

llvm-svn: 254767
2015-12-04 21:16:42 +00:00
Mike Aizatsky
0372f5b7df sancov -not-covered-functions.
Summary: The command prints out list of functions that were not entered.
To do this, addresses are first converted to function locations. Set
operations are used for function locations.

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

review

llvm-svn: 254742
2015-12-04 18:35:37 +00:00
David Blaikie
3fd553d9d8 [llvm-dwp] Retrieve the DWOID from the CU for the cu_index entry
llvm-svn: 254731
2015-12-04 17:20:04 +00:00
Nathan Slingerland
5a941550ef Revert "[llvm-profdata] Add support for weighted merge of profile data"
This reverts commit b7250858d96b8ce567681214273ac0e62713c661.

Reverting in order to investigate Windows test failure.

llvm-svn: 254687
2015-12-04 02:13:58 +00:00
Nathan Slingerland
e6205d97d7 [llvm-profdata] Add support for weighted merge of profile data
This change adds support for an optional weight when merging profile data with the llvm-profdata tool.
Weights are specified by adding an option ':<weight>' suffix to the input file names.

Adding support for arbitrary weighting of input profile data allows for relative importance to be placed on the
input data from multiple training runs.

Both sampled and instrumented profiles are supported.

Reviewers: dnovillo, bogner, davidxl

Subscribers: llvm-commits

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

llvm-svn: 254669
2015-12-04 00:00:20 +00:00
Xinliang David Li
bd5d5ab3e1 [PGO] Add v2 format compatibility test
llvm-svn: 254572
2015-12-03 01:05:31 +00:00
David Blaikie
e5f9d70f7f [llvm-dwp] Include only the non-empty columns in the cu_index
llvm-svn: 254555
2015-12-02 22:01:56 +00:00
Nathan Slingerland
625b1f4b92 [llvm-profdata] Change instr prof counter overflow to saturate rather than discard
Summary: This changes overflow handling during instrumentation profile merge. Rathar than throwing away records that would result in counter overflow, merged counts are instead clamped to the maximum representable value. A warning about counter overflow is still surfaced to the user as before.

Reviewers: dnovillo, davidxl, silvas

Subscribers: llvm-commits

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

llvm-svn: 254525
2015-12-02 18:19:24 +00:00
David Blaikie
3719678673 [llvm-dwp] Emit a rather fictional debug_cu_index
This is very rudimentary support for debug_cu_index, but it is enough to
allow llvm-dwarfdump to find the offsets for  contributions and
correctly dump debug_info.

It will need to actually find the real signature of the unit and build
the real hash table with the right number of buckets, as per the DWP
specification.

It will also need to be expanded to cover the tu_index as well.

llvm-svn: 254489
2015-12-02 06:21:34 +00:00
David Blaikie
2b4f493936 [llvm-dwp] Deduplicate strings in the debug_str.dwo section
Also, ensure that references to those strings in debug_str_offsets.dwo
correctly refer to the deduplicated strings.

llvm-svn: 254441
2015-12-01 19:17:58 +00:00
David Blaikie
3fa2e45f02 [llvm-dwp] Correctly update debug_str_offsets.dwo when linking dwo files
This doesn't deduplicate strings in the debug_str section, nor does it
properly wire up the index so that debug_info can /find/ these strings,
but it does correct the str_offsets specifically.

Follow up patches to address those related/next issues.

llvm-svn: 254431
2015-12-01 18:07:07 +00:00
David Blaikie
0483eddbd1 [llvm-dwp] Initial partial prototype
This just concatenates the common DWP sections without doing any of the
fancy DWP things like:

1) update str_offsets
2) deduplicating strings
3) merging/creating cu/tu_index

Patches for these will follow shortly.

(also not sure about target triple/object file type for this tool - do I
really need a whole triple just to write an object file that contains
purely static/hardcoded bytes in each section? & I guess I should just
pick it based on the first input, maybe, rather than hardcoding for now
- but we only produce .dwo on ELF platforms with objcopy for now anyway)

llvm-svn: 254355
2015-12-01 00:48:39 +00:00
Rafael Espindola
94e602fadd Add a passing test.
When a comdat is discarded, any globals defined in it become undefined.

llvm-svn: 254258
2015-11-29 15:52:12 +00:00
Rafael Espindola
cb0eb08c74 Don't depend on the order the IR is copied.
llvm-svn: 254257
2015-11-29 15:22:49 +00:00
Rafael Espindola
731dd51848 Don't depend on the order the IR is copied.
llvm-svn: 254256
2015-11-29 15:08:39 +00:00
Rafael Espindola
b078a10e4d Test both input file orders.
llvm-svn: 254186
2015-11-27 03:50:34 +00:00
Rafael Espindola
f464f09124 Add missing file.
llvm-svn: 254185
2015-11-27 03:47:29 +00:00
Rafael Espindola
7feb960b9e Make the test a bit more interesting.
It now covers a regular function replacing an available_externally one.

llvm-svn: 254184
2015-11-27 02:07:37 +00:00
Rafael Espindola
0ba5a45ed3 Add a few passing lto tests.
I found these while trying to get a prototype to bootstrap.

They cover things like
* Handling of non linker visible stuff (append, available_externally)
* Type merging
* Alias to dropped globals
* Dropping linkage when converting to a declaration.

These should hopefully be generally useful for anyone refactoring the
plugin.

llvm-svn: 254174
2015-11-26 19:53:12 +00:00
Rafael Espindola
59fb3a9087 Make this test a bit more strict.
It now tests with files in both orders.

llvm-svn: 253993
2015-11-24 16:43:53 +00:00
Rafael Espindola
7781902df3 Add an already passing test.
This tests that a declaration can resolve to an alias.

I broke this locally while prototyping a change and it looks like a nice
test to have.

llvm-svn: 253984
2015-11-24 14:15:50 +00:00
Xinliang David Li
0f29a15199 [PGO] Add --text option for llvm-profdata show|merge commands
The new option is similar to the SampleProfile dump option.

- dump raw/indexed format into text profile format
- merge the profile and output into text profile format.

Note that Value Profiling data text format is not yet designed. 
That functionality will be added later.

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

llvm-svn: 253913
2015-11-23 20:47:38 +00:00
Rafael Espindola
9cb8841b77 Have a single way for creating unique value names.
We had two code paths. One would create names like "foo.1" and the other
names like "foo1".

For globals it is important to use "foo.1" to help C++ name demangling.
For locals there is no strong reason to go one way or the other so I
kept the most common mangling (foo1).

llvm-svn: 253804
2015-11-22 00:16:24 +00:00
Teresa Johnson
2b4369dd03 [ThinLTO] Handle bitcode without function summary sections gracefully
Summary:
Several fixes to the handling of bitcode files without function summary
sections so that they are skipped during ThinLTO processing in llvm-lto
and the gold plugin when appropriate instead of aborting.

1 Don't assert when trying to add a FunctionInfo that doesn't have
  a summary attached.
2 Skip FunctionInfo structures that don't have attached function summary
  sections when trying to create the combined function summary.
3 In both llvm-lto and gold-plugin, check whether a bitcode file has
  a function summary section before trying to parse the index, and skip
  the bitcode file if it does not.
4 Fix hasFunctionSummaryInMemBuffer in BitcodeReader, which had a bug
  where we returned to early while looking for the summary section.

Also added llvm-lto and gold-plugin based tests for cases where we
don't have function summaries in the bitcode file. I verified that
either the first couple fixes described above are enough to avoid the
crashes, or fixes 1,3,4. But have combined them all here for added
robustness.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

llvm-svn: 253796
2015-11-21 21:55:48 +00:00
Diego Novillo
0b8eea8df5 SamplePGO - Sort samples by source location when emitting as text.
When dumping function samples or writing them out as text format, it
helps if the samples are emitted sorted by source location. The sorting
of the maps is a bit slow, so we only do it on demand.

llvm-svn: 253568
2015-11-19 15:33:08 +00:00
Betul Buyukkurt
b3b3ea9a07 [PGO] Value profiling support
This change introduces an instrumentation intrinsic instruction for
value profiling purposes, the lowering of the instrumentation intrinsic
and raw reader updates. The raw profile data files for llvm-profdata
testing are updated.

llvm-svn: 253484
2015-11-18 18:14:55 +00:00
James Molloy
32883b6702 [LTO] Appease buildbots take 3
This time I've found a linux box and checked it there. This test now passes.

Because I'd introduced an undefined reference in @bar, gold now returns an error. This doesn't matter for the test itself, because it also emits the remarks the test is checking for. But it does cause LIT to notice a nonzero return code which it faults on.

llvm-svn: 253454
2015-11-18 12:08:24 +00:00
James Molloy
64eca23a0e [LTO] Buildbot appeasing take 2
Let's try again. This time using the right function signature. It's a real pity I can't run this on a darwin machine...

llvm-svn: 253453
2015-11-18 11:37:32 +00:00
James Molloy
5da47be927 [LTO] Fix up test/tools/gold/X86/remarks.ll
It needs the same fixes as in test/LTO/X86/remarks.ll, but this test appears not to get run on my system (but does on the buildbot). Strange.

llvm-svn: 253452
2015-11-18 11:32:14 +00:00
David Majnemer
0ee82e9395 [llvm-objdump] Use the COFF export table for additional symbols
Most linked executables do not have a symbol table in COFF.
However, it is pretty typical to have some export entries.  Use those
entries to inform the disassembler about potential function definitions
and call targets.

llvm-svn: 253429
2015-11-18 02:49:19 +00:00
Nathan Slingerland
9c743e7e7f [llvm-profdata] Improve error messaging when merging mismatched profile data
Summary:
This change tries to make the root cause of instrumented profile data merge failures clearer.

Previous:

$ llvm-profdata merge test_0.profraw test_1.profraw -o test_merged.profdata
test_1.profraw: foo: Function count mismatch
test_1.profraw: bar: Function count mismatch
test_1.profraw: baz: Function count mismatch
...

Changed:

$ llvm-profdata merge test_0.profraw test_1.profraw -o test_merged.profdata
test_1.profraw: foo: Function basic block count change detected (counter mismatch)
Make sure that all profile data to be merged is generated from the same binary.
test_1.profraw: bar: Function basic block count change detected (counter mismatch)
test_1.profraw: baz: Function basic block count change detected (counter mismatch)
...

Reviewers: dnovillo, davidxl, bogner

Subscribers: llvm-commits

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

llvm-svn: 253384
2015-11-17 22:08:53 +00:00
Mike Aizatsky
bc4d11920b enabling sancov tests on linux x86_64 only
Differential Revision: http://reviews.llvm.org/D14728

llvm-svn: 253354
2015-11-17 18:25:21 +00:00
Diego Novillo
8138378d81 SamplePGO - Add dump routines for LineLocation, SampleRecord and FunctionSamples
llvm-svn: 253071
2015-11-13 20:24:28 +00:00
NAKAMURA Takumi
4e41c2e7d7 llvm/test/tools/llvm-profdata/text-format-errors.test: Use prepared version of the input file, instead of using echo.
...and s/\C9/\xC9/

llvm-svn: 253014
2015-11-13 06:06:58 +00:00