1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

2512 Commits

Author SHA1 Message Date
Craig Topper
f55c0fa51f [APInt] Use 'unsigned' instead of 'unsigned int' in the interface to the APInt tc functions. This is more consistent with the rest of the codebase. NFC
llvm-svn: 298897
2017-03-28 05:32:48 +00:00
Craig Topper
3275a24a2b [APInt] Move the single word cases of the bitwise operators inline.
llvm-svn: 298894
2017-03-28 04:00:47 +00:00
Craig Topper
6146e01ab1 [APInt] Move operator=(uint64_t) inline as its pretty simple and is often used with small constants that the compiler can optimize.
While there recognize that we only need to clearUnusedBits on the single word case.

llvm-svn: 298881
2017-03-27 20:07:31 +00:00
Craig Topper
b3e2d57189 [APInt] Move operator&=(uint64_t) inline and use memset to clear the upper words.
This method is pretty new and probably isn't use much in the code base so this should have a negligible size impact. The OR and XOR operators are already inline.

llvm-svn: 298870
2017-03-27 18:16:17 +00:00
Craig Topper
4c61a8c441 [APInt] Use memset in setAllBits.
llvm-svn: 298867
2017-03-27 17:50:54 +00:00
Craig Topper
327b741a6a [APInt] Move the >64 bit case for flipAllBits out of line.
This is more consistent with what we do for other operations. This shrinks the opt binary on my build by ~72k.

llvm-svn: 298858
2017-03-27 17:10:21 +00:00
Justin Bogner
b844e1b0eb ADT: Add range helpers for pointer_ and pointee_iterator
llvm-svn: 298841
2017-03-27 12:56:12 +00:00
Richard Smith
f72eaba29b Remove unnecessary use of std::result_of, which is deprecated in C++17.
llvm-svn: 298645
2017-03-23 21:02:31 +00:00
Zachary Turner
c9ea10a63b Resubmit "Improve StringMap iterator support."
The issue was trying to advance past the end of the iterator
when computing the end() iterator.

llvm-svn: 298461
2017-03-21 23:45:03 +00:00
Zachary Turner
5a93187aed Revert "Improve StringMap iterator support."
This is causing crashes in clang, so reverting until the problem
is figured out.

llvm-svn: 298440
2017-03-21 21:23:57 +00:00
Zachary Turner
7f3c5a6c6d Fix clang errors caused by StringMap iterator changes.
llvm-svn: 298437
2017-03-21 20:41:51 +00:00
Zachary Turner
86fa3b92a2 Improve StringMap iterator support.
StringMap's iterators did not support LLVM's
iterator_facade_base, which made it unusable in various
STL algorithms or with some of our range adapters.
This patch makes both StringMapConstIterator as well as
StringMapIterator support iterator_facade_base.

With this in place, it is easy to make an iterator adapter
that iterates over only keys, and whose value_type is
StringRef.  So I add StringMapKeyIterator as well, and
provide the method StringMap::keys() that returns a
range that can be iterated.

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

llvm-svn: 298436
2017-03-21 20:27:36 +00:00
Zachary Turner
928a5380bb [ADT] Add a version of llvm::join() that takes a range.
llvm-svn: 298427
2017-03-21 19:35:05 +00:00
Craig Topper
a0b1c94daf [APFloat] Tag the fltSemantic getter functions with LLVM_READNONE.
This gives about an 8k reduction in the size of the opt binary on my local x86-64 build.

llvm-svn: 298344
2017-03-21 07:18:00 +00:00
Craig Topper
bd14444022 [APInt] Add LLVM_READONLY to some methods.
llvm-svn: 298342
2017-03-21 06:19:46 +00:00
Simon Pilgrim
1d42891fcb Use MutableArrayRef for APFloat::convertToInteger
As discussed on D31074, use MutableArrayRef for destination integer buffers to help assert before stack overflows happen.

llvm-svn: 298253
2017-03-20 14:40:12 +00:00
Simon Pilgrim
cd77b1a217 Strip trailing whitespace
llvm-svn: 298247
2017-03-20 13:53:59 +00:00
Craig Topper
42c5924a25 [APInt] Don't initialize VAL to 0 in APInt constructors. Push it down to the initSlowCase and other init methods.
I'm not sure if zeroing VAL before writing pVal is really necessary, but at least one other place did it in code.

But by taking the store out of line, this reduces the opt binary by about 20k on my local x86-64 build.

llvm-svn: 298233
2017-03-20 01:29:52 +00:00
Craig Topper
f85e0d3530 [GVN] Fix accidental double storage of the function BasicBlock list in iterateOnFunction
Summary:
iterateOnFunction creates a ReversePostOrderTraversal object which does a post order traversal in its constructor and stores the results in an internal vector. Iteration over it just reads from the internal vector in reverse order.

