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

Commit 0023fb9

Browse files
committed
Add some jemalloc functions to TargetLibraryInfo + MemoryBuiltins
Original patch by Nathaniel Theis
1 parent f8fee4a commit 0023fb9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

include/llvm/Analysis/TargetLibraryInfo.def

+6
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,12 @@ TLI_DEFINE_STRING_INTERNAL("isascii")
550550
/// int isdigit(int c);
551551
TLI_DEFINE_ENUM_INTERNAL(isdigit)
552552
TLI_DEFINE_STRING_INTERNAL("isdigit")
553+
/// void *je_mallocx(size_t size, int flags)
554+
TLI_DEFINE_ENUM_INTERNAL(je_mallocx)
555+
TLI_DEFINE_STRING_INTERNAL("je_mallocx")
556+
/// void je_sdallocx(void *ptr, size_t size, int flags)
557+
TLI_DEFINE_ENUM_INTERNAL(je_sdallocx)
558+
TLI_DEFINE_STRING_INTERNAL("je_sdallocx")
553559
/// long int labs(long int j);
554560
TLI_DEFINE_ENUM_INTERNAL(labs)
555561
TLI_DEFINE_STRING_INTERNAL("labs")

lib/Analysis/MemoryBuiltins.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ static const AllocFnsTy AllocationFnData[] = {
6666
{LibFunc::realloc, ReallocLike, 2, 1, -1},
6767
{LibFunc::reallocf, ReallocLike, 2, 1, -1},
6868
{LibFunc::strdup, StrDupLike, 1, -1, -1},
69-
{LibFunc::strndup, StrDupLike, 2, 1, -1}
69+
{LibFunc::strndup, StrDupLike, 2, 1, -1},
70+
{LibFunc::je_mallocx, MallocLike, 2, 0, -1}
7071
// TODO: Handle "int posix_memalign(void **, size_t, size_t)"
7172
};
7273

@@ -322,6 +323,8 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
322323
TLIFn == LibFunc::ZdaPvm || // delete[](void*, ulong)
323324
TLIFn == LibFunc::ZdaPvRKSt9nothrow_t) // delete[](void*, nothrow)
324325
ExpectedNumParams = 2;
326+
else if (TLIFn == LibFunc::je_sdallocx)
327+
ExpectedNumParams = 3;
325328
else
326329
return nullptr;
327330

0 commit comments

Comments
 (0)