[PATCH] Use returns_nonnull in BumpPtrAllocator and MallocAllocator to avoid null-check in placement new

Chandler Carruth chandlerc at gmail.com
Thu Aug 21 10:00:04 PDT 2014


Regardless of whether we can add more portable tricks, this seems like a strict improvement in the allocation API. Awesome speedups too!

================
Comment at: include/llvm/Support/Allocator.h:93
@@ -92,2 +92,3 @@
 
-  void *Allocate(size_t Size, size_t /*Alignment*/) { return malloc(Size); }
+  void LLVM_ATTRIBUTE_RETURNS_NONNULL *Allocate(size_t Size,
+                                                size_t /*Alignment*/) {
----------------
Why is this attribute in a different location?

http://reviews.llvm.org/D4989






More information about the llvm-commits mailing list