1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/unittests
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
..
ADT [APInt] Fix extractBits to correctly handle Result.isSingleWord() case. 2018-02-16 01:44:36 +00:00
Analysis [SCEV] Do not cache S -> V if S is not equivalent of V 2018-01-09 06:47:14 +00:00
AsmParser
BinaryFormat
Bitcode Pass a reference to a module to the bitcode writer. 2018-02-14 19:11:32 +00:00
CodeGen [GISel]: Add pattern matchers for G_BITCAST/PTRTOINT/INTTOPTR 2018-02-19 23:11:53 +00:00
DebugInfo Silence an unsigned vs signed compare warning. 2018-02-16 22:46:45 +00:00
ExecutionEngine [ORC] Consolidate RTDyldObjectLinkingLayer GetMemMgr and GetResolver into a 2018-02-14 22:13:02 +00:00
FuzzMutate [FuzzMutate] Inst deleter doesn't work with PhiNodes 2018-01-25 09:22:18 +00:00
IR Use EXPECT_FALSE instead of EXPECT_EQ(false, ... 2018-02-14 13:11:56 +00:00
LineEditor
Linker
MC
MI Followup on Proposal to move MIR physical register namespace to '$' sigil. 2018-01-31 22:04:26 +00:00
Object
ObjectYAML
Option [Option] For typo '-foo', suggest '--foo' 2018-01-09 19:38:04 +00:00
ProfileData Remove redundant includes from unittests. 2017-12-13 21:31:05 +00:00
Support Report fatal error in the case of out of memory 2018-02-20 05:41:26 +00:00
Target
tools [CMake] Use PRIVATE in target_link_libraries for executables 2017-12-05 21:49:56 +00:00
Transforms Pass a module reference to CloneModule. 2018-02-14 19:50:40 +00:00
XRay
CMakeLists.txt