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

2363 Commits

Author SHA1 Message Date
Tim Shen
e69d467a94 [ADT] Change PostOrderIterator to use NodeRef. NFC.
Reviewers: dblaikie

Subscribers: mzolotukhin, llvm-commits

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

llvm-svn: 278752
2016-08-15 21:52:54 +00:00
Mehdi Amini
784f5239a9 [ADT] Add a reserve() method to DenseSet as well as an insert() for R-value
Recommit 278600 with some fixes to make the test more robust.

llvm-svn: 278604
2016-08-13 20:42:19 +00:00
Mehdi Amini
19082f556e Revert "[ADT] Add a reserve method to DenseSet as well as an insert() for R-value"
This reverts commit r278600. The unittest does not pass on MSVC, there is
an extra move. Investigating how to make it more robust.

llvm-svn: 278603
2016-08-13 20:14:39 +00:00
Yaron Keren
a7a54d9a58 Limit DenseMap::setNumEntries input to 1<<31, in accordance with the 31 bits allocated to NumEntries.
std::numeric_limits<int>::max() may be something else than 1<<31.

llvm-svn: 278602
2016-08-13 19:46:31 +00:00
Mehdi Amini
fc467f872b [ADT] Add a reserve method to DenseSet as well as an insert() for R-value
llvm-svn: 278600
2016-08-13 19:40:13 +00:00
Eugene Zelenko
10633be3a7 Fix some Clang-tidy modernize-use-using and Include What You Use warnings.
Differential revision: https://reviews.llvm.org/D23478

llvm-svn: 278583
2016-08-13 00:50:41 +00:00
Tim Shen
1190d0c314 [ADT] Add filter_iterator for filtering elements
Differential Revision: https://reviews.llvm.org/D22951

llvm-svn: 278569
2016-08-12 22:03:28 +00:00
Duncan P. N. Exon Smith
cfb5e5c89c ADT: Remove stale header comments about next/prev after r278532
Thanks to Mehdi for noticing.

llvm-svn: 278542
2016-08-12 18:14:42 +00:00
Duncan P. N. Exon Smith
e9d11a8a23 Hide type trait from r278532 from MSVC
The fixup from r278537 was insufficient.  Just #ifdef it out for MSVC.

llvm-svn: 278539
2016-08-12 18:10:29 +00:00
Duncan P. N. Exon Smith
5f3a13feda Try to appease win7 bots after r278532 by cleaning up type trait
The HasGetNext type trait was cluttered with a few things it didn't
need.  Try to clean it up, hoping to fix windows bots:
  http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/38063

I may just have to delete the trait...

llvm-svn: 278537
2016-08-12 17:54:54 +00:00
Duncan P. N. Exon Smith
e2d742d768 ADT: Remove the ilist_nextprev_traits customization point
No one is using the capability to implement next and prev another way
(since lld stopped doing it in r278468).  Remove the customization point
by moving the API from ilist_nextprev_traits<T> to ilist_node_access.

The old traits class is still useful/necessary API as a target for
friends of node types that inherit privately from ilist_node.
Eventually I plan to either remove it entirely or move the template
parameters to the methods.

(Note: if there's desire to bring back customization of next/prev
pointers in the future (e.g., to pack some bits in there), I think a
traits class like this is an awkward way to accomplish it.  Instead, we
should change ilist<T> to be ilist<ilist_node<T>>, and give an extra
template parameter to ilist_node.)

llvm-svn: 278532
2016-08-12 17:32:34 +00:00
Duncan P. N. Exon Smith
2e8f72520b ADT: Share code for embedded sentinel traits, NFC
Share code for the (mostly problematic) embedded sentinel traits.
- Move the LLVM_NO_SANITIZE("object-size") attribute to
  ilist_half_embedded_sentinel_traits and ilist_embedded_sentinel_traits
  (previously it spread throughout the code duplication).
- Add an ilist_full_embedded_sentinel_traits which has no UB (but has
  the downside of storing the complete node).
- Replace all the custom sentinel traits in LLVM with a declaration of
  ilist_sentinel_traits that inherits from one of the embedded sentinel
  traits classes.

There are still custom sentinel traits in other LLVM subprojects.  I'll
remove those in a follow-up.

Nothing at all should be changing here, this is just rearranging code.
Note that the final goal here is to remove the sentinel traits
altogether, settling on the memory layout of
ilist_half_embedded_sentinel_traits without the UB.  This intermediate
step moves the logic into ilist.h.

llvm-svn: 278513
2016-08-12 15:00:55 +00:00
Duncan P. N. Exon Smith
bdb3b06958 ADT: Remove all ilist_iterator => pointer casts, NFC
Remove all ilist_iterator to pointer casts.  There were two reasons for
casts:

  - Checking for an uninitialized (i.e., null) iterator.  I added
    MachineInstrBundleIterator::isValid() to check for that case.

  - Comparing an iterator against the underlying pointer value while
    avoiding converting the pointer value to an iterator.  This is
    occasionally necessary in MachineInstrBundleIterator, since there is
    an assertion in the constructors that the underlying MachineInstr is
    not bundled (but we don't care about that if we're just checking for
    pointer equality).

