-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an "allocator" attribute to mark functions as allocators #23322
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
I'm not keen that this teaches trans about jemalloc directly. Is there nowhere in liballoc where this can be annotated? |
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.
Updated the code to use a feature gated |
It's all experimental anyway, so it could be something like |
Yeah, since this is unstable and gated I feel good about it. @bors r+ rollup |
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.
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.