The GVN code seems to be unaware of this and iterates over ReversePostOrderTraversal object and makes a copy of the vector into a local vector. (I think at one point in time we used a DFS here instead which would have required the local vector).

The net affect of this is that we have two vectors containing the basic block list. As I didn't want to expose the implementation detail of ReversePostOrderTraversal's constructor to GVN, I've changed the code to do an explicit post order traversal storing into the local vector and then reverse iterate over that.

I've also removed the reserve(256) since the ReversePostOrderTraversal wasn't doing that. I can add it back if we thinks it important. Though it seemed weird that it wasn't based on the size of the function.

Reviewers: davide, anemet, dberlin

Subscribers: llvm-commits

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

llvm-svn: 298191
2017-03-18 18:24:41 +00:00
Craig Topper
41e75a32fb [ValueTracking] Add APInt::setSignBit and use it to replace ORing with getSignBit which will malloc if the bit width is larger than 64.
llvm-svn: 298180
2017-03-18 04:01:29 +00:00
Jonathan Roelofs
77b3b41bd4 Clarify a comment about mapped_iterator. NFC
llvm-svn: 297988
2017-03-16 20:37:59 +00:00
Zachary Turner
53b5566696 Add missing include on <limits>.
llvm-svn: 297646
2017-03-13 17:25:47 +00:00
Zachary Turner
3f1f055e62 Use numeric_limits<size_t>::max() instead of size_t(-1).
llvm-svn: 297641
2017-03-13 17:12:37 +00:00
Zachary Turner
2810a164dd Fix a warning due to signed/unsigned comparison.
llvm-svn: 297639
2017-03-13 16:41:49 +00:00
Zachary Turner
bb6c1699b6 [ADT] Improve the genericity of llvm::enumerate().
There were some issues in the implementation of enumerate()
preventing it from being used in various contexts.  These were
all related to the fact that it did not supporter llvm's
iterator_facade_base class.  So this patch adds support for that
and additionally exposes a new helper method to_vector() that
will evaluate an entire range and store the results in a
vector.

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

llvm-svn: 297633
2017-03-13 16:24:10 +00:00
Zachary Turner
a5e44188b6 [ADT] Add a DenseMapInfo<T> for shorts.
Differential Revision: https://reviews.llvm.org/D30857

llvm-svn: 297552
2017-03-11 02:52:48 +00:00
Zachary Turner
1b5e220eaa Fix line endings of DenseMapInfo.h
llvm-svn: 297550
2017-03-11 02:50:18 +00:00
Zachary Turner
fbab7c7505 Remove eol-style:native from DenseMapInfo.h
llvm-svn: 297549
2017-03-11 02:47:59 +00:00
Simon Pilgrim
9d9d7803a0 [APInt] Add APInt::insertBits() method to insert an APInt into a larger APInt
We currently have to insert bits via a temporary variable of the same size as the target with various shift/mask stages, resulting in further temporary variables, all of which require the allocation of memory for large APInts (MaskSizeInBits > 64).

This is another of the compile time issues identified in PR32037 (see also D30265).

This patch adds the APInt::insertBits() helper method which avoids the temporary memory allocation and masks/inserts the raw bits directly into the target.

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

llvm-svn: 297458
2017-03-10 13:44:32 +00:00
Daniel Berlin
294f6c0958 Add support for DenseMap/DenseSet count and find using const pointers
Summary:
Similar to SmallPtrSet, this makes find and count work with both const
referneces and const pointers.

Reviewers: dblaikie

Subscribers: llvm-commits, mzolotukhin

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

llvm-svn: 297424
2017-03-10 00:25:26 +00:00
Jan Sjodin
f699e1cb43 Add front() method to SetVector.
Differential Revision: https://reviews.llvm.org/D27262

llvm-svn: 297398
2017-03-09 18:25:07 +00:00
Zachary Turner
b21c035434 Work around an ICE on MSVC 2017.
MSVC 2017 was released today, and I found one bug in the
compiler which prevents a successful build of LLVM.  This
patch works around the bug in a fairly benign way.

llvm-svn: 297255
2017-03-08 01:57:40 +00:00
Duncan P. N. Exon Smith
1e4b2c7632 ADT: Fix SmallPtrSet iterators in reverse mode
Fix SmallPtrSet::iterator behaviour and creation ReverseIterate is true.

  - Any function that creates an iterator now uses
    SmallPtrSet::makeIterator, which creates an iterator that
    dereferences to the given pointer.

  - In reverse-iterate mode, initialze iterator::End with "CurArray"
    instead of EndPointer.

  - In reverse-iterate mode, the current node is iterator::Buffer[-1].
    iterator::operator* and SmallPtrSet::makeIterator are the only ones
    that need to know.

  - Fix the assertions for reverse-iterate mode.

