[PATCH] D117664: [Support] Remove incorrect noalias return attribute in BumpPtrAllocator

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 19 05:35:32 PST 2022


nikic created this revision.
nikic added reviewers: aganea, reames, jdoerfert.
Herald added subscribers: jeroen.dobbelaere, dexonsmith.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The memory returned by the Allocate() function is also otherwise accessible -- and is indeed accessed by the DestroyAll() method of SpecificBumpPtrAlloactor. This is a violation of the noalias return contract.

This should address the issue reported in https://reviews.llvm.org/D116728#3252464.


https://reviews.llvm.org/D117664

Files:
  llvm/include/llvm/Support/Allocator.h


Index: llvm/include/llvm/Support/Allocator.h
===================================================================
--- llvm/include/llvm/Support/Allocator.h
+++ llvm/include/llvm/Support/Allocator.h
@@ -141,8 +141,7 @@
   }
 
   /// Allocate space at the specified alignment.
-  LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void *
-  Allocate(size_t Size, Align Alignment) {
+  LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size, Align Alignment) {
     // Keep track of how many bytes we've allocated.
     BytesAllocated += Size;
 
@@ -198,7 +197,7 @@
     return AlignedPtr;
   }
 
-  inline LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void *
+  inline LLVM_ATTRIBUTE_RETURNS_NONNULL void *
   Allocate(size_t Size, size_t Alignment) {
     assert(Alignment > 0 && "0-byte alignment is not allowed. Use 1 instead.");
     return Allocate(Size, Align(Alignment));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117664.401193.patch
Type: text/x-patch
Size: 906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220119/0bdf9406/attachment.bin>


More information about the llvm-commits mailing list