1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/lib
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
..
Analysis [PatternMatch, InstSimplify] enhance m_AllOnes() to ignore undef elements in vectors 2018-02-18 18:05:08 +00:00
AsmParser [DebugInfo] Unify ChecksumKind and Checksum value in DIFile 2018-02-12 19:45:54 +00:00
BinaryFormat Add DWARF for discriminated unions 2018-02-06 23:45:59 +00:00
Bitcode bitcode support change for fast flags compatibility 2018-02-19 19:22:28 +00:00
CodeGen Report fatal error in the case of out of memory 2018-02-20 05:41:26 +00:00
DebugInfo [dwarfdump] Fix spurious verification errors for DW_AT_location attributes 2018-02-17 13:06:37 +00:00
Demangle
ExecutionEngine Report fatal error in the case of out of memory 2018-02-20 05:41:26 +00:00
Fuzzer
FuzzMutate [llvm-opt-fuzzer] Add another pack of passes for continuous fuzzing 2018-02-19 11:57:07 +00:00
IR [ThinLTO] Add GraphTraits for FunctionSummaries 2018-02-19 15:14:50 +00:00
IRReader LLParser: add an argument for overriding data layout and do not check alloca addr space 2018-01-30 22:32:39 +00:00
LineEditor
Linker [ThinLTO] Import global variables 2018-02-16 08:11:04 +00:00
LTO [ThinLTO] Add GraphTraits for FunctionSummaries 2018-02-19 15:14:50 +00:00
MC [WebAssembly] MC: Make explicit our current lack of support for relocations against unnamed temporary symbols. 2018-02-16 18:06:05 +00:00
Object Report fatal error in the case of out of memory 2018-02-20 05:41:26 +00:00
ObjectYAML AMDGPU: Bring elf flags in sync with the spec 2018-02-16 22:33:59 +00:00
Option
Passes
ProfileData
Support Report fatal error in the case of out of memory 2018-02-20 05:41:26 +00:00
TableGen [tablegen] Fixed few !foreach evaluation issues. 2018-02-09 18:37:55 +00:00
Target [AArch64][GlobalISel] When copying from a gpr32 to an fpr16 reg, convert to fpr32 first. 2018-02-20 05:11:57 +00:00
Testing
ToolDrivers
Transforms [InstCombine] use CreateWithCopiedFlags to reduce code; NFCI 2018-02-19 23:09:03 +00:00
WindowsManifest
XRay [XRay] clarify error messages when parsing broken traces 2018-01-30 13:41:34 +00:00
CMakeLists.txt
LLVMBuild.txt