History log of /llvm-project/llvm/lib/Support/StringMap.cpp (Results 26 – 50 of 57)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# b9ad1759 26-Feb-2018 Jonas Devlieghere <jonas@devlieghere.com>

[Support] Replace HashString with djbHash.

This removes the HashString function from StringExtraces and replaces
its uses with calls to djbHash from DJB.h

This is *almost* NFC. While the algorithm

[Support] Replace HashString with djbHash.

This removes the HashString function from StringExtraces and replaces
its uses with calls to djbHash from DJB.h

This is *almost* NFC. While the algorithm is identical, the djbHash
implementation in StringExtras used 0 as its seed while the
implementation in DJB uses 5381. The latter has been shown to result in
less collisions and improved avalanching.

https://reviews.llvm.org/D43615
(cherry picked from commit 77f7f965bc9499a9ae768a296ca5a1f7347d1d2c)

llvm-svn: 326081

show more ...


Revision tags: llvmorg-6.0.0-rc3
# 76d8ccee 20-Feb-2018 Serge Pavlov <sepavloff@gmail.com>

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 mem

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

show more ...


# 45000019 15-Feb-2018 Serge Pavlov <sepavloff@gmail.com>

Revert r325224 "Report fatal error in the case of out of memory"

It caused fails on some buildbots.

llvm-svn: 325227


# 431502a6 15-Feb-2018 Serge Pavlov <sepavloff@gmail.com>

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

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

show more ...


Revision tags: llvmorg-6.0.0-rc2, llvmorg-6.0.0-rc1, llvmorg-5.0.1, llvmorg-5.0.1-rc3, llvmorg-5.0.1-rc2, llvmorg-5.0.1-rc1, llvmorg-5.0.0, llvmorg-5.0.0-rc5, llvmorg-5.0.0-rc4, llvmorg-5.0.0-rc3, llvmorg-5.0.0-rc2, llvmorg-5.0.0-rc1
# c20b3383 20-Jul-2017 Matthias Braun <matze@braunis.de>

Support, IR, ADT: Check nullptr after allocation with malloc/realloc or calloc

As a follow up of the bad alloc handler patch, this patch introduces nullptr checks on pointers returned from the
mallo

Support, IR, ADT: Check nullptr after allocation with malloc/realloc or calloc

As a follow up of the bad alloc handler patch, this patch introduces nullptr checks on pointers returned from the
malloc/realloc/calloc functions. In addition some memory size assignments are moved behind the allocation
of the corresponding memory to fulfill exception safe memory management (RAII).

patch by Klaus Kretzschmar

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

llvm-svn: 308576

show more ...


Revision tags: llvmorg-4.0.1, llvmorg-4.0.1-rc3, llvmorg-4.0.1-rc2, llvmorg-4.0.1-rc1, llvmorg-4.0.0, llvmorg-4.0.0-rc4, llvmorg-4.0.0-rc3, llvmorg-4.0.0-rc2, llvmorg-4.0.0-rc1, llvmorg-3.9.1, llvmorg-3.9.1-rc3, llvmorg-3.9.1-rc2, llvmorg-3.9.1-rc1, llvmorg-3.9.0, llvmorg-3.9.0-rc3
# 33d7b762 23-Aug-2016 Eugene Zelenko <eugene.zelenko@gmail.com>

Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes.

Differential revision: https://reviews.llvm.org/D23789

llvm-svn: 279535


Revision tags: llvmorg-3.9.0-rc2, llvmorg-3.9.0-rc1, llvmorg-3.8.1, llvmorg-3.8.1-rc1
# be8a57f9 25-Mar-2016 Mehdi Amini <mehdi.amini@apple.com>

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 d

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

show more ...


Revision tags: llvmorg-3.8.0, llvmorg-3.8.0-rc3, llvmorg-3.8.0-rc2, llvmorg-3.8.0-rc1, llvmorg-3.7.1, llvmorg-3.7.1-rc2, llvmorg-3.7.1-rc1, llvmorg-3.7.0, llvmorg-3.7.0-rc4, llvmorg-3.7.0-rc3, studio-1.4, llvmorg-3.7.0-rc2, llvmorg-3.7.0-rc1, llvmorg-3.6.2, llvmorg-3.6.2-rc1, llvmorg-3.6.1, llvmorg-3.6.1-rc1, llvmorg-3.5.2, llvmorg-3.5.2-rc1, llvmorg-3.6.0
# 654a85e2 23-Feb-2015 Benjamin Kramer <benny.kra@googlemail.com>