This fixes the tests Danny B added in r297182, and adds a couple of
others to confirm that dereferencing does the right thing, regardless of
how the iterator was found, and that iteration works correctly from each
return from find.

llvm-svn: 297234
2017-03-07 21:56:32 +00:00
Daniel Berlin
247bebf29e Make SmallPtrSet count and find able to take const PtrType's
Summary:
For our set/map types, count/find normally take const references.
This works well for non-pointer types, but can suck for pointer
types.

DenseSet<int *> foo;
const int *b = nullptr;
foo.count(b) does not work

but the equivalent reference version does work
(patch to fix DenseSet/DenseMap coming up)
For SmallPtrSet, you have no such option.

The following will not work right now:
SmallPtrSet<int *> foo;
const int *b = nullptr;
foo.count(b);

This makes const correctness hard in some cases.
Example:
SmallPtrSet<Instruction *> InstructionsToErase;

You can't make this SmallPtrSet<const Instruction *> because then you
can't erase the instruction.  If I want to see if something is in the
set, I may only have a const Instruction *.  Given that count and find
are non-mutating, this should just work.

The places in our code base that do this resort to const_cast :(.

This patch makes count and find able to be used with const Instruction
* in the above SmallPtrSet examples.

This is a bit annoying because of where C++ applies the const, so we
have to remove the pointer type from the passed-in-type and rebuild it
with const.

Reviewers: dblaikie

Subscribers: llvm-commits

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

llvm-svn: 297180
2017-03-07 18:47:48 +00:00
Craig Topper
f1ec36c63e [APInt] Add rvalue reference support to and, or, xor operations to allow their memory allocation to be reused when possible
This extends an earlier change that did similar for add and sub operations.

With this first patch we lose the fastpath for the single word case as operator&= and friends don't support it. This can be added there if we think that's important.

I had to change some functions in the APInt class since the operator overloads were moved out of the class and can't be used inside the class now. The getBitsSet change collides with another outstanding patch to implement it with setBits. But I didn't want to make this patch dependent on that series.

I've also removed the Or, And, Xor functions which were rarely or never used. I already commited two changes to remove the only uses of Or that existed.

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

llvm-svn: 297121
2017-03-07 05:36:19 +00:00
Craig Topper
0658ff9ba0 [APInt] Add getBitsSetFrom and setBitsFrom to set upper bits starting at a bit
We currently have methods to set a specified number of low bits, a specified number of high bits, or a range of bits. But looking at some existing code it seems sometimes we want to set the high bits starting from a certain bit. Currently we do this with something like getHighBits(BitWidth, BitWidth - StartBit). Or once we start switching to setHighBits, setHighBits(BitWidth - StartBit) or setHighBits(getBitWidth() - StartBit).

Particularly for the latter case it would be better to have a convenience method like setBitsFrom(StartBit) so we don't need to mention the bit width that's already known to the APInt object.

I considered just making setBits have a default value of UINT_MAX for the hiBit argument and we would internally MIN it with the bit width. So if it wasn't specified it would be treated as bit width. This would require removing the assertion we currently have on the value of hiBit and may not be as readable.

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

llvm-svn: 297114
2017-03-07 02:58:36 +00:00
Craig Topper
71df626b08 [APInt] Implement getLowBitsSet/getHighBitsSet/getBitsSet using setLowBits/setHighBits/setBits
This patch implements getLowBitsSet/getHighBitsSet/getBitsSet in terms of the new setLowBits/setHighBits/setBits methods by making an all 0s APInt and then calling the appropriate set method.

This also adds support to setBits to allow loBits/hiBits to be in the other order to match with getBitsSet behavior.

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

llvm-svn: 297112
2017-03-07 02:19:45 +00:00
Craig Topper
3a62ce44b4 [APInt] Add setLowBits/setHighBits methods to APInt.
Summary:
There are quite a few places in the code base that do something like the following to set the high or low bits in an APInt.

KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - 1);

For BitWidths larger than 64 this creates a short lived APInt with malloced storage. I think it might even call malloc twice. Its better to just provide methods that can set the necessary bits without the temporary APInt.

I'll update usages that benefit in a separate patch.

Reviewers: majnemer, MatzeB, davide, RKSimon, hans

Reviewed By: hans

Subscribers: llvm-commits

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

llvm-svn: 297111
2017-03-07 01:56:01 +00:00
Craig Topper
e2e31b6a01 [APInt] Move operator~ out of line to make it better able to reused memory allocation from temporary objects
Summary:
This makes operator~ take the APInt by value so if it came from a temporary APInt the move constructor will get invoked and it will be able to reuse the memory allocation from the temporary.

