Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
Add some Rust allocation functions to TargetLibraryInfo + MemoryBuiltins
Browse files Browse the repository at this point in the history
Original patch by Nathaniel Theis
  • Loading branch information
alexcrichton committed Mar 14, 2016
1 parent de62574 commit cca16c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/llvm/Analysis/TargetLibraryInfo.def
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ TLI_DEFINE_STRING_INTERNAL("__memmove_chk")
/// void *__memset_chk(void *s, char v, size_t n, size_t s1size);
TLI_DEFINE_ENUM_INTERNAL(memset_chk)
TLI_DEFINE_STRING_INTERNAL("__memset_chk")
/// void *__rust_allocate(size_t size, size_t align)
TLI_DEFINE_ENUM_INTERNAL(rust_allocate)
TLI_DEFINE_STRING_INTERNAL("__rust_allocate")
/// void __rust_deallocate(void *ptr, size_t size, size_t align)
TLI_DEFINE_ENUM_INTERNAL(rust_deallocate)
TLI_DEFINE_STRING_INTERNAL("__rust_deallocate")
/// double __sincospi_stret(double x);
TLI_DEFINE_ENUM_INTERNAL(sincospi_stret)
TLI_DEFINE_STRING_INTERNAL("__sincospi_stret")
Expand Down
5 changes: 4 additions & 1 deletion lib/Analysis/MemoryBuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ static const AllocFnsTy AllocationFnData[] = {
{LibFunc::realloc, ReallocLike, 2, 1, -1},
{LibFunc::reallocf, ReallocLike, 2, 1, -1},
{LibFunc::strdup, StrDupLike, 1, -1, -1},
{LibFunc::strndup, StrDupLike, 2, 1, -1}
{LibFunc::strndup, StrDupLike, 2, 1, -1},
{LibFunc::rust_allocate, MallocLike, 2, 0, -1}
// TODO: Handle "int posix_memalign(void **, size_t, size_t)"
};

Expand Down Expand Up @@ -323,6 +324,8 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
TLIFn == LibFunc::msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow)
TLIFn == LibFunc::msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow)
ExpectedNumParams = 2;
else if (TLIFn == LibFunc::rust_deallocate)
ExpectedNumParams = 3;
else
return nullptr;

Expand Down

0 comments on commit cca16c0

Please sign in to comment.