Commit Graph

2323 Commits

Author SHA1 Message Date
Teresa Johnson
402752067f [ThinLTO] Remove post-pass metadata linking support
Since we have moved to a model where functions are imported in bulk from
each source module after making summary-based importing decisions, there
is no longer a need to link metadata as a postpass, and all users have
been removed.

This essentially reverts r255909 and follow-on fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264763 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 18:24:19 +00:00
Easwaran Raman
418032a1c8 Sample profile summary cleanup
Replace references to MaxHeadSamples with MaxFunctionCount

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264686 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 23:14:29 +00:00
Vedant Kumar
76bf991538 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264658 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 21:06:42 +00:00
Duncan P. N. Exon Smith
75f9dc9b05 Explicitly test BitstreamReader::setArtificialByteLimit, NFC
Explicitly check that artificial byte limit is rounded correctly by
exposing BitstreamReader::Size through a new accessor, getSizeIfKnown.

The original code for rounding (from r264547) wasn't obviously correct,
and even though r264623 cleaned it up (by calling llvm::alignTo) I think
it's worth testing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264650 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 20:39:41 +00:00
Duncan P. N. Exon Smith
2686d302c0 Remove accidentally duplicated test
This was identical to setArtificialByteLimitNotWordBoundary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264646 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 20:30:15 +00:00
Vedant Kumar
0afb669256 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264643 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 20:20:40 +00:00
Vedant Kumar
e15d81ae23 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264641 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 20:12:07 +00:00
Vedant Kumar
beaf3d18cf Revert "[PGO] Fix name encoding for ObjC-like functions"
This reverts commit r264587. Reverting to investigate 6 unexpected
failures on the ppc bot:

http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/2822

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264590 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 16:14:07 +00:00
Vedant Kumar
f63fe23e0d [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).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264587 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 15:52:08 +00:00
Vedant Kumar
ab3787a574 [Coverage] Strip <unknown> from PGO names if no filenames are available
Patch suggested by David Li!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264586 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 15:49:08 +00:00
Vedant Kumar
9c51ac3626 [Coverage] Fix the way we load "<unknown>:func" records
When emitting coverage mappings for functions with local linkage and an
unknown filename, we use "<unknown>:func" for the PGO function name. The
problem is that we don't strip "<unknown>" from the name when loading
coverage data, like we do for other file names. Fix that and add a test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264559 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 01:16:12 +00:00
Duncan P. N. Exon Smith
bd2e7848ab Bitcode: Fix MSVC bot failure from r264549
make_unique => llvm::make_unique

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264553 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-27 23:36:55 +00:00
Duncan P. N. Exon Smith
15b99e0369 BitcodeWriter: Simplify and test writing blobs, NFC
Split helper out of EmitRecordWithAbbrevImpl called emitBlob to reduce
code duplication, and add a few tests for it.

No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264550 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-27 23:04:04 +00:00
Duncan P. N. Exon Smith
fbf768a4d3 Support: Implement StreamingMemoryObject::getPointer
The implementation is fairly obvious.  This is preparation for using
some blobs in bitcode.

For clarity (and perhaps future-proofing?), I moved the call to
JumpToBit in BitstreamCursor::readRecord ahead of calling
MemoryObject::getPointer, since JumpToBit can theoretically (a) read
bytes, which (b) invalidates the blob pointer.

This isn't strictly necessary the two memory objects we have:

  - The return of RawMemoryObject::getPointer is valid until the memory
    object is destroyed.

  - StreamingMemoryObject::getPointer is valid until the next chunk is
    read from the stream.  Since the JumpToBit call is only going ahead
    to a word boundary, we'll never load another chunk.

However, reordering makes it clear by inspection that the blob returned
by BitstreamCursor::readRecord will be valid.

I added some tests for StreamingMemoryObject::getPointer and
BitstreamCursor::readRecord.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264549 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-27 23:00:59 +00:00
Duncan P. N. Exon Smith
b341866e2c Support: Move StreamingMemoryObject{,Test}.cpp, NFC
Change the filename to indicate this is a test, rename the tests, move
them into an anonymous namespace, and rename some variables.  All to
match our usual style before making further changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264548 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-27 22:55:19 +00:00
Duncan P. N. Exon Smith
a115062beb Bitcode: Add SimpleBitstreamCursor::setArtificialByteLimit
Allow users of SimpleBitstreamCursor to limit the number of bytes
available to the cursor.  This is preparation for instantiating a cursor
that isn't allowed to load more bytes from a StreamingMemoryObject (just
move around the ones already-loaded).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264547 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-27 22:49:32 +00:00
Duncan P. N. Exon Smith
2e87e9ef90 Bitcode: Add SimpleBitstreamCursor::getPointerToByte, etc.
Add API to SimpleBitstreamCursor to allow users to translate between
byte addresses and pointers.

  - jumpToPointer: move the bit position to a particular pointer.
  - getPointerToByte: get the pointer for a particular byte.
  - getPointerToBit: get the pointer for the byte of the current bit.
  - getCurrentByteNo: convenience function for assertions and tests.

