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

100 Commits

Author SHA1 Message Date
Chandler Carruth
ae65e281f3 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Simon Pilgrim
43e5ef164c [ADT][BitVector] Add push_back()
Add a higher performance alternative to calling resize() every time which performs a lot of clearing to zero - when we're adding a single bit most of the time this will be completely unnecessary.

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

llvm-svn: 342535
2018-09-19 11:08:54 +00:00
Adrian Prantl
076a6683eb Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

  for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done

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

llvm-svn: 331272
2018-05-01 15:54:18 +00:00
Serge Pavlov
5202bf068f Report fatal error in the case of out of memory
This is the second part of recommit of r325224. The previous part was
committed in r325426, which deals with C++ memory allocation. Solution
for C memory allocation involved functions `llvm::malloc` and similar.
This was a fragile solution because it caused ambiguity errors in some
cases. In this commit the new functions have names like `llvm::safe_malloc`.

The relevant part of original comment is below, updated for new function
names.

Analysis of fails in the case of out of memory errors can be tricky on
Windows. Such error emerges at the point where memory allocation function
fails, but manifests itself when null pointer is used. These two points
may be distant from each other. Besides, next runs may not exhibit
allocation error.

In some cases memory is allocated by a call to some of C allocation
functions, malloc, calloc and realloc. They are used for interoperability
with C code, when allocated object has variable size and when it is
necessary to avoid call of constructors. In many calls the result is not
checked for null pointer. To simplify checks, new functions are defined
in the namespace 'llvm': `safe_malloc`, `safe_calloc` and `safe_realloc`.
They behave as corresponding standard functions but produce fatal error if
allocation fails. This change replaces the standard functions like 'malloc'
in the cases when the result of the allocation function is not checked
for null pointer.

Finally, there are plain C code, that uses malloc and similar functions. If
the result is not checked, assert statement is added.

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

llvm-svn: 325551
2018-02-20 05:41:26 +00:00
Serge Pavlov
87e0b778f8 Revert r325224 "Report fatal error in the case of out of memory"
It caused fails on some buildbots.

llvm-svn: 325227
2018-02-15 09:45:59 +00:00
Serge Pavlov
5359575468 Report fatal error in the case of out of memory
Analysis of fails in the case of out of memory errors can be tricky on
Windows. Such error emerges at the point where memory allocation function
fails, but manifests itself when null pointer is used. These two points
may be distant from each other. Besides, next runs may not exhibit
allocation error.

Usual programming practice does not require checking result of 'operator
new' because it throws 'std::bad_alloc' in the case of allocation error.
However, LLVM is usually built with exceptions turned off, so 'new' can
return null pointer. This change installs custom new handler, which causes
fatal error in the case of out of memory. The handler is installed
automatically prior to call to 'main' during construction of a static
object defined in 'lib/Support/ErrorHandling.cpp'. If the application does
not use this file, the handler may be installed manually by a call to
'llvm::install_out_of_memory_new_handler', declared in
'include/llvm/Support/ErrorHandling.h".

There are calls to C allocation functions, malloc, calloc and realloc.
They are used for interoperability with C code, when allocated object has
variable size and when it is necessary to avoid call of constructors. In
many calls the result is not checked against null pointer. To simplify
checks, new functions are defined in the namespace 'llvm' with the
same names as these C function. These functions produce fatal error if
allocation fails. User should use 'llvm::malloc' instead of 'std::malloc'
in order to use the safe variant. This change replaces 'std::malloc'
in the cases when the result of allocation function is not checked against
null pointer.

Finally, there are plain C code, that uses malloc and similar functions. If
the result is not checked, assert statements are added.

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

llvm-svn: 325224
2018-02-15 09:20:26 +00:00
David Blaikie
79b38636a9 BitVector.h:capacity_in_bytes Don't mark header functions as file-scope static
This creates ODR violations if the function is called from another
inline function in a header and also creates binary bloat from duplicate
definitions.

llvm-svn: 316470
2017-10-24 17:29:08 +00:00
Eugene Zelenko
88a928e194 [ADT] Revert r305326 changes in BitVector.h to fix broken builds.
llvm-svn: 305332
2017-06-13 22:32:38 +00:00
Eugene Zelenko
0c3f2cbd1c [ADT] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 305326
2017-06-13 22:11:49 +00:00
Zachary Turner
44e5728b1e [BitVector] Add find_[first,last]_[set,unset]_in.
A lot of code is duplicated between the first_last and the
next / prev methods.  All of this code can be shared if they
are implemented in terms of find_first_in(Begin, End) etc,
in which case find_first = find_first_in(0, Size) and find_next
is find_first_in(Prev+1, Size), with similar reductions for
the other methods.

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

llvm-svn: 303269
2017-05-17 15:49:45 +00:00
Francis Visoiu Mistrih
d02a2cc569 BitVector: add iterators for set bits
Differential revision: https://reviews.llvm.org/D32060

