Add an "allocator" attribute to mark functions as allocators

When this attribute is applied to a function, its return value gets the
noalias attribute, which is how you tell LLVM that the function returns
a "new" pointer that doesn't alias anything accessible to the caller,
i.e. it acts like a memory allocator.

Plain malloc doesn't need this attribute because LLVM already knows
about malloc and adds the attribute itself.
This commit is contained in:
Björn Steinbrink
2015-03-13 03:19:30 +01:00
parent 49f7550a25
commit 0942803f50
5 changed files with 18 additions and 6 deletions

View File

@@ -69,6 +69,7 @@
#![feature(no_std)]
#![no_std]
#![feature(allocator)]
#![feature(lang_items, unsafe_destructor)]
#![feature(box_syntax)]
#![feature(optin_builtin_traits)]