PR21145: Teach LLVM about C++14 sized deallocation functions.

C++14 adds new builtin signatures for 'operator delete'. This change allows
new/delete pairs to be removed in C++14 onwards, as they were in C++11 and
before.

llvm-svn: 219014
This commit is contained in:
Richard Smith 2014-10-03 20:17:06 +00:00
parent aae7fefce8
commit 1ed4229f6f
4 changed files with 40 additions and 1 deletions

View File

@ -26,10 +26,18 @@ namespace llvm {
ZdaPv, ZdaPv,
/// void operator delete[](void*, nothrow); /// void operator delete[](void*, nothrow);
ZdaPvRKSt9nothrow_t, ZdaPvRKSt9nothrow_t,
/// void operator delete[](void*, unsigned int);
ZdaPvj,
/// void operator delete[](void*, unsigned long);
ZdaPvm,
/// void operator delete(void*); /// void operator delete(void*);
ZdlPv, ZdlPv,
/// void operator delete(void*, nothrow); /// void operator delete(void*, nothrow);
ZdlPvRKSt9nothrow_t, ZdlPvRKSt9nothrow_t,
/// void operator delete(void*, unsigned int);
ZdlPvj,
/// void operator delete(void*, unsigned long);
ZdlPvm,
/// void *new[](unsigned int); /// void *new[](unsigned int);
Znaj, Znaj,
/// void *new[](unsigned int, nothrow); /// void *new[](unsigned int, nothrow);

View File

@ -332,7 +332,11 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
TLIFn == LibFunc::ZdlPv || // operator delete(void*) TLIFn == LibFunc::ZdlPv || // operator delete(void*)
TLIFn == LibFunc::ZdaPv) // operator delete[](void*) TLIFn == LibFunc::ZdaPv) // operator delete[](void*)
ExpectedNumParams = 1; 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) TLIFn == LibFunc::ZdaPvRKSt9nothrow_t) // delete[](void*, nothrow)
ExpectedNumParams = 2; ExpectedNumParams = 2;
else else

View File

@ -28,8 +28,12 @@ const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] =
"_IO_putc", "_IO_putc",
"_ZdaPv", "_ZdaPv",
"_ZdaPvRKSt9nothrow_t", "_ZdaPvRKSt9nothrow_t",
"_ZdaPvj",
"_ZdaPvm",
"_ZdlPv", "_ZdlPv",
"_ZdlPvRKSt9nothrow_t", "_ZdlPvRKSt9nothrow_t",
"_ZdlPvj",
"_ZdlPvm",
"_Znaj", "_Znaj",
"_ZnajRKSt9nothrow_t", "_ZnajRKSt9nothrow_t",
"_Znam", "_Znam",

View File

@ -144,3 +144,26 @@ lpad.i: ; preds = %entry
call void @_ZdlPvRKSt9nothrow_t(i8* %call.i, i8* %nt) builtin nounwind call void @_ZdlPvRKSt9nothrow_t(i8* %call.i, i8* %nt) builtin nounwind
resume { i8*, i32 } %0 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
}