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

Commit 8e1b4fe

Browse files
alexcrichtonarielb1
authored andcommitted
Merge pull request #88 from alexcrichton/tmp
Add knowledge of __rust_{alloc,realloc,dealloc}
2 parents 184599f + e7b49c8 commit 8e1b4fe

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/llvm/Analysis/TargetLibraryInfo.def

+8-3
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,23 @@ TLI_DEFINE_STRING_INTERNAL("__memset_chk")
200200
TLI_DEFINE_ENUM_INTERNAL(nvvm_reflect)
201201
TLI_DEFINE_STRING_INTERNAL("__nvvm_reflect")
202202

203+
TLI_DEFINE_ENUM_INTERNAL(rust_alloc)
204+
TLI_DEFINE_STRING_INTERNAL("__rust_alloc")
205+
203206
/// uint8_t *__rust_allocate(size_t size, size_t align)
204207
TLI_DEFINE_ENUM_INTERNAL(rust_allocate)
205208
TLI_DEFINE_STRING_INTERNAL("__rust_allocate")
206209

207-
/// uint8_t *__rust_allocate_zeroed(size_t size, size_t align)
208-
TLI_DEFINE_ENUM_INTERNAL(rust_allocate_zeroed)
209-
TLI_DEFINE_STRING_INTERNAL("__rust_allocate_zeroed")
210+
TLI_DEFINE_ENUM_INTERNAL(rust_dealloc)
211+
TLI_DEFINE_STRING_INTERNAL("__rust_dealloc")
210212

211213
/// void __rust_deallocate(uint8_t *ptr, size_t size, size_t align)
212214
TLI_DEFINE_ENUM_INTERNAL(rust_deallocate)
213215
TLI_DEFINE_STRING_INTERNAL("__rust_deallocate")
214216

217+
TLI_DEFINE_ENUM_INTERNAL(rust_realloc)
218+
TLI_DEFINE_STRING_INTERNAL("__rust_realloc")
219+
215220
/// uint8_t *__rust_reallocate(uint8_t *ptr, size_t oldsz, size_t newsz, size_t align)
216221
TLI_DEFINE_ENUM_INTERNAL(rust_reallocate)
217222
TLI_DEFINE_STRING_INTERNAL("__rust_reallocate")

lib/Analysis/MemoryBuiltins.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ static const std::pair<LibFunc::Func, AllocFnsTy> AllocationFnData[] = {
7575
{LibFunc::strdup, {StrDupLike, 1, -1, -1}},
7676
{LibFunc::strndup, {StrDupLike, 2, 1, -1}},
7777

78+
{LibFunc::rust_alloc, {MallocLike, 3, 0, -1}},
7879
{LibFunc::rust_allocate, {MallocLike, 2, 0, -1}},
80+
{LibFunc::rust_realloc, {ReallocLike, 6, 3, -1}},
7981
{LibFunc::rust_reallocate, {ReallocLike, 4, 2, -1}},
8082
// TODO: Handle "int posix_memalign(void **, size_t, size_t)"
8183
};
@@ -366,6 +368,8 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
366368
ExpectedNumParams = 2;
367369
else if (TLIFn == LibFunc::rust_deallocate)
368370
ExpectedNumParams = 3;
371+
else if (TLIFn == LibFunc::rust_dealloc)
372+
ExpectedNumParams = 3;
369373
else
370374
return nullptr;
371375

0 commit comments

Comments
 (0)