llvm-6502/include/llvm
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
..
ADT Remove custom implementations of max/min in StringRef that was originally added to work an old gcc bug. I believe its been fixed by now. 2014-08-21 04:31:10 +00:00
Analysis Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size. 2014-08-21 05:55:13 +00:00
AsmParser Split parseAssembly into parseAssembly and parseAssemblyInto. 2014-08-19 22:05:47 +00:00
Bitcode Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
CodeGen Add a thread-model knob for lowering atomics on baremetal & single threaded systems 2014-08-21 14:35:47 +00:00
Config Regenerate autoconf, previous updates to the configury haven't 2014-07-28 22:00:44 +00:00
DebugInfo Use a reference instead of a pointer. 2014-07-31 20:19:36 +00:00
ExecutionEngine Don't own the buffer in object::Binary. 2014-08-19 18:44:46 +00:00
IR [x86] Added _addcarry_ and _subborrow_ intrinsics 2014-08-21 09:43:43 +00:00
IRReader Make a helper function static. No functionality change. 2014-07-05 00:39:08 +00:00
LineEditor [C++11] Replace OwningPtr with std::unique_ptr in places where it doesn't break the API. 2014-04-21 09:34:48 +00:00
Linker IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
LTO Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size. 2014-08-21 05:55:13 +00:00
MC Add isInsertSubreg property. 2014-08-20 23:49:36 +00:00
Object fix the gcc build 2014-08-19 20:06:25 +00:00
Option Option: Propagate flags from groups to options in each group 2014-07-12 00:18:58 +00:00
ProfileData Don't own the buffer in object::Binary. 2014-08-19 18:44:46 +00:00
Support Use returns_nonnull in BumpPtrAllocator and MallocAllocator to avoid null-check in placement new 2014-08-21 17:10:00 +00:00
TableGen Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
Target Add a thread-model knob for lowering atomics on baremetal & single threaded systems 2014-08-21 14:35:47 +00:00
Transforms Handle inlining in populateLTOPassManager like in populateModulePassManager. 2014-08-21 13:35:30 +00:00
CMakeLists.txt Remove llvm_headers_do_not_build for the benefit of XCode and Visual Studio users. 2014-08-14 00:51:47 +00:00
InitializePasses.h MachineCombiner Pass for selecting faster instruction 2014-08-03 21:35:39 +00:00
LinkAllIR.h [cleanup] Move the Dominators.h and Verifier.h headers into the IR 2014-01-13 09:26:24 +00:00
LinkAllPasses.h Move -verify-use-list-order into llvm-uselistorder 2014-07-25 17:13:03 +00:00
module.modulemap [modules] Update module map workaround to cope with the problematic file having 2014-08-07 20:27:08 +00:00
module.modulemap.build [modules] Add module maps for LLVM. These are not quite ready for prime-time 2014-05-21 02:46:14 +00:00
Pass.h Revert "[PM] Add pass run listeners to the pass manager." 2014-05-15 17:49:20 +00:00
PassAnalysisSupport.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
PassInfo.h Remove pimpl class from PassRegistry. 2014-06-12 16:06:51 +00:00
PassManager.h Move the old pass manager infrastructure into a legacy namespace and 2013-11-09 12:26:54 +00:00
PassRegistry.h Remove pimpl class from PassRegistry. 2014-06-12 16:06:51 +00:00
PassSupport.h Move GlobalMerge from Transform to CodeGen. 2014-06-13 22:57:59 +00:00