diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index 389fd250daa..56a89191a58 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -26,10 +26,18 @@ namespace llvm { ZdaPv, /// void operator delete[](void*, nothrow); ZdaPvRKSt9nothrow_t, + /// void operator delete[](void*, unsigned int); + ZdaPvj, + /// void operator delete[](void*, unsigned long); + ZdaPvm, /// void operator delete(void*); ZdlPv, /// void operator delete(void*, nothrow); ZdlPvRKSt9nothrow_t, + /// void operator delete(void*, unsigned int); + ZdlPvj, + /// void operator delete(void*, unsigned long); + ZdlPvm, /// void *new[](unsigned int); Znaj, /// void *new[](unsigned int, nothrow); diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp index 64d339f564d..5316cf9fef7 100644 --- a/lib/Analysis/MemoryBuiltins.cpp +++ b/lib/Analysis/MemoryBuiltins.cpp @@ -332,7 +332,11 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) { TLIFn == LibFunc::ZdlPv || // operator delete(void*) TLIFn == LibFunc::ZdaPv) // operator delete[](void*) ExpectedNumParams = 1; - else if (TLIFn == LibFunc::ZdlPvRKSt9nothrow_t || // delete(void*, nothrow) + else if (TLIFn == LibFunc::ZdlPvj || // delete(void*, uint) + TLIFn == LibFunc::ZdlPvm || // delete(void*, ulong) + TLIFn == LibFunc::ZdlPvRKSt9nothrow_t || // delete(void*, nothrow) + TLIFn == LibFunc::ZdaPvj || // delete[](void*, uint) + TLIFn == LibFunc::ZdaPvm || // delete[](void*, ulong) TLIFn == LibFunc::ZdaPvRKSt9nothrow_t) // delete[](void*, nothrow) ExpectedNumParams = 2; else diff --git a/lib/Target/TargetLibraryInfo.cpp b/lib/Target/TargetLibraryInfo.cpp index 616ff906730..7ca5c74e935 100644 --- a/lib/Target/TargetLibraryInfo.cpp +++ b/lib/Target/TargetLibraryInfo.cpp @@ -28,8 +28,12 @@ const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] = "_IO_putc", "_ZdaPv", "_ZdaPvRKSt9nothrow_t", + "_ZdaPvj", + "_ZdaPvm", "_ZdlPv", "_ZdlPvRKSt9nothrow_t", + "_ZdlPvj", + "_ZdlPvm", "_Znaj", "_ZnajRKSt9nothrow_t", "_Znam", diff --git a/test/Transforms/InstCombine/malloc-free-delete.ll b/test/Transforms/InstCombine/malloc-free-delete.ll index 20852065384..ed25e4e49c8 100644 --- a/test/Transforms/InstCombine/malloc-free-delete.ll +++ b/test/Transforms/InstCombine/malloc-free-delete.ll @@ -144,3 +144,26 @@ lpad.i: ; preds = %entry call void @_ZdlPvRKSt9nothrow_t(i8* %call.i, i8* %nt) builtin nounwind resume { i8*, i32 } %0 } + +declare i8* @_Znwm(i64) nobuiltin +declare void @_ZdlPvm(i8*, i64) nobuiltin +declare i8* @_Znwj(i32) nobuiltin +declare void @_ZdlPvj(i8*, i32) nobuiltin +declare i8* @_Znam(i64) nobuiltin +declare void @_ZdaPvm(i8*, i64) nobuiltin +declare i8* @_Znaj(i32) nobuiltin +declare void @_ZdaPvj(i8*, i32) nobuiltin + +; CHECK-LABEL: @test8( +define void @test8() { + ; CHECK-NOT: call + %nwm = call i8* @_Znwm(i64 32) builtin + call void @_ZdlPvm(i8* %nwm, i64 32) builtin + %nwj = call i8* @_Znwj(i32 32) builtin + call void @_ZdlPvj(i8* %nwj, i32 32) builtin + %nam = call i8* @_Znam(i64 32) builtin + call void @_ZdaPvm(i8* %nam, i64 32) builtin + %naj = call i8* @_Znaj(i32 32) builtin + call void @_ZdaPvj(i8* %naj, i32 32) builtin + ret void +}