This is similar to what was already done for 2s complement negation.

Reviewers: hans, davide, RKSimon

Reviewed By: davide

Subscribers: llvm-commits

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

llvm-svn: 296997
2017-03-06 06:30:47 +00:00
Craig Topper
4e17c0a9f9 [APInt] Remove add and sub functions from APIntOps namespace.
They aren't used in tree and using the overloaded operators has more optimization opportunities.

llvm-svn: 296995
2017-03-06 04:35:01 +00:00
Craig Topper
ac0e488f8e [APInt] Remove unused And/Or/Xor methods. They just forward to the corresponding operator overload.
I plan to enhance the operator overloads to handle rvalues and these methods would not longer be optimal to use.

llvm-svn: 296993
2017-03-06 00:24:53 +00:00
Craig Topper
1c33eb3a5e [APInt] Remove the And/Or/Xor/Not functions from the APIntOps namespace.
Summary:
They aren't used anywhere in tree and its preferable to use the &, |, ^, or ~ operators.

With my patch to add rvalue reference support to &, |, ^ operators it also becomes less performant to use these functions.

Reviewers: RKSimon, davide, hans

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 296990
2017-03-05 16:41:11 +00:00
Craig Topper
860d21dff8 [APInt] Optimize APInt creation from uint64_t
Summary:
This patch moves the clearUnusedBits calls into the two different initialization paths for APInt from a uint64_t. This allows the compiler to better optimize the clearing of the unused bits for the single word case. And it puts the clearing for the multi word case into the initSlowCase function to save code. In the common case of initializing with 0 this allows the clearing to be completely optimized out for the single word case.

On my local x86 build this is showing a ~45kb reduction in the size of the opt binary.

Reviewers: RKSimon, hans, majnemer, davide, MatzeB

Reviewed By: hans

Subscribers: llvm-commits

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

llvm-svn: 296677
2017-03-01 21:06:18 +00:00
Craig Topper
67aa87241c [APInt] Use UINT64_MAX instead of ~integerPart(0). NFC
llvm-svn: 296322
2017-02-27 06:05:33 +00:00
Craig Topper
3de998317b [APInt] Use UINT64_MAX instead of ~uint64_t(0ULL). NFC
llvm-svn: 296301
2017-02-26 21:15:18 +00:00
Craig Topper
5fc36545f5 [APInt] Use UINT64_MAX instead of ~0ULL. NFC
llvm-svn: 296300
2017-02-26 19:28:48 +00:00
Craig Topper
0d258134e5 [APInt] Remove unnecessary early out from getLowBitsSet. The same case is handled equally well by the next check.
llvm-svn: 296299
2017-02-26 19:28:45 +00:00
Simon Pilgrim
879a5b0804 [APInt] Add APInt::extractBits() method to extract APInt subrange (reapplied)
The current pattern for extract bits in range is typically:

Mask.lshr(BitOffset).trunc(SubSizeInBits);

Which can be particularly slow for large APInts (MaskSizeInBits > 64) as they require the allocation of memory for the temporary variable.

This is another of the compile time issues identified in PR32037 (see also D30265).

This patch adds the APInt::extractBits() helper method which avoids the temporary memory allocation.

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

llvm-svn: 296272
2017-02-25 20:01:58 +00:00
NAKAMURA Takumi
046a844fb7 Revert r296215, "[PDB] General improvements to Stream library." and followings.
r296215, "[PDB] General improvements to Stream library."
r296217, "Disable BinaryStreamTest.StreamReaderObject temporarily."
r296220, "Re-enable BinaryStreamTest.StreamReaderObject."
r296244, "[PDB] Disable some tests that are breaking bots."
r296249, "Add static_cast to silence -Wc++11-narrowing."

std::errc::no_buffer_space should be used for OS-oriented errors for socket transmission.
(Seek discussions around llvm/xray.)

I could substitute s/no_buffer_space/others/g, but I revert whole them ATM.

Could we define and use LLVM errors there?

llvm-svn: 296258
2017-02-25 17:04:23 +00:00
Zachary Turner
c0166260b8 [PDB] General improvements to Stream library.
This adds various new functionality and cleanup surrounding the
use of the Stream library.  Major changes include:

* Renaming of all classes for more consistency / meaningfulness
* Addition of some new methods for reading multiple values at once.
* Full suite of unit tests for reader / writer functionality.
* Full set of doxygen comments for all classes.
* Streams now store their own endianness.
* Fixed some bugs in a few of the classes that were discovered
  by the unit tests.

llvm-svn: 296215
2017-02-25 00:44:30 +00:00