Sync the __builtin_expects for our 3 quadratically probed hash table implementations.

This assumes that
a) finding the bucket containing the value is LIKELY
b) finding an empty bucket is LIKELY

Sync the __builtin_expects for our 3 quadratically probed hash table implementations.

This assumes that
a) finding the bucket containing the value is LIKELY
b) finding an empty bucket is LIKELY
c) growing the table is UNLIKELY

I also switched the a) and b) cases for SmallPtrSet as we seem to use
the set mostly more for insertion than for checking existence.

In a simple benchmark consisting of 2^21 insertions of 2^20 unique
pointers into a DenseMap or SmallPtrSet a few percent speedup on average,
but nothing statistically significant.

llvm-svn: 230232

show more ...


Revision tags: llvmorg-3.6.0-rc4, llvmorg-3.6.0-rc3, llvmorg-3.6.0-rc2, llvmorg-3.6.0-rc1, llvmorg-3.5.1, llvmorg-3.5.1-rc2, llvmorg-3.5.1-rc1, llvmorg-3.5.0, llvmorg-3.5.0-rc4, llvmorg-3.5.0-rc3, llvmorg-3.5.0-rc2, llvmorg-3.5.0-rc1
# 16a9eab3 23-Jun-2014 David Blaikie <dblaikie@gmail.com>

Recommit 211309 (StringMap::insert), reverted in 211328 due to issues with private, but non-deleted, move members.

Certain versions of GCC (~4.7) couldn't handle the SFINAE on access
control, but wi

Recommit 211309 (StringMap::insert), reverted in 211328 due to issues with private, but non-deleted, move members.

Certain versions of GCC (~4.7) couldn't handle the SFINAE on access
control, but with "= delete" (hidden behind a macro for portability)
this issue is worked around/addressed.

Patch by Agustín Bergé

llvm-svn: 211525

show more ...


# 393b2b59 20-Jun-2014 Rafael Espindola <rafael.espindola@gmail.com>

Revert "Add StringMap::insert(pair) consistent with the standard associative container concept."

This reverts commit r211309.

It looks like it broke some bots:

http://lab.llvm.org:8011/builders/cl

Revert "Add StringMap::insert(pair) consistent with the standard associative container concept."

This reverts commit r211309.

It looks like it broke some bots:

http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/15563/steps/compile/logs/stdio

llvm-svn: 211328

show more ...


# 37700dc0 19-Jun-2014 David Blaikie <dblaikie@gmail.com>

Add StringMap::insert(pair) consistent with the standard associative container concept.

Patch by Agustín Bergé.

llvm-svn: 211309


Revision tags: llvmorg-3.4.2, llvmorg-3.4.2-rc1, llvmorg-3.4.1, llvmorg-3.4.1-rc2, llvmorg-3.4.1-rc1
# 8d399f87 09-Apr-2014 Craig Topper <craig.topper@gmail.com>

[C++11] Replace some comparisons with 'nullptr' with simple boolean checks to reduce verbosity.

llvm-svn: 205829


# c10719f5 07-Apr-2014 Craig Topper <craig.topper@gmail.com>

[C++11] Make use of 'nullptr' in the Support library.

llvm-svn: 205697


Revision tags: llvmorg-3.4.0, llvmorg-3.4.0-rc3, llvmorg-3.4.0-rc2, llvmorg-3.4.0-rc1, llvmorg-3.3.1-rc1, llvmorg-3.3.0, llvmorg-3.3.0-rc3, llvmorg-3.3.0-rc2, llvmorg-3.3.0-rc1, llvmorg-3.2.0, llvmorg-3.2.0-rc3, llvmorg-3.2.0-rc2, llvmorg-3.2.0-rc1
# ffa24e04 29-Aug-2012 Benjamin Kramer <benny.kra@googlemail.com>

Add some __builtin_expect magic to StringMap.

Tombstones and full hash collisions are rare, mark the "empty"
and "no collision" paths as likely. The bug in simplifycfg
that prevented the hints from

Add some __builtin_expect magic to StringMap.

Tombstones and full hash collisions are rare, mark the "empty"
and "no collision" paths as likely. The bug in simplifycfg
that prevented the hints from being picked during selfhost
up was fixed recently :)

llvm-svn: 162874

show more ...


# 198422a4 19-Jun-2012 Chandler Carruth <chandlerc@gmail.com>

Fix PR13148, an inf-loop in StringMap.

StringMap suffered from the same bug as DenseMap: when you explicitly
construct it with a small number of buckets, you can arrange for the
tombstone-based grow

Fix PR13148, an inf-loop in StringMap.