Mainly adds unit tests (getPointerToBit/Byte already has a use), but
also preparation for eventually using jumpToPointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264546 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-27 22:45:25 +00:00
Lang Hames
bbb35fb68d [Support] Switch to RAII helper for error-as-out-parameter idiom.
As discussed on the llvm-commits thread for r264467.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264479 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 23:54:32 +00:00
Mehdi Amini
64f92384a5 StringMap/DenseMap unittests: use piecewise_construct and ensure no copy occurs.
This makes us no longer relying on move-construction elision by the compiler.
Suggested by D. Blaikie.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264475 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 23:25:06 +00:00
Lang Hames
d65658e8aa [Support] Add Error::errorForOutParameter helper.
This helper method creates a pre-checked Error suitable for use as an out
parameter in a constructor. This avoids the need to have the constructor
check a known-good error before assigning to it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264467 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 21:56:35 +00:00
Jun Bum Lim
cb239ec911 [SetVector] Add erase() method
This is a recommit of r264414 after fixing the buildbot failure caused by
incompatible use of std::vector.erase().

The original message:

Add erase() which returns an iterator pointing to the next element after the
erased one. This makes it possible to erase selected elements while iterating
over the SetVector :
  while (I != E)
    if (test(*I))
      I = SetVector.erase(I);
    else
      ++I;

Reviewers: qcolombet, mcrosier, MatzeB, dblaikie

Subscribers: dberlin, dblaikie, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264450 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 19:28:08 +00:00
Jun Bum Lim
16303e867d Revert "[SetVector] Add erase() method"
This reverts commit r264414.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264420 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 16:49:16 +00:00
Mehdi Amini
ff9b2316f1 Improve StringMap unittests: reintroduce move count, but shield against std::pair internals
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264418 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 16:36:00 +00:00
Mehdi Amini
df98afd142 Ensure that the StringMap does not grow during the test for pre-allocation/reserve
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264416 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 16:09:34 +00:00
Jun Bum Lim
c9a0644f8a [SetVector] Add erase() method
Summary:
Add erase() which returns an iterator pointing to the next element after the
erased one. This makes it possible to erase selected elements while iterating
over the SetVector :
  while (I != E)
    if (test(*I))
      I = SetVector.erase(I);
    else
      ++I;

Reviewers: qcolombet, mcrosier, MatzeB, dblaikie

Subscribers: dberlin, dblaikie, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264414 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 16:04:43 +00:00
Mehdi Amini
4f6a396142 Disable counting the number of move in the unittest, it seems to rely on move-construction elision
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264412 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 15:46:14 +00:00
Mehdi Amini
256567583d Query the StringMap only once when creating MDString (NFC)
Summary:
Loading IR with debug info improves MDString::get() from 19ms to 10ms.
This is a rework of D16597 with adding an "emplace" method on the StringMap
to avoid requiring the MDString move ctor to be public.

Reviewers: dexonsmith

Subscribers: llvm-commits

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

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264386 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 05:58:04 +00:00
Mehdi Amini
bf941ea066 Adjust initial size in StringMap constructor to guarantee no grow()
Summary:
StringMap ctor accepts an initialize size, but expect it to be
rounded to the next power of 2. The ctor can handle that directly
instead of expecting clients to round it. Also, since the map will
resize itself when 75% full, take this into account an initialize
a larger initial size to avoid any growth.

Reviewers: dblaikie

Subscribers: llvm-commits

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

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264385 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 05:57:57 +00:00
Mehdi Amini
9ed5a8271e Fix DenseMap::reserve(): the formula was wrong
Summary:
Just running the loop in the unittests for a few more iterations
(till 48) exhibit that the condition on the limit was not handled
properly in r263522.
Rewrite the test to use a class to count move/copies that happens
when inserting into the map.
Also take the opportunity to refactor the logic to compute the
number of buckets required for a given number of entries in the map.
Use this when constructing a DenseMap with a desired size given to
the constructor (and add a tests for this).

Reviewers: dblaikie

