Uh oh!
There was an error while loading. Please reload this page.
Add an "allocator" attribute to mark functions as allocators - #23322
Conversation
rust-highfive
commented
Mar 12, 2015
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
brson
commented
Mar 13, 2015
I'm not keen that this teaches trans about jemalloc directly. Is there nowhere in liballoc where this can be annotated? |
dotdash
commented
Mar 13, 2015
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.
dotdash
commented
Mar 13, 2015
Updated the code to use a feature gated |
alexcrichton
commented
Mar 13, 2015
It's all experimental anyway, so it could be something like |
brson
commented
Mar 13, 2015
Yeah, since this is unstable and gated I feel good about it. @bors r+ rollup |
bors
commented
Mar 13, 2015
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.