To support the latter case, I rewrote the == and != operators for
ilist_iterator and MachineInstrBundleIterator.

  - The implicit constructors now use enable_if to exclude
    const-iterator => non-const-iterator conversions from overload
    resolution (previously it was a compiler error on instantiation, now
    it's SFINAE).

  - The == and != operators are now global (friends), and are not
    templated.

  - MachineInstrBundleIterator has overloads to compare against both
    const_pointer and const_reference.  This avoids the implicit
    conversions to MachineInstrBundleIterator that assert, instead just
    checking the address (and I added unit tests to confirm this).

Notably, the only remaining uses of ilist_iterator::getNodePtrUnchecked
are in ilist.h, and no code outside of ilist*.h directly relies on this
UB end-iterator-to-pointer conversion anymore.  It's still needed for
ilist_*sentinel_traits, but I'll clean that up soon.

llvm-svn: 278478
2016-08-12 05:05:36 +00:00
David Majnemer
95fedaaedc Use the range variant of transform instead of unpacking begin/end
No functionality change is intended.

llvm-svn: 278476
2016-08-12 04:32:42 +00:00
David Majnemer
9880e078f0 Use the range variant of remove_if instead of unpacking begin/end
No functionality change is intended.

llvm-svn: 278475
2016-08-12 04:32:37 +00:00
Duncan P. N. Exon Smith
e7746af20b ADT: Add ilist_iterator conversions to/from ilist_node
Allow an ilist_iterator to be constructed from an ilist_node, and give
access to the underlying ilist_node as well.

This will be used immediately in lld to support a type-erasure use case.
Longer term, they'll stick around once the iterator is using
ilist_node<NodeTy>* instead of NodeTy*.

llvm-svn: 278467
2016-08-12 03:35:33 +00:00
Tim Shen
f3b1df95f7 [ADT] Migrate DepthFirstIterator to use NodeRef
Summary:
Notice that the data layout is changed: instead of using
std::pair<PointerIntPair<NodeType*, 1>, ChildItTy>, now use
std::pair<NodeRef, Optional<ChildItTy>>.

A NFC but worth noticing change is operator==(), since we only compare
an iterator against end(), it's better to put an assert there and make
people noticed when it fails.

Reviewers: dblaikie, chandlerc

Subscribers: mzolotukhin, llvm-commits

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

llvm-svn: 278437
2016-08-11 22:36:16 +00:00
David Majnemer
85242fb9f9 Use the range variant of find instead of unpacking begin/end
If the result of the find is only used to compare against end(), just
use is_contained instead.

No functionality change is intended.

llvm-svn: 278433
2016-08-11 22:21:41 +00:00
David Majnemer
5423e4bff5 Use range algorithms instead of unpacking begin/end
No functionality change is intended.

llvm-svn: 278417
2016-08-11 21:15:00 +00:00
Tim Shen
5026b80249 [ADT] Add relation operators for Optional
Summary: Make Optional's behavior the same as the coming std::optional.

Reviewers: dblaikie

Subscribers: llvm-commits

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

llvm-svn: 278397
2016-08-11 20:10:15 +00:00
Tim Shen
ff8eb1a70e [ADT] Move LLVM_ATTRIBUTE_UNUSED_RESULT to the function, otherwise gcc 4.8 complains about it.
It's a fix for the original patch r278251.

llvm-svn: 278298
2016-08-10 22:35:38 +00:00
Tim Shen
6514f5cdd0 [ADT] Removed synthesized constructor introduced in r278251, since MSVC doesn't support them
llvm-svn: 278259
2016-08-10 18:08:38 +00:00
Tim Shen
8573eb4217 [ADT] Add make_scope_exit().
Summary: make_scope_exit() is described in C++ proposal p0052r2, which uses RAII to do cleanup works at scope exit.

Reviewers: chandlerc

Subscribers: llvm-commits

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

llvm-svn: 278251
2016-08-10 17:52:09 +00:00
Tim Shen
2df4c154e7 [ADT] Change iterator_adaptor_base's default template arguments to forward more underlying typedefs
Reviewers: chandlerc

Subscribers: llvm-commits

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

llvm-svn: 278157
2016-08-09 20:23:13 +00:00
Tim Shen
4df0ad8244 [ADT] NFC: Generalize GraphTraits requirement of "NodeType *" in interfaces to "NodeRef", and migrate SCCIterator.h to use NodeRef
Summary: By generalize the interface, users are able to inject more flexible Node token into the algorithm, for example, a pair of vector<Node>* and index integer. Currently I only migrated SCCIterator to use NodeRef, but more is coming. It's a NFC.

Reviewers: dblaikie, chandlerc

Subscribers: llvm-commits

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

llvm-svn: 277399
2016-08-01 22:32:20 +00:00
Chandler Carruth
cd6624d554 [ADT] Add 'consume_front' and 'consume_back' methods to StringRef which
are very handy when parsing text.

They are essentially a combination of startswith and a self-modifying
drop_front, or endswith and drop_back respectively.

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

llvm-svn: 277288
2016-07-31 02:19:13 +00:00
Jordan Rose
1ccdcb20d6 Fix r276671 to not use a defaulted move constructor.
MSVC won't provide the body of this move constructor and assignment
operator, possibly because the copy constructor is banned. Just write
it manually.

llvm-svn: 276685
2016-07-25 20:34:25 +00:00
Jordan Rose
d8e923bb4b StringSwitch cannot be copied (take 2).
This prevents StringSwitch from being used with 'auto', which is
important because the inferred type is StringSwitch rather than the
result type. This is a problem because StringSwitch stores addresses
of temporary values rather than copying or moving the value into its
own storage.

This is a compromise that still allows wrapping StringSwitch in other
temporary structures, which (unlike StringSwitch) may be non-trivial
to set up and therefore want to at least be movable. (For an example,
see QueryParser.cpp in clang-tools-extra.)

Changing this uncovered the bug in PassBuilder, also in this patch.
Clang doesn't seem to have any occurrences of the issue.

Re-commit of r276652.

llvm-svn: 276671
2016-07-25 18:34:51 +00:00
Jordan Rose
81fe82436f Revert "StringSwitch cannot be copied or moved."
This reverts commit r276652. The clang-query tool is currently
relying on this behavior. I'll try again later.

llvm-svn: 276661
2016-07-25 17:28:33 +00:00
Jordan Rose
199957b97b StringSwitch cannot be copied or moved.
...but most importantly, it cannot be used well with 'auto', because
the inferred type is StringSwitch rather than the result type. This
is a problem because StringSwitch stores addresses of temporary
values rather than copying or moving the value into its own storage.

Changing this uncovered the bug in PassBuilder, also in this patch.
Clang doesn't seem to have any occurrences of the issue.

llvm-svn: 276652
2016-07-25 17:08:24 +00:00
Pete Cooper
a18d1734a0 Use RValue refs in APInt add/sub methods.
This adds versions of operator + and - which are optimized for the LHS/RHS of the
operator being RValue's.  When an RValue is available, we can use its storage space
instead of allocating new space.

On code such as ConstantRange which makes heavy use of APInt's over 64-bits in size,
this results in significant numbers of saved allocations.

Thanks to David Blaikie for all the review and most of the code here.

llvm-svn: 276470
2016-07-22 20:55:46 +00:00
Benjamin Kramer
6d65c1193c Weaken ThreadSafeRefCountedBase atomics.
Doesn't make a difference on x86, but avoids memory barriers on
weakly-ordered archs like PowerPC and ARM.

llvm-svn: 276291
2016-07-21 15:06:50 +00:00
Benjamin Kramer
38c61d7923 [DenseMap] Add a C++17-style try_emplace method.
This provides an elegant pattern to solve the "construct if not in map
already" problem we have many times in LLVM. Without try_emplace we
either have to rely on a sentinel value (nullptr) or do two lookups.

llvm-svn: 276277
2016-07-21 13:37:53 +00:00
Benjamin Kramer
750272d02a Rename StringMap::emplace_second to try_emplace.
Coincidentally this function maps to the C++17 try_emplace. Rename it
for consistentcy with C++17 std::map. NFC.

llvm-svn: 276276
2016-07-21 13:37:48 +00:00
Justin Lebar
a636e42b86 [ADT] Warn on unused results from ArrayRef and StringRef functions that read like they might mutate.
Summary:
Functions like "slice" and "drop_front" sound like they might mutate the
underlying object, but they don't.  Warning on unused results would have
saved me an hour yesterday, and I'm sure I'm not the only one.

LLVM and Clang are clean wrt this warning after D22540.

Reviewers: majnemer

Subscribers: sanjoy, chandlerc, llvm-commits

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

llvm-svn: 276058
2016-07-19 23:19:25 +00:00
Daniel Sanders
e79a374823 [mips] Recognise the triple used by Debian stretch for mips64el.
Summary:
The triple used for this distribution is mips64el-linux-gnuabi64.

Reviewers: sdardis

Subscribers: sdardis, llvm-commits

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

llvm-svn: 275966
2016-07-19 10:22:19 +00:00
Dehao Chen
84b1505453 [PM] Convert IVUsers analysis to new pass manager.
Summary: Convert IVUsers analysis to new pass manager.

Reviewers: davidxl, silvas

Subscribers: junbuml, sanjoy, llvm-commits, mzolotukhin

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

llvm-svn: 275698
2016-07-16 22:51:33 +00:00
Justin Lebar
2ce62bc5b9 Force a semicolon at the end of the LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE() macro.
This silences a warning about an extra semicolon on gcc.

llvm-svn: 275349
2016-07-13 23:52:19 +00:00
Justin Lebar
98656f3236 [ADT] Add LLVM_MARK_AS_BITMASK_ENUM, used to enable bitwise operations on enums without static_cast.
Summary: Normally when you do a bitwise operation on an enum value, you
get back an instance of the underlying type (e.g. int).  But using this
macro, bitwise ops on your enum will return you back instances of the
enum.  This is particularly useful for enums which represent a
combination of flags.

Suppose you have a function which takes an int and a set of flags.  One
way to do this would be to take two numeric params:

  enum SomeFlags { F1 = 1, F2 = 2, F3 = 4, ... };
  void Fn(int Num, int Flags);

  void foo() {
    Fn(42, F2 | F3);
  }

But now if you get the order of arguments wrong, you won't get an error.

You might try to fix this by changing the signature of Fn so it accepts
a SomeFlags arg:

  enum SomeFlags { F1 = 1, F2 = 2, F3 = 4, ... };
  void Fn(int Num, SomeFlags Flags);

  void foo() {
    Fn(42, static_cast<SomeFlags>(F2 | F3));
  }

But now we need a static cast after doing "F2 | F3" because the result
of that computation is the enum's underlying type.

This patch adds a mechanism which gives us the safety of the second
approach with the brevity of the first.

  enum SomeFlags {
    F1 = 1, F2 = 2, F3 = 4, ..., F_MAX = 128,
    LLVM_MARK_AS_BITMASK_ENUM(F_MAX)
  };

  void Fn(int Num, SomeFlags Flags);

  void foo() {
    Fn(42, F2 | F3);  // No static_cast.
  }

The LLVM_MARK_AS_BITMASK_ENUM macro enables overloads for bitwise
operators on SomeFlags.  Critically, these operators return the enum
type, not its underlying type, so you don't need any static_casts.

An advantage of this solution over the previously-proposed BitMask class
[0, 1] is that we don't need any wrapper classes -- we can operate
directly on the enum itself.

The approach here is somewhat similar to OpenOffice's typed_flags_set
[2].  But we skirt the need for a wrapper class (and a good deal of
complexity) by judicious use of enable_if.  We SFINAE on the presence of
a particular enumerator (added by the LLVM_MARK_AS_BITMASK_ENUM macro)
instead of using a traits class so that it's impossible to use the enum
before the overloads are present.  The solution here also seamlessly
works across multiple namespaces.

[0] http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150622/283369.html
[1] http://lists.llvm.org/pipermail/llvm-commits/attachments/20150623/073434b6/attachment.obj
[2] https://cgit.freedesktop.org/libreoffice/core/tree/include/o3tl/typed_flags_set.hxx

Reviewers: chandlerc, rsmith

Subscribers: llvm-commits

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

llvm-svn: 275292
2016-07-13 18:23:16 +00:00
Pirama Arumuga Nainar
5892fda7c5 Add RenderScript ArchType
Summary:
Add renderscript32 and renderscript64 ArchTypes.  This is to configure
the ABI requirement on 32-bit RenderScript that 'long' types have 64-bit
size and alignment.  64-bit RenderScript is the same as AArch64, but is
added here for completeness.

Reviewers: echristo, rsmith

Subscribers: aemerson, jfb, rampitec, dschuff, mehdi_amini, llvm-commits, srhines

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

llvm-svn: 274412
2016-07-02 00:23:09 +00:00
Chandler Carruth
69a27222d9 [ADT] Add a new data structure for managing a priority worklist where
re-insertion of entries into the worklist moves them to the end.

This is fairly similar to a SetVector, but helps in the case where in
addition to not inserting duplicates you want to adjust the sequence of
a pop-off-the-back worklist.

I'm not at all attached to the name of this data structure if others
have better suggestions, but this is one that David Majnemer brought up
in IRC discussions that seems plausible.

I've trimmed the interface down somewhat from SetVector's interface
because several things make less sense here IMO: iteration primarily.
I'd prefer to add these back as we have users that need them. My use
case doesn't even need all of what is provided here. =]

I've also included a basic unittest to make sure this functions
reasonably.

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

llvm-svn: 274198
2016-06-30 02:32:20 +00:00
Davide Italiano
5a9dae8e37 [Triple] Add isLittleEndian().
This allows us to query about the endianness without having to
look at DataLayout. The API will be used (and tested) in lld,
in order to find out the endianness of BitcodeFiles.

Briefly discussed with Rafael.

llvm-svn: 274090
2016-06-29 01:56:27 +00:00
Pawel Bylica
082b2dbaae APInt: remove unsued param in private method. NFC
Reviewers: davide

Subscribers: davide, llvm-commits

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

llvm-svn: 273851
2016-06-27 08:31:48 +00:00
Rafael Espindola
915dc69c99 Add support for musl-libc on ARM Linux.
Patch by Lei Zhang!

llvm-svn: 273726
2016-06-24 21:14:33 +00:00
Vassil Vassilev
2d8201a373 Typo.
llvm-svn: 273592
2016-06-23 18:13:46 +00:00
David Majnemer
bed83762f6 [ADT] Add a range variant of std::transform
This will be used in a followup change in clang.

llvm-svn: 273520
2016-06-23 00:14:26 +00:00
Daniel Sanders
8f2778b973 [arm+x86] Make GNU variants behave like GNU w.r.t combining sin+cos into sincos.
Summary:
canCombineSinCosLibcall() would previously combine sin+cos into sincos for
GNUX32/GNUEABI/GNUEABIHF regardless of whether UnsafeFPMath were set or not.
However, GNU would only combine them for UnsafeFPMath because sincos does not
set errno like sin and cos do. It seems likely that this is an oversight.

Reviewers: t.p.northover

Subscribers: t.p.northover, aemerson, llvm-commits, rengolin

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

llvm-svn: 273259
2016-06-21 12:29:03 +00:00
David Majnemer
ab562bff72 Replace silly uses of 'signed' with 'int'
llvm-svn: 273244
2016-06-21 05:10:24 +00:00
Evgeniy Stepanov
0e1477e15b Fix BitVector move ctor/assignment.
Current implementation leaves the object in an invalid state.

This reverts commit bf0c389ac683cd6c0e5959b16537e59e5f4589e3.

llvm-svn: 272965
2016-06-16 21:45:13 +00:00
Matthias Braun
cf19d2a645 Statistic: Add machine parseable json output
- We lacked a short unique identifier for a statistics, so I renamed the
  current "Name" field that just contained the DEBUG_TYPE name of the
  current file to DebugType and added a new "Name" field that contains
  the C++ identifier of the statistic variable.
- Add the -stats-json option which outputs statistics in json format.

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

llvm-svn: 272826
2016-06-15 20:19:16 +00:00
Rafael Espindola
417a1022df Add a Musl environment to the triple.
It will be used in clang.

Patch by Lei Zhang.

llvm-svn: 272660
2016-06-14 12:45:33 +00:00
Sanjoy Das
858bed9b6b [STLExtras] Introduce and use llvm::count_if; NFC
(This is split out from was D21115)

llvm-svn: 272435
2016-06-10 21:18:39 +00:00
Sean Silva
7c30828bb9 Fix stale name in comment.
llvm-svn: 272382
2016-06-10 08:48:49 +00:00
Benjamin Kramer
d415569b3b Apply most suggestions of clang-tidy's performance-unnecessary-value-param
Avoids unnecessary copies. All changes audited & pass tests with asan.
No functional change intended.

llvm-svn: 272190
2016-06-08 19:09:22 +00:00
Devin Coughlin
9a58e5e9f3 STLExtras: Add convenience is_contained() function.
This commit adds a convenience is_contained() function
which checks if an element exists in a container. It is part of a larger
series of patches adding an MPI checker to the clang static analyzer.

Reviewers: dblaikie,bkramer

A patch by Alexander Droste!

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

llvm-svn: 271757
2016-06-04 00:49:46 +00:00
Ben Craig
6ab6ea46ef Doxygen for FoldingSet::reserve and FoldingSet::capacity
llvm-svn: 271694
2016-06-03 17:50:14 +00:00
Ben Craig
d37457ba08 Adding reserve and capacity methods to FoldingSet
http://reviews.llvm.org/D20930

llvm-svn: 271669
2016-06-03 13:54:48 +00:00
Pete Cooper
850888b791 Make APInt negate just do a 2's complement negate instead of subtract. NFC.
This is part of an effort to shave allocations from APInt heavy paths.  I'll
be moving many of the other operators to r-value references soon and this is
a step towards doing that without too much duplication.

Saves 15k allocations when doing 'opt -O2 verify-uselistorder.bc'.

llvm-svn: 271556
2016-06-02 18:11:54 +00:00
Ahmed Bougacha
64f0370857 [ADT] Pass ArrayRef::slice size_t instead of unsigned.
Also fix slice wrappers drop_front and drop_back.
The unittests are pretty awkward, but do the job; alternatives
welcome!

..and yes, I do have ArrayRefs with more than 4 billion elements.

llvm-svn: 271546
2016-06-02 17:26:03 +00:00
Chandler Carruth
2c6eeb37b3 Switch statistics to use relaxed updates to a std::atomic.
This removes usage of the hacky, incorrect, and TSan-unfriendly
home-grown atomics. It should actually be more efficient in some cases.

Based on our existing usage of <atomic>, all of this is portably
available AFAICT. One small challenge is initializing the stastic, but
I've tried a comparable sample out on MSVC (the most likely to complain
here) and it seems to work. Will have to watch the build bots of course.