Subscribers: llvm-commits

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

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264384 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 05:57:52 +00:00
Reid Kleckner
c68f3d4c8d Try to fix ODR violation of ErrorInfo::ID
This implements my suggestion to Lang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264360 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24 23:49:34 +00:00
David Blaikie
1825f4d513 [ADT] C++11ify SmallVector::erase's arguments from iterator to const_iterator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264330 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24 20:25:51 +00:00
NAKAMURA Takumi
89b695a240 ErrorTest.cpp: Move instantiations out of anonymous namespace. gcc didn't complain.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264297 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24 15:40:46 +00:00
NAKAMURA Takumi
389c434b57 Define ErrorInfo::ID explicitly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264293 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24 15:26:43 +00:00
NAKAMURA Takumi
f043736d85 ErrorTest.cpp: Fix an expression, possibly typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264290 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24 15:19:22 +00:00
Lang Hames
d1800c2b1c [Support] Add conversions between Expected<T> and ErrorOr<T>.
More utilities to help with std::error_code -> Error transitions.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264238 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24 02:00:10 +00:00
Lang Hames
d34f785662 [Support] Make all Errors convertible to std::error_code.
This is a temporary crutch to enable code that currently uses std::error_code
to be incrementally moved over to Error. Requiring all Error instances be
convertible enables clients to call errorToErrorCode on any error (not just
ECErrors created by conversion *from* an error_code).

This patch also moves code for Error from ErrorHandling.cpp into a new
Error.cpp file.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264221 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-23 23:57:28 +00:00
Matt Arsenault
b883372896 APFloat: Fix signalling nans for scalbn
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264219 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-23 23:51:45 +00:00
Pete Cooper
552f3d8472 StringRef::copy shouldn't allocate anything for length 0 strings.
The BumpPtrAllocator currently doesn't handle zero length allocations well.
The discussion for how to fix that is ongoing.  However, there's no need
for StringRef::copy to actually allocate anything here anyway, so just
return StringRef() when we get a zero length copy.

Reviewed by David Blaikie

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264201 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-23 21:49:31 +00:00
Easwaran Raman
e34db46356 Add getBlockProfileCount method to BlockFrequencyInfo
Differential Revision: http://reviews.llvm.org/D18233



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264179 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-23 18:18:26 +00:00
Vedant Kumar
a9e82b41a3 [unittests] clang-format a line, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264059 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-22 15:14:18 +00:00
Mehdi Amini
d4501fffa8 Fix unittests: resize() -> reserve()
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264029 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-22 07:35:51 +00:00
Lang Hames
43f3f60fb4 [Orc] Switch RPC Procedure to take a function type, rather than an arg list.
No functional change, just a little more readable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21 16:56:25 +00:00
Matt Arsenault
7c9226fea8 APFloat: Add frexp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263950 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21 16:49:16 +00:00
Matt Arsenault
23f7a82592 Implement constant folding for bitreverse
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21 15:00:35 +00:00
Easwaran Raman
af640bffc2 Interface to get/set profile summary metadata to module
Differential Revision: http://reviews.llvm.org/D17894


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263835 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-18 21:29:30 +00:00
Lang Hames
ec1cb3a98d [Support] Refactor Error unit tests to avoid duplicating work.
Suggested by Dave Blaikie in review for r263749. Thanks Dave!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263768 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-18 00:12:37 +00:00
Mike Aizatsky
779c414f55 Revert "allow lambdas in mapped_iterator"
MSVC as usual:

C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/ADT/STLExtras.h(120):
error C2100: illegal indirection
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/IR/Instructions.h(3966):
note: see reference to class template instantiation
'llvm::mapped_iterator<llvm::User::op_iterator,llvm::CatchSwitchInst::DerefFnTy>'
being compiled

This reverts commit e091dd63f1f34e043748e28ad160d3bc17731168.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263760 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 23:32:20 +00:00
Mike Aizatsky
4408c622ad allow lambdas in mapped_iterator
Differential Revision: http://reviews.llvm.org/D17311

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263759 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 23:22:22 +00:00
Lang Hames
0583c9334d [Support] Add ExitOnError utility to support tools that use the exit-on-error
idiom.

Most LLVM tool code exits immediately when an error is encountered and prints an
error message to stderr. The ExitOnError class supports this by providing two
call operators - one for Errors, and one for Expected<T>s. Calls to code that
can return Errors (or Expected<T>s) can use these calls to bail out on error,
and otherwise continue as if the operation had succeeded. E.g.

Error foo();
Expected<int> bar();

int main(int argc, char *argv[]) {
  ExitOnError ExitOnErr;

  ExitOnErr.setBanner(std::string("Error in ") + argv[0] + ":");

  // Exit if foo returns an error. No need to manually check error return.
  ExitOnErr(foo());

  // Exit if bar returns an error, otherwise unwrap the contained int and
  // continue.
  int X = ExitOnErr(bar());

  // ...

  return 0;
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263749 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 21:28:49 +00:00
Lang Hames
3d86278890 [Support] Make Error::isA<T>() works on success values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263745 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 20:35:00 +00:00