llvm-6502/include/llvm/Support
Hans Wennborg eeb828f029 Use returns_nonnull in BumpPtrAllocator and MallocAllocator to avoid null-check in placement new
In both Clang and LLVM, this is a common pattern:

  Size = sizeof(DeclRefExpr) + SomeExtraStuff;
  void *Mem = Context.Allocate(Size, llvm::alignOf<DeclRefExpr>());
  return new (Mem) DeclRefExpr(...);

The annoying thing is that because the default placement-new operator has a
nothrow specification, the compiler will insert a null check of Mem before
calling the DeclRefExpr constructor. This null check is redundant for us,
because we expect the allocation functions to never return null.

By annotating the allocator functions with returns_nonnull, we can optimize
away these checks. Compiling clang with a recent version of Clang and measuring
with:

  $ perf stat -r20 bin/clang.patch -fsyntax-only -w gcc.c && perf stat -r20 bin/clang.orig -fsyntax-only -w gcc.c

Shows a 2.4% speed-up (+- 0.8%).

The pattern occurs in LLVM too. Measuring with -O3 (and now using bzip2.c
instead, because it's smaller):

  $ perf stat -r20 bin/clang.patch -O3 -w bzip2.c  &&  perf stat -r20 bin/clang.orig -O3 -w bzip2.c

Shows 4.4 % speed-up (+- 1%).

If anyone knows of a similar attribute we can use for MSVC, or some other
technique to get rid off the null check there, please let me know.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216192 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-21 17:10:00 +00:00
..
AIXDataTypesFix.h
AlignOf.h Extend llvm::AlignedCharArrayUnion to support up to 10 arguments, as required by Clang's APValue. 2014-01-09 03:28:55 +00:00
Allocator.h Use returns_nonnull in BumpPtrAllocator and MallocAllocator to avoid null-check in placement new 2014-08-21 17:10:00 +00:00
ARMBuildAttributes.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
ARMEHABI.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
ARMWinEH.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
ArrayRecycler.h [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-14 00:51:57 +00:00
Atomic.h
BlockFrequency.h blockfreq: Defer to BranchProbability::scale() (again) 2014-04-29 16:31:29 +00:00
BranchProbability.h BranchProb: Simplify printing code 2014-04-29 17:07:42 +00:00
Capacity.h
Casting.h [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
CBindingWrapping.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
circular_raw_ostream.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
CodeGen.h
COFF.h Support: update DLLCharacteristics enumeration 2014-06-27 03:11:18 +00:00
CommandLine.h Revert "[Support] Promote cl::StringSaver to a separate utility" 2014-08-15 23:39:01 +00:00
Compiler.h Use returns_nonnull in BumpPtrAllocator and MallocAllocator to avoid null-check in placement new 2014-08-21 17:10:00 +00:00
Compression.h Simplify compression API by compressing into a SmallVector rather than a MemoryBuffer 2014-04-05 21:53:04 +00:00
ConvertUTF.h Support/ConvertUTF: implement U+FFFD insertion according to the recommendation 2014-06-16 11:09:46 +00:00
CrashRecoveryContext.h For CrashRecoveryContext::RunSafelyOnThread, propagate Darwin's PRIO_DARWIN_BG to the new thread if it is 2014-06-25 23:54:50 +00:00
DataExtractor.h
DataStream.h
DataTypes.h.cmake DataTypes.h.cmake: Define PRIx32 &c for !HAVE_INTTYPES_H hosts. 2014-08-08 17:00:47 +00:00
DataTypes.h.in Fix standard integer definitions for MSVC in DataTypes.h 2014-05-28 18:19:55 +00:00
Debug.h [Modules] Make Support/Debug.h modular. This requires it to not change 2014-04-21 22:55:11 +00:00
DOTGraphTraits.h
Dwarf.h Emit DWARF3 call frame information when DWARF3+ debug info is requested 2014-06-19 15:39:33 +00:00
DynamicLibrary.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
ELF.h AArch64: add support for dynamic-loader relocations 2014-08-11 10:10:27 +00:00
Endian.h Using llvm::sys::swapByteOrder() for the common case of byte-swapping a value in place 2014-06-14 13:18:07 +00:00
EndianStream.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
Errc.h Finishing touch for the std::error_code transition. 2014-06-13 17:20:48 +00:00
Errno.h
ErrorHandling.h Make the error-handling functions thread-safe. 2014-06-13 21:20:44 +00:00
ErrorOr.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
FileOutputBuffer.h Don't use 'using std::error_code' in include/llvm. 2014-06-12 21:46:39 +00:00
FileSystem.h Remove dead code. Fixes pr20544. 2014-08-08 21:35:52 +00:00
FileUtilities.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
Format.h Make format_object_base's destructor protected and non-virtual. 2014-08-21 11:22:05 +00:00
FormattedStream.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
GCOV.h test commit: remove trailing space 2014-07-23 17:18:05 +00:00
GenericDomTree.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
GenericDomTreeConstruction.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
GraphWriter.h Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00
Host.h Return a StringRef from getHostCPUName. 2013-12-12 15:45:32 +00:00
LEB128.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
LICENSE.TXT
LineIterator.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
Locale.h
LockFileManager.h Don't use 'using std::error_code' in include/llvm. 2014-06-12 21:46:39 +00:00
MachO.h extracting swapStruct into include/llvm/Support/MachO.h (no functional change) 2014-07-18 09:26:16 +00:00
ManagedStatic.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
MathExtras.h Undefine R2, R4, R6 after use. 2014-07-02 14:40:35 +00:00
MD5.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
Memory.h Don't use 'using std::error_code' in include/llvm. 2014-06-12 21:46:39 +00:00
MemoryBuffer.h Don't own the buffer in object::Binary. 2014-08-19 18:44:46 +00:00
MemoryObject.h
Mutex.h Include Threading.h instead of forward declaring a function. 2014-06-19 20:20:03 +00:00
MutexGuard.h
OnDiskHashTable.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
OutputBuffer.h
Path.h Path: Stop claiming path::const_iterator is bidirectional 2014-08-04 17:36:41 +00:00
PluginLoader.h
PointerLikeTypeTraits.h
PrettyStackTrace.h [C++11] Remove 'virtual' keyword from methods marked with 'override' keyword. 2014-03-10 03:53:12 +00:00
Process.h Refactor the code in clang to find a file in a PATH like environment variable into a helper function 2014-06-30 19:54:20 +00:00
Program.h Don't use 'using std::error_code' in include/llvm. 2014-06-12 21:46:39 +00:00
RandomNumberGenerator.h Fix the build. 2014-06-25 15:47:36 +00:00
raw_os_ostream.h [C++11] Remove 'virtual' keyword from methods marked with 'override' keyword. 2014-03-10 03:53:12 +00:00
raw_ostream.h Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00
Recycler.h [Allocator] Stop forward-declaring BumpPtrAllocator in a few places. 2014-03-30 11:36:29 +00:00
RecyclingAllocator.h Add an assertion to the fixed-size allocator to ensure that we don't request 2013-08-27 11:20:13 +00:00
Regex.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
Registry.h Use unique_ptr for the result of Registry entries. 2014-04-15 05:53:26 +00:00
RegistryParser.h
RWMutex.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
SaveAndRestore.h SaveAndRestore: fix coding style and Doxygenify comments 2014-04-10 09:44:32 +00:00
ScaledNumber.h Include <tuple> for std::tie 2014-06-24 05:59:52 +00:00
Signals.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
SMLoc.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
Solaris.h
SourceMgr.h SourceMgr: consistently use 'unsigned' for the memory buffer ID type 2014-07-09 08:30:15 +00:00
SpecialCaseList.h SpecialCaseList.h: Fix -Wdocumentation with \code. 2014-07-10 11:39:59 +00:00
StreamableMemoryObject.h Convert some assert(0) to llvm_unreachable or fold an 'if' condition into the assert. 2014-06-19 06:10:58 +00:00
StringPool.h Fix breakage from r211244 by using LLVM_EXPLICIT to avoid using explicit operators under MSVC where they're not supported. 2014-06-19 01:09:49 +00:00
StringRefMemoryObject.h Switch all uses of LLVM_OVERRIDE to just use 'override' directly. 2014-03-02 09:09:27 +00:00
SwapByteOrder.h Adding llvm::sys::swapByteOrder() for the common use-case of byte-swapping a value in place 2014-06-14 12:52:55 +00:00
SystemUtils.h
TargetRegistry.h Remove obsolete function TargetRegistry::getClosestTargetForJIT() 2014-07-01 10:47:13 +00:00
TargetSelect.h
Threading.h Re-apply r211287: Remove support for LLVM runtime multi-threading. 2014-06-27 15:13:01 +00:00
ThreadLocal.h
Timer.h [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-14 00:51:57 +00:00
TimeValue.h Remove TimeValue::toPosixTime() -- it is buggy, semantics are unclear, and its 2014-02-11 09:11:18 +00:00
ToolOutputFile.h Don't make F_None the default. 2014-02-24 15:07:20 +00:00
type_traits.h [C++11] Now that the users are gone, rip out the duplicated traits from type_traits.h 2014-03-07 15:54:23 +00:00
Unicode.h include/llvm/Support/Unicode.h didn't have re-include guards 2014-05-13 10:11:29 +00:00
UnicodeCharRanges.h [Modules] Make Support/Debug.h modular. This requires it to not change 2014-04-21 22:55:11 +00:00
Valgrind.h Don't mark the declarations of the TSan annotation functions as weak. 2014-03-30 11:20:25 +00:00
Watchdog.h
Win64EH.h Partially roll back r202915. 2014-03-05 00:43:02 +00:00
WindowsError.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
YAMLParser.h Convert an ownership comment with std::uinque_ptr. 2014-08-17 22:20:33 +00:00
YAMLTraits.h Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00