llvm-svn: 271504
2016-06-02 08:44:05 +00:00
Chandler Carruth
dcd88d1c3c [ADT] Remove unused multiply and divide operator overloads on
statistics.

Scaling statistics atomically doesn't make any sense anyways, and none
were using these. If you find yourself wanting to do this, you should
probably keep a local count that you scale and then apply that after
scaling to the shared statistic object.

llvm-svn: 271503
2016-06-02 08:37:14 +00:00
David Blaikie
06b8355a88 SmallVector: Replace some pre-C++11 move helpers with standard algorithms
llvm-svn: 271036
2016-05-27 19:05:14 +00:00
Benjamin Kramer
a855b3205f Apply clang-tidy's misc-move-constructor-init throughout LLVM.
No functionality change intended, maybe a tiny performance improvement.

llvm-svn: 270997
2016-05-27 14:27:24 +00:00
Pete Cooper
96fc7f8340 Don't allocate unnecessarily in APInt::operator[+-]. NFC.
APInt::operator+(uint64_t) just forwarded to operator+(const APInt&).

Constructing the APInt for the RHS takes an allocation which isn't
required.  Also, for APInt's in the slow path, operator+ would
call add() internally which iterates over both arrays of values.  Instead
we can use add_1 and sub_1 which only iterate while there is something to do.