llvm-svn: 303227
2017-05-17 01:07:53 +00:00
Zachary Turner
5808c2f470 [BitVector] Make find_prev member function const.
NFC.

llvm-svn: 302458
2017-05-08 19:45:55 +00:00
Craig Topper
04b33967e9 [BitVector] Improve the description of the BitVector::clear to say it removes the bits rather than clearing since clearing could be interpreted as just zeroing. NFC
llvm-svn: 302315
2017-05-05 22:46:40 +00:00
Zachary Turner
c5bb012416 [ADT] Add BitVector::find_prev.
This almost completes the matrix of all possible find
functions.

*EXISTING*
----------
find_first
find_first_unset
find_next
find_next_unset
find_last
find_last_unset

*NEW*
----
find_prev

*STILL MISSING*
---------------
find_prev_unset

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

llvm-svn: 302254
2017-05-05 17:00:04 +00:00
Zachary Turner
0be559d8cc [ADT] A few minor improvements to BitVector
Fixes some spelling mistakes, uses a helper function, and
adds an additional test case.

llvm-svn: 302208
2017-05-05 00:19:57 +00:00
Zachary Turner
264e00c2c8 Fixed a type conversion error in BitVector.
llvm-svn: 301033
2017-04-21 20:18:43 +00:00
Zachary Turner
dcec9af484 [BitVector] Make BitVector store an ArrayRef.
This makes certain operations on the underlying storage
easier since we have access to ArrayRef methods such as
drop_front, drop_back, slice, range-based for loops, etc.

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

llvm-svn: 301031
2017-04-21 20:12:08 +00:00
Zachary Turner
00c4e359e7 [BitVector] Add find_last() and find_last_unset().
Differential Revision: https://reviews.llvm.org/D32302

llvm-svn: 301014
2017-04-21 18:07:46 +00:00
Zachary Turner
e778f3aec8 Resubmit "[BitVector] Add operator<<= and operator>>=."
This was failing due to the use of assigning a Mask to an
unsigned, rather than to a BitWord.  But most systems do not
have sizeof(unsigned) == sizeof(unsigned long), so the mask
was getting truncated.

llvm-svn: 300857
2017-04-20 16:56:54 +00:00
Zachary Turner
6a140a3327 Revert "[BitVector] Add operator<<= and operator>>=."
This is causing test failures on Linux / BSD systems.  Reverting
while I investigate.

llvm-svn: 300852
2017-04-20 16:35:22 +00:00
Zachary Turner
821edde041 [BitVector] Add operator<<= and operator>>=.
Differential Revision: https://reviews.llvm.org/D32244

llvm-svn: 300848
2017-04-20 15:57:58 +00:00
Zachary Turner
c56ab3f3f4 [Support] Add support for finding unset bits in a BitVector.
BitVector had methods for searching for the first and next
set bits, but it did not have analagous methods for finding
the first and next unset bits.  This is useful when your ones
and zeros are grouped together and you want to iterate over
ranges of ones and zeros.

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

llvm-svn: 299857
2017-04-10 17:18:54 +00:00
Zachary Turner
6cd4a2b6df Fix line endings.
llvm-svn: 299856
2017-04-10 17:17:11 +00:00
Zachary Turner
5d32414fb2 Remove eol-style:native from BitVector.h
llvm-svn: 299855
2017-04-10 17:15:11 +00:00
Matthias Braun
d766a0e380 BitVector: Fix undefined behaviour
Calling reset() on an empty BitVector would call memset with a nullptr
argument which is undefined behaviour.

This should fix the sanitizer bot.

llvm-svn: 292575
2017-01-20 04:23:08 +00:00
Eugene Zelenko
0820a70f28 [ADT, IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 288989
2016-12-07 22:06:02 +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
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
Rui Ueyama
dca64dbccc Update to use new name alignTo().
llvm-svn: 257804
2016-01-14 21:06:47 +00:00
Vedant Kumar
f7653bdd88 [ADT] Make capacity_in_bytes support BitVector. NFC.
This makes it a bit easier to replace instances of vector<bool> with
BitVector.

llvm-svn: 253180
2015-11-16 04:02:36 +00:00
Alexander Kornienko
f993659b8f Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)
Apparently, the style needs to be agreed upon first.

llvm-svn: 240390
2015-06-23 09:49:53 +00:00
Alexander Kornienko
40cb19d802 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
  -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
  llvm/lib/


Thanks to Eugene Kosov for the original patch!

llvm-svn: 240137
2015-06-19 15:57:42 +00:00
David Blaikie
d215bbe13e [Small]BitVector::reference: Explicitly default copy construction as it is deprecated in C++11 in the presence of explicit copy assignment.
I tried making these private & friended to the BitVector, but that
didn't work - there's one use of BitVector::reference in Clang that
actually copies it into a local variable & uses it from there, rather
than just using the result of op[] in a temporary expression.