StringMap suffered from the same bug as DenseMap: when you explicitly
construct it with a small number of buckets, you can arrange for the
tombstone-based growth path to be followed when the number of buckets
was less than '8'. In that case, even with a full map, it would compare
'0' as not less than '0', and refuse to grow the table, leading to
inf-loops trying to find an empty bucket on the next insertion. The fix
is very simple: use '<=' as the comparison. The same fix was applied to
DenseMap as well during its recent refactoring.

Thanks to Alex Bolz for the great report and test case. =]

llvm-svn: 158725

show more ...


Revision tags: llvmorg-3.1.0, llvmorg-3.1.0-rc3, llvmorg-3.1.0-rc2, llvmorg-3.1.0-rc1
# 46236ee5 27-Dec-2011 Benjamin Kramer <benny.kra@googlemail.com>

Switch StringMap from an array of structures to a structure of arrays.

- -25% memory usage of the main table on x86_64 (was wasted in struct padding).
- no significant performance change.

llvm-svn:

Switch StringMap from an array of structures to a structure of arrays.

- -25% memory usage of the main table on x86_64 (was wasted in struct padding).
- no significant performance change.

llvm-svn: 147294

show more ...


Revision tags: llvmorg-3.0.0, llvmorg-3.0.0-rc4, llvmorg-3.0.0-rc3, llvmorg-3.0.0-rc2, llvmorg-3.0.0-rc1, llvmorg-2.9.0
# 846f9508 30-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk>

Reset StringMap's NumTombstones on clears and rehashes.

StringMap was not properly updating NumTombstones after a clear or rehash.

This was not fatal until now because the table was growing faster

Reset StringMap's NumTombstones on clears and rehashes.

StringMap was not properly updating NumTombstones after a clear or rehash.

This was not fatal until now because the table was growing faster than
NumTombstones could, but with the previous change of preventing infinite
growth of the table the invariant (NumItems + NumTombstones <= NumBuckets)
stopped being observed, causing infinite loops in certain situations.

Patch by José Fonseca!

llvm-svn: 128567

show more ...


# f587f441 30-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk>

Prevent infinite growth of SmallMap instances.

Rehash but don't grow when full of tombstones.

Patch by José Fonseca!

llvm-svn: 128565


Revision tags: llvmorg-2.9.0-rc3, llvmorg-2.9.0-rc2, llvmorg-2.9.0-rc1
# 9b43f336 23-Dec-2010 Jeffrey Yasskin <jyasskin@google.com>

Change all self assignments X=X to (void)X, so that we can turn on a
new gcc warning that complains on self-assignments and
self-initializations.

llvm-svn: 122458


Revision tags: llvmorg-2.8.0, llvmorg-2.8.0-rc3, llvmorg-2.8.0-rc2, llvmorg-2.8.0-rc1, llvmorg-2.8.0-rc0, llvmorg-2.7.0
# ad36e8ac 06-Nov-2009 Daniel Dunbar <daniel@zuster.org>

Pass StringRef by value.

llvm-svn: 86251


Revision tags: llvmorg-2.6.0
# 77668004 17-Oct-2009 Daniel Dunbar <daniel@zuster.org>

Move StringMap's string has function into StringExtras.h

llvm-svn: 84344


# 5bf72e20 23-Jul-2009 Daniel Dunbar <daniel@zuster.org>

Convert StringMap to using StringRef for its APIs.
- Yay for '-'s and simplifications!

- I kept StringMap::GetOrCreateValue for compatibility purposes, this can
eventually go away. Likewise the

Convert StringMap to using StringRef for its APIs.
- Yay for '-'s and simplifications!

- I kept StringMap::GetOrCreateValue for compatibility purposes, this can
eventually go away. Likewise the StringMapEntry Create functions still follow
the old style.

- NIFC.

llvm-svn: 76888

show more ...


Revision tags: llvmorg-2.5.0, llvmorg-2.4.0, llvmorg-2.3.0, llvmorg-2.2.0
# f3ebc3f3 29-Dec-2007 Chris Lattner <sabre@nondot.org>

Remove attribution from file headers, per discussion on llvmdev.

llvm-svn: 45418


Revision tags: llvmorg-2.1.0, llvmorg-2.0.0
# c770a027 04-Apr-2007 Chris Lattner <sabre@nondot.org>

stringmap memory managed with malloc now

llvm-svn: 35666


# adf83a35 04-Apr-2007 Chris Lattner <sabre@nondot.org>

use calloc instead of new/memset, it is more efficient

llvm-svn: 35644


123