Using the memory for 'opt -O2 verify-uselistorder.lto.opt.bc -o opt.bc'
(see r236629 for details), this reduces the number of allocations from
23.9M to 22.7M.

llvm-svn: 270959
2016-05-27 03:42:17 +00:00
Xinliang David Li
e9cf4364da Add a new helper API in triple /NFC
llvm-svn: 270726
2016-05-25 17:11:31 +00:00
Richard Smith
43a8b67421 Add a (size, value) constructor to TinyPtrVector.
llvm-svn: 269711
2016-05-16 21:57:47 +00:00
Richard Smith
b47dd66659 Add missing TinyPtrVector functionality: reverse iterators and conversion of
TinyPtrVector<T*> to ArrayRef<const T*>.

llvm-svn: 269710
2016-05-16 21:45:58 +00:00
Chandler Carruth
7b7724634c Another attempt to fix MSVC by explicitly disabling the conversion
operator when the value type can't be initialized from the argument
type. Testing with the online MSVC compiler is finally happy with this,
let's see if the build bot will tolerate it.

llvm-svn: 269501
2016-05-13 22:20:43 +00:00
Chandler Carruth
0e0ff74b55 Yet another attempt to appease MSVC...
llvm-svn: 269409
2016-05-13 11:39:37 +00:00
Chandler Carruth
da6a122f1e Try to fix MSVC by explicitly providing copy and move constructors so it
doesn't try to use the converting constructor template for those
operations.