Whether or not this is desired is debatable (we could just fix that one
use in Clang) & it's not clear which way the C++ standard falls on this
for std::bitset's reference type (it has the same bug at least in
libstdc++, but Clang's -Wdeprecated doesn't flag it, because it's in a
standard header)

While it was only BitVector::reference's copy ctor that was referenced
by user code, I made SmallBitVector::reference's copy ctor public too,
for consistency.

llvm-svn: 231099
2015-03-03 18:39:00 +00:00
Benjamin Kramer
4b76aa3d46 MathExtras: Bring Count(Trailing|Leading)Ones and CountPopulation in line with countTrailingZeros
Update all callers.

llvm-svn: 228930
2015-02-12 15:35:40 +00:00
Benjamin Kramer
c7a7636094 BitVector: Remove manual bit width dispatch, this is handled by templates
NFC.

llvm-svn: 228922
2015-02-12 14:02:58 +00:00
Michael Ilseman
dd56e9aa72 Silence more static analyzer warnings.
Add in definedness checks for shift operators, null checks when
pointers are assumed by the code to be non-null, and explicit
unreachables.

llvm-svn: 224255
2014-12-15 18:48:43 +00:00
Michael Ilseman
6d636ee500 Clean up static analyzer warnings.
Clang's static analyzer found several potential cases of undefined
behavior, use of un-initialized values, and potentially null pointer
dereferences in tablegen, Support, MC, and ADT. This cleans them up
with specific assertions on the assumptions of the code.

llvm-svn: 224154
2014-12-12 21:48:03 +00:00
Yaron Keren
d3a024a162 Attempting to fix the 64 bit bots.
llvm-svn: 211351
2014-06-20 10:52:57 +00:00
Yaron Keren
e1172cbc66 The count() function for STL datatypes returns unsigned, even where it's
only 1/0 result like std::set. Some of the LLVM ADT already return unsigned
count(), while others still return bool count().

In continuation to r197879, this patch modifies DenseMap, DenseSet, 
ScopedHashTable, ValueMap:: count() to return size_type instead of bool,
1 instead of true and 0 instead of false.

size_type is typedef-ed locally within each class to size_t.

http://reviews.llvm.org/D4018

Reviewed by dblaikie.

llvm-svn: 211350
2014-06-20 10:26:56 +00:00
Craig Topper
30281a67fb [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr.
llvm-svn: 206142
2014-04-14 00:51:57 +00:00
Joerg Sonnenberger
f6b412530d Shifting into the sign bit is UB as discussed on IRC. Explicitly use the
BitWord type for the constants to avoid this.

llvm-svn: 205257
2014-03-31 22:53:57 +00:00
Chandler Carruth
df9f7f4aec [C++11] Remove the R-value reference #if usage from the ADT and Support
libraries. It is now always 1 in LLVM builds.

llvm-svn: 202580
2014-03-01 09:27:28 +00:00
Anna Zaks
3a3a64f7fe Fix a buffer overrun detected by AddressSanitizer.
llvm-svn: 197647
2013-12-19 02:35:26 +00:00
Benjamin Kramer
2fbc7287e4 BitVector: Do the right thing in all() when Size is a multiple of BITWORD_SIZE.
llvm-svn: 183525
2013-06-07 15:14:31 +00:00
Benjamin Kramer
5f752c703f Optimize BitVector::all().
llvm-svn: 183521
2013-06-07 14:14:38 +00:00
Michael J. Spencer
c195b8a813 Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.
llvm-svn: 182680
2013-05-24 22:23:49 +00:00
Chandler Carruth
5286042938 Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES.
Rationale:
1) This was the name in the comment block. ;]
2) It matches Clang's __has_feature naming convention.
3) It matches other compiler-feature-test conventions.

Sorry for the noise. =]

I've also switch the comment block to use a \brief tag and not duplicate
the name.

llvm-svn: 168996
2012-11-30 11:45:22 +00:00
Owen Anderson
cb8d1f6815 Fix a bug in the set(I,E)/reset(I,E) methods that I recently added. The boundary condition for checking if I and E were in the same word were incorrect, and, beyond that, the mask computation was not using a wide enough constant.
llvm-svn: 166015
2012-10-16 06:04:27 +00:00
Owen Anderson
e678a60cc8 Add range-based set()/reset() to BitVector. These allow fast setting/resetting of ranges of bits, particularly useful when dealing with very large BitVector's.
llvm-svn: 165984
2012-10-15 22:05:27 +00:00
Nadav Rotem
f25e382cd2 Add a new optimization pass: Stack Coloring, that merges disjoint static allocations (allocas). Allocas are known to be
disjoint if they are marked by disjoint lifetime markers (@llvm.lifetime.XXX intrinsics).

llvm-svn: 163299
2012-09-06 09:17:37 +00:00