llvm-svn: 269406
2016-05-13 10:55:23 +00:00
Chandler Carruth
6004493dd0 [ADT] Add an 'llvm::seq' function which produces an iterator range over
a sequence of values.

It increments through the values in the half-open range: [Begin, End),
producing those values when indirecting the iterator. It should support
integers, iterators, and any other type providing these basic arithmetic
operations.

This came up in the C++ standards committee meeting, and it seemed like
a useful construct that LLVM might want as well, and I wanted to
understand how easily we could solve it. I suspect this can be used to
write simpler counting loops even in LLVM along the lines of:

  for (int i : seq(0, v.size())) {
    ...
  };

As part of this, I had to fix the lack of a proxy object returned from
the operator[] in our iterator facade.

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

llvm-svn: 269390
2016-05-13 03:57:50 +00:00
Eugene Zelenko
8694825d8f Fix some Clang-tidy readability-simplify-boolean-expr and Include What You Use warnings.
Differential revision: reviews.llvm.org/D19946

llvm-svn: 268689
2016-05-05 21:35:47 +00:00
Marcin Koscielnicki
fe2c3bbeba [X86] Extend some Linux special cases to cover kFreeBSD.
Both Linux and kFreeBSD use glibc, so follow similiar code paths.
Add isTargetGlibc to check for this, and use it instead of isTargetLinux
in a few places.

Fixes PR22248 for kFreeBSD.

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

llvm-svn: 268624
2016-05-05 11:35:51 +00:00
Igor Laevsky
48c396748c [RS4GC] Use SetVector/MapVector instead of DenseSet/DenseMap to guarantee stable ordering
Goal of this change is to guarantee stable ordering of the statepoint arguments and other 
newly inserted values such as gc.relocates. Previously we had explicit sorting in a couple
of places. However for unnamed values ordering was partial and overall we didn't have any 
strong invariant regarding it. This change switches all data structures to use SetVector's
and MapVector's which provide possibility for deterministic iteration over them.
Explicit sorting is now redundant and was removed.

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

llvm-svn: 268502
2016-05-04 14:55:36 +00:00
Reid Kleckner
9a635e6090 [ADT] Add drop_front method to ArrayRef
We have it for StringRef but not ArrayRef, and ArrayRef has drop_back,
so I see no reason it shouldn't have drop_front. Splitting this out of a
change that I have that will use this funcitonality.

llvm-svn: 268434
2016-05-03 20:53:20 +00:00
Richard Smith
e4b2229799 Fix bogus documentation for StringRef::slice in the End < Start case.
llvm-svn: 267831
2016-04-28 00:57:14 +00:00
David Majnemer
c78d15d0c3 [WinEH] Update SplitAnalysis::computeLastSplitPoint to cope with multiple EH successors
We didn't have logic to correctly handle CFGs where there was more than
one EH-pad successor (these are novel with WinEH).
There were situations where a register was live in one exceptional
successor but not another but the code as written would only consider
the first exceptional successor it found.

This resulted in split points which were insufficiently early if an
invoke was present.

This fixes PR27501.

N.B.  This removes getLandingPadSuccessor.

llvm-svn: 267412
2016-04-25 14:31:32 +00:00
Rafael Espindola
becf204913 Add a CachedHash structure.
A DenseMap doesn't store the hashes, so it needs to recompute them when
the table is resized.

In some applications the hashing cost is noticeable. That is the case
for example in lld for symbol names (StringRef).

This patch adds a templated structure that can wraps any value that can
go in a DenseMap and caches the hash.

llvm-svn: 266981
2016-04-21 12:16:21 +00:00
Mehdi Amini
f5346020b9 ThinLTO: add module caching handling.
Differential Revision: http://reviews.llvm.org/D18494

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266959
2016-04-21 05:54:23 +00:00
Mehdi Amini
9ff867f98c [NFC] Header cleanup
Removed some unused headers, replaced some headers with forward class declarations.

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

Patch by Eugene Kosov <claprix@yandex.ru>

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266595
2016-04-18 09:17:29 +00:00
Mehdi Amini
70b295014e Remove some unneeded headers and replace some headers with forward class declarations (NFC)
Differential Revision: http://reviews.llvm.org/D19154

Patch by Eugene Kosov <claprix@yandex.ru>

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266524
2016-04-16 07:51:28 +00:00
Richard Smith
0024f020dc Add some missing #includes, found by C++ modules selfhost.
llvm-svn: 266500
2016-04-16 00:42:37 +00:00
Matt Arsenault
795072118d APInt: Add overload of isMask
This mimics the version in MathExtras.h which isn't testing for a
specific mask size.

llvm-svn: 266101
2016-04-12 18:17:23 +00:00
JF Bastien
16f8e8748e Fix hash_integer_value
Broken in D18938 because underlying_type only works for enums and not all stdlibs are sad when given a non-enum. Bots error out with 'only enumeration types have underlying types'.

There's probably a clever enable_if-ism that I can do with underlying_type and the actual integer value, but is_integral_or_enum also accepts implicit conversion so I need to ponder my life choices a bit before committing to template magic. A quick fix for now.

llvm-svn: 265880
2016-04-09 20:25:02 +00:00
JF Bastien
fd71b93500 is_integral_or_enum ❥ enum class ⇒ hashable enum class
Summary:
As discussed in D18775 making AtomicOrdering an enum class makes it non-hashable, which shouldn't be the case. Hashing.h defines hash_value for all is_integral_or_enum, but type_traits.h's definition of is_integral_or_enum only checks for *inplicit* conversion to integral types which leaves enum classes out and is very confusing because is_enum is true for enum classes.

This patch:
  - Adds a check for is_enum when determining is_integral_or_enum.
  - Explicitly converts the value parameter in hash_value to handle enum class hashing.

Note that the warning at the top of Hashing.h still applies: each execution of the program has a high probability of producing a different hash_code for a given input. Thus their values are not stable to save or persist, and should only be used during the execution for the construction of hashing datastructures.

Reviewers: dberlin, chandlerc

Subscribers: llvm-commits

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

llvm-svn: 265879
2016-04-09 20:04:34 +00:00
Duncan P. N. Exon Smith
d908c6425f IR: Use DenseSet instead of DenseMap for ConstantUniqueMap; NFC
Use a DenseSet instead of a DenseMap for constants in LLVMContextImpl.
Last time I looked at this was some time before r223588, when
DenseSet<V> had no advantage over DenseMap<V,char>.  After r223588,
there's a 50% memory savings.

This is all mechanical.  There were little bits of missing API from
DenseSet so I added the trivial implementations:

  - iterator::operator++(int)
  - template <class LookupKeyT> insert_as(ValueTy, LookupKeyT)

There should be no functionality change, just reduced memory consumption
(this wasn't on a profile or anything; just a cleanup I stumbled on).

llvm-svn: 265577
2016-04-06 17:56:08 +00:00
Mehdi Amini
d4b845cb1f Revert "ThinLTO: add module caching handling."
This reverts commit r265214, unintentionally commited.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265216
2016-04-02 05:08:18 +00:00
Mehdi Amini
0df8de9a1a ThinLTO: add module caching handling.
Reviewers: tejohnson

Subscribers: llvm-commits, joker.eph

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265214
2016-04-02 05:07:08 +00:00
Benjamin Kramer
aebef745f3 [ADT] Make StringMap's tombstone aligned.
This avoids undefined behavior when casting pointers to it. Also make
sure that we don't cast to a derived StringMapEntry before checking for
tombstone, as that may have different alignment requirements.

llvm-svn: 265145
2016-04-01 15:51:51 +00:00
Hal Finkel
66a0968e06 Add a copy constructor to StringMap
There is code under review that requires StringMap to have a copy constructor,
and this makes StringMap more consistent with our other containers (like
DenseMap) that have copy constructors.

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

llvm-svn: 264906
2016-03-30 19:54:56 +00:00
Eugene Zelenko
f9e799a8d6 Fix Clang-tidy modernize-deprecated-headers warnings in some files; other minor fixes.
Differential revision: http://reviews.llvm.org/D18469

llvm-svn: 264598
2016-03-28 17:40:08 +00:00
Jun Bum Lim
0857fa46b4 [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

llvm-svn: 264450
2016-03-25 19:28:08 +00:00
Jun Bum Lim
cd509e296e Revert "[SetVector] Add erase() method"
This reverts commit r264414.

llvm-svn: 264420
2016-03-25 16:49:16 +00:00
Jun Bum Lim
305aa24843 [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

llvm-svn: 264414
2016-03-25 16:04:43 +00:00
Mehdi Amini
b571577686 Fix perfect forwarding for StringMap
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 264391
2016-03-25 07:11:31 +00:00
Mehdi Amini
7f6c7f0a20 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>
llvm-svn: 264386
2016-03-25 05:58:04 +00:00
Mehdi Amini
aad049fea9 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>
llvm-svn: 264385
2016-03-25 05:57:57 +00:00
Mehdi Amini
bbd89f73ab 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>
llvm-svn: 264384
2016-03-25 05:57:52 +00:00
Mehdi Amini
cc356f2508 StringMap: reserve appropriate size when initializing from an initializer list
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 264383
2016-03-25 05:57:47 +00:00
David Blaikie
4824d34fa2 [ADT] C++11ify SmallVector::erase's arguments from iterator to const_iterator
llvm-svn: 264330
2016-03-24 20:25:51 +00:00
Richard Smith
8edc6624b9 Stop relying on mapped_iterator's function having a result_type. That facility
is deprecated in modern C++ and unnecessary since decltype can be used to query
the relevant type.

llvm-svn: 264321
2016-03-24 19:10:58 +00:00
Pete Cooper
0059979e14 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

llvm-svn: 264201
2016-03-23 21:49:31 +00:00
Mehdi Amini
c95ffc2050 Rename DenseMap::resize() into DenseMap::reserve() (NFC)
This is more coherent with usual containers.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 264026
2016-03-22 07:20:00 +00:00
Matt Arsenault
5d7eb096ca APFloat: Add frexp
llvm-svn: 263950
2016-03-21 16:49:16 +00:00
Matt Arsenault
f2fb55d608 Implement constant folding for bitreverse
llvm-svn: 263945
2016-03-21 15:00:35 +00:00
Mike Aizatsky
8b73d34d94 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.

llvm-svn: 263760
2016-03-17 23:32:20 +00:00
Mike Aizatsky
f856af3360 allow lambdas in mapped_iterator
Differential Revision: http://reviews.llvm.org/D17311

llvm-svn: 263759
2016-03-17 23:22:22 +00:00
Fiona Glaser
750f1d0625 DenseMap: make .resize() do the intuitive thing
In some places, like InstCombine, we resize a DenseMap to fit the elements
we intend to put in it, then insert those elements (to avoid continual
reallocations as it grows). But .resize(foo) doesn't actually do what
people think; it resizes to foo buckets (which is really an
implementation detail the user of DenseMap probably shouldn't care about),
not the space required to fit foo elements. DenseMap grows if 3/4 of its
buckets are full, so this actually causes one forced reallocation every
time instead of avoiding a reallocation.

This patch makes .resize(foo) do the intuitive thing: it grows to the size
necessary to fit foo elements without new allocations.

Also include a test to verify that .resize() actually does what we think it
does.

llvm-svn: 263522
2016-03-15 01:50:46 +00:00
Quentin Colombet
573b41c165 [ADT] Add a pop_back_val method to the SparseSet container.
The next commit will use it.

llvm-svn: 263455
2016-03-14 18:10:41 +00:00
Matt Arsenault
974dc48135 Fix build
llvm-svn: 263372
2016-03-13 05:22:08 +00:00
Matt Arsenault
26aa8f6035 APFloat: Fix ilogb for denormals
llvm-svn: 263370
2016-03-13 05:12:32 +00:00
Matt Arsenault
b9effef6fc APFloat: Fix scalbn handling of denormals
This was incorrect for denormals, and also failed
on longer exponent ranges.

llvm-svn: 263369
2016-03-13 05:11:51 +00:00
Sanjoy Das
3b791814db Introduce @llvm.experimental.deoptimize
Summary:
This intrinsic, together with deoptimization operand bundles, allow
frontends to express transfer of control and frame-local state from
one (typically more specialized, hence faster) version of a function
into another (typically more generic, hence slower) version.

In languages with a fully integrated managed runtime this intrinsic can
be used to implement "uncommon trap" like functionality.  In unmanaged
languages like C and C++, this intrinsic can be used to represent the
slow paths of specialized functions.

Note: this change does not address how `@llvm.experimental_deoptimize`
is lowered.  That will be done in a later change.

Reviewers: chandlerc, rnk, atrick, reames

Subscribers: llvm-commits, kmod, mjacob, maksfb, mcrosier, JosephTremoulet

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

llvm-svn: 263281
2016-03-11 19:08:34 +00:00
Mehdi Amini
ea71be934f libLTO: add a ThinLTOCodeGenerator on the model of LTOCodeGenerator.
This is intended to provide a parallel (threaded) ThinLTO scheme
for linker plugin use through the libLTO C API.

The intent of this patch is to provide a first implementation as a
proof-of-concept and allows linker to start supporting ThinLTO by
definiing the libLTO C API. Some part of the libLTO API are left
unimplemented yet. Following patches will add support for these.

The current implementation can link all clang/llvm binaries.

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 262977
2016-03-09 01:37:22 +00:00
Mehdi Amini
a4f4ae8aaf Add a new insert_as() method to DenseMap and use it for ConstantUniqueMap
Just like the existing find_as() method, the new insert_as() accepts
an extra parameter which is used as a key to find the bucket in the
map.
When creating a Constant, we want to check the map before actually
creating the object. In this case we have to perform two queries to
the map, and this extra parameter can save recomputing the hash value
for the second query.

This is a reapply of r260458, that was reverted because it was
suspected to be the cause of instability of an internal bot, but
wasn't confirmed.

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 262812
2016-03-07 00:51:00 +00:00
Duncan P. N. Exon Smith
0fa6439bcd Revert "CodeGen: MachineInstr::getIterator() => getInstrIterator(), NFC"
This reverts commit r261504, since it's not obvious the new name is
better:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160222/334298.html

I'll recommit if we get consensus that it's the right direction.

llvm-svn: 261567
2016-02-22 20:49:58 +00:00
Duncan P. N. Exon Smith
b2dab65ba3 CodeGen: MachineInstr::getIterator() => getInstrIterator(), NFC
Delete MachineInstr::getIterator(), since the term "iterator" is
overloaded when talking about MachineInstr.

- Downcast to ilist_node in iplist::getNextNode() and getPrevNode() so
  that ilist_node::getIterator() is still available.
- Add it back as MachineInstr::getInstrIterator().  This matches the
  naming in MachineBasicBlock.
- Add MachineInstr::getBundleIterator().  This is explicitly called
  "bundle" (not matching MachineBasicBlock) to disintinguish it clearly
  from ilist_node::getIterator().
- Update all calls.  Some of these I switched to `auto` to remove
  boiler-plate, since the new name is clear about the type.

There was one call I updated that looked fishy, but it wasn't clear what
the right answer was.  This was in X86FrameLowering::inlineStackProbe(),
added in r252578 in lib/Target/X86/X86FrameLowering.cpp.  I opted to
leave the behaviour unchanged, but I'll reply to the original commit on
the list in a moment.

llvm-svn: 261504
2016-02-21 22:58:35 +00:00
Duncan P. N. Exon Smith
4689c1c69e ADT: Disallow == and != between pointers and ilist iterators
I completely missed these non-class operators when I removed the
implicit conversions in r252380.  Remove them now.  r261498 should have
already removed all uses.

Note (repeated from r252380): if you have out-of-tree code, it should be
fairly easy to revert this patch downstream while you update your
out-of-tree call sites.  Note that these conversions are occasionally
latent bugs (that may happen to "work" now, but only because of getting
lucky with UB; follow-ups will change your luck).  When they are valid,
I suggest using `->getIterator()` to go from pointer to iterator, and
`&*` to go from iterator to pointer.

llvm-svn: 261499
2016-02-21 20:46:37 +00:00
Duncan P. N. Exon Smith
41a6ce2615 ADT: clang-format ilist_iterator, NFC
Also removed a couple of noisy (no-value-added) comments.

llvm-svn: 261492
2016-02-21 19:26:08 +00:00
Duncan P. N. Exon Smith
9ab1fdd06b ADT: Remove ilist_iterator random access API, NFC
Remove explicitly deleted random access API from ilist_iterator.
Since it no longer has implicit conversions to a pointer type, we
no longer need this protection.

llvm-svn: 261491
2016-02-21 19:23:18 +00:00
Jordan Rose
e196eb6e96 [ADT] Be less clever when using a nonce type for disambiguation.
Old compilers don't like constexpr, but we're only going to use this in one
place anyway: this file. Everyone else should go through PointerLikeTypeTraits.

Update to r261259.

llvm-svn: 261268
2016-02-18 22:03:23 +00:00
Jordan Rose
8c6650f01b [ADT] Fix PointerEmbeddedInt when the underlying type is uintptr_t.
...and when you try to store negative values in it.

llvm-svn: 261259
2016-02-18 21:00:08 +00:00
Vedant Kumar
edda1d67ad [ADT] Add StringRef::{l,r}trim(char) overloads (NFC)
Add support for trimming a single kind of character from a StringRef.
This makes the common case of trimming null bytes much neater. It's also
probably a bit speedier too, since it avoids creating a std::bitset in
find_{first,last}_not_of.

llvm-svn: 260925
2016-02-16 01:48:39 +00:00
Matthias Braun
ad3e9d1469 SmallPtrSet: Avoid initializing Array in the small case.
This patch avoids the initial memset at the cost of making iterators
slightly more complex. This should be beneficial as most SmallPtrSets
hold no or only a few elements, while iterating over them is less
common.

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

llvm-svn: 260913
2016-02-15 21:38:42 +00:00
Benjamin Kramer
2316eec7c0 [APInt] No need for a copy when taking min/max of an APInt.
llvm-svn: 260827
2016-02-13 17:23:27 +00:00
Matt Arsenault
b576160845 Add AMDGPU related triple vendors/OSes
As support expands to more runtimes, we'll need to
distinguish between more than just HSA and unknown.
This also lets us stop using unknown everywhere.

llvm-svn: 260790
2016-02-13 01:56:21 +00:00
Argyrios Kyrtzidis
94fe44f7a0 [ADT] Revert the llvm/ADT/OptionSet.h header and unit test.
llvm-svn: 260714
2016-02-12 19:47:35 +00:00
Argyrios Kyrtzidis
fde63b7154 [ADT] OptionSet: ifdef out some code that seems to be crashing MSVC.
llvm-svn: 260654
2016-02-12 04:36:48 +00:00
Argyrios Kyrtzidis
eaf4355f60 [ADT] Introduce ‘OptionSet’ in llvm/ADT headers, which is a utility class that makes it convenient to work with enumerators representing bit options.
llvm-svn: 260652
2016-02-12 02:48:26 +00:00
Mehdi Amini
4b1db4c68c Revert "Add a new insert_as() method to DenseMap and use it for ConstantUniqueMap"
This reverts commit r260458.

It was backported on an internal branch and broke stage2 build. Since
this can lead to weird random crash I'm reverting upstream as well
while investigating.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 260605
2016-02-11 22:00:36 +00:00
Jacques Pienaar
837592b498 [lanai] Add Lanai triple.
Add triple for the Lanai backend.

General Lanai backend discussion on llvm-dev thread "[RFC] Lanai backend".

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

llvm-svn: 260545
2016-02-11 17:16:20 +00:00
Mehdi Amini
c106fe9b9e Add the ability to initialize a StringSet from a pair of iterators (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 260461
2016-02-10 23:24:21 +00:00
Mehdi Amini
ec8aba4a5a Add a new insert_as() method to DenseMap and use it for ConstantUniqueMap
Summary:
Just like the existing find_as() method, the new insert_as() accepts
an extra parameter which is used as a key to find the bucket in the
map.
When creating a Constant, we want to check the map before actually
creating the object. In this case we have to perform two queries to
the map, and this extra parameter can save recomputing the hash value
for the second query.

Reviewers: dexonsmith, chandlerc

Subscribers: llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 260458
2016-02-10 23:07:29 +00:00
Matt Arsenault
abdf63cb3b Fix return type of bool function
llvm-svn: 260409
2016-02-10 19:04:12 +00:00
Jordan Rose
33941da363 [ADT] Add "return *this;" to PointerEmbeddedInt::operator=.
llvm-svn: 260407
2016-02-10 18:54:41 +00:00
Roman Divacky
aae2173227 Fix a typo.
llvm-svn: 260038
2016-02-07 15:50:55 +00:00
Matthias Braun
1ad84f2d28 SmallSet/SmallPtrSet: Refuse huge Small numbers
These sets do linear searching in small mode; It is not a good idea to
use huge numbers as the small value here, save people from themselves by
adding a static_assert.

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

llvm-svn: 259419
2016-02-01 22:05:16 +00:00
Craig Topper
548b47cf16 Remove utostr_32 as it has no uses anymore.
llvm-svn: 259331
2016-01-31 20:00:26 +00:00
Craig Topper
9c91186b26 Merge utohex_buffer into utohexstr, it's only caller. Also change utohexstr to use the std::string constructor that takes a start and end pointer. This saves a call to strlen. NFC
llvm-svn: 259329
2016-01-31 20:00:22 +00:00
Craig Topper
10624d8809 Use std::end instead of repeating buffer sizes.
llvm-svn: 259312
2016-01-31 01:12:35 +00:00
Matthias Braun
d03612ddc4 SmallPtrSet: Add missing include
llvm-svn: 259021
2016-01-28 05:09:01 +00:00
Matthias Braun
75154d690e SmallPtrSet: Make destructor available for inlining
llvm-svn: 259019
2016-01-28 04:49:14 +00:00
Matthias Braun
0a16f48325 SmallPtrSet: Share some code between copy/move constructor/assignment operator
llvm-svn: 259018
2016-01-28 04:49:11 +00:00
Matthias Braun
df154ae0af SmallPtrSet: Remove trailing whitespace, fix indentation
llvm-svn: 259017
2016-01-28 04:49:07 +00:00
Tim Northover
873c40a8de ARMv7k: base ABI decision on v7k Arch rather than watchos OS.
Various bits we want to use the new ABI actually compile with "-arch armv7k
-miphoneos-version-min=9.0". Not ideal, but also not ridiculous given how
slices work.

llvm-svn: 258975
2016-01-27 19:32:29 +00:00
Matthias Braun
f834c97f30 SmallPtrSet: Inline the part of insert_imp in the small case
Most of the time we only hit the small case, so it is beneficial to pull
it out of the insert_imp() implementation. This improves compile time
at least for non-LTO builds.

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

llvm-svn: 258908
2016-01-27 04:20:24 +00:00
Eugene Zelenko
966902f532 Fix Clang-tidy modernize-use-nullptr and modernize-use-override warnings; other minor fixes.
Differential revision: reviews.llvm.org/D16568

llvm-svn: 258831
2016-01-26 18:48:36 +00:00
Sanjay Patel
3bb30646d9 don't repeat function names in documentation comments; NFC
llvm-svn: 258699
2016-01-25 18:38:38 +00:00
Justin Lebar
640b3f9212 [CUDA] Add Target::isNVPTX().
Summary: Helper so we don't have to enumerate nvptx && nvptx64 everywhere.

Reviewers: echristo

Subscribers: llvm-commits, jhen, tra

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

llvm-svn: 258639
2016-01-23 21:12:22 +00:00
Bradley Smith
faae1a370a [ARM] Add ARMv8-M Baseline/Mainline LLVM targeting
llvm-svn: 257878
2016-01-15 10:24:39 +00:00