[TLI] Add four C++17 delete variants.

Summary:
delete(void*, unsigned int, align_val_t)
delete(void*, unsigned long, align_val_t)
delete[](void*, unsigned int, align_val_t)
delete[](void*, unsigned long, align_val_t)

Differential Revision: https://reviews.llvm.org/D81853
This commit is contained in:
Hiroshi Yamauchi 2020-06-10 14:06:25 -07:00
parent 8aef01eed4
commit 6bc2b042f4
5 changed files with 45 additions and 2 deletions

View File

@ -136,9 +136,15 @@ TLI_DEFINE_STRING_INTERNAL("_ZdaPvSt11align_val_tRKSt9nothrow_t")
/// void operator delete[](void*, unsigned int);
TLI_DEFINE_ENUM_INTERNAL(ZdaPvj)
TLI_DEFINE_STRING_INTERNAL("_ZdaPvj")
/// void operator delete[](void*, unsigned int, align_val_t);
TLI_DEFINE_ENUM_INTERNAL(ZdaPvjSt11align_val_t)
TLI_DEFINE_STRING_INTERNAL("_ZdaPvjSt11align_val_t")
/// void operator delete[](void*, unsigned long);
TLI_DEFINE_ENUM_INTERNAL(ZdaPvm)
TLI_DEFINE_STRING_INTERNAL("_ZdaPvm")
/// void operator delete[](void*, unsigned long, align_val_t);
TLI_DEFINE_ENUM_INTERNAL(ZdaPvmSt11align_val_t)
TLI_DEFINE_STRING_INTERNAL("_ZdaPvmSt11align_val_t")
/// void operator delete(void*);
TLI_DEFINE_ENUM_INTERNAL(ZdlPv)
TLI_DEFINE_STRING_INTERNAL("_ZdlPv")
@ -154,9 +160,15 @@ TLI_DEFINE_STRING_INTERNAL("_ZdlPvSt11align_val_tRKSt9nothrow_t")
/// void operator delete(void*, unsigned int);
TLI_DEFINE_ENUM_INTERNAL(ZdlPvj)
TLI_DEFINE_STRING_INTERNAL("_ZdlPvj")
/// void operator delete(void*, unsigned int, align_val_t)
TLI_DEFINE_ENUM_INTERNAL(ZdlPvjSt11align_val_t)
TLI_DEFINE_STRING_INTERNAL("_ZdlPvjSt11align_val_t")
/// void operator delete(void*, unsigned long);
TLI_DEFINE_ENUM_INTERNAL(ZdlPvm)
TLI_DEFINE_STRING_INTERNAL("_ZdlPvm")
/// void operator delete(void*, unsigned long, align_val_t)
TLI_DEFINE_ENUM_INTERNAL(ZdlPvmSt11align_val_t)
TLI_DEFINE_STRING_INTERNAL("_ZdlPvmSt11align_val_t")
/// void *new[](unsigned int);
TLI_DEFINE_ENUM_INTERNAL(Znaj)
TLI_DEFINE_STRING_INTERNAL("_Znaj")

View File

@ -456,7 +456,11 @@ bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
TLIFn == LibFunc_msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow)
ExpectedNumParams = 2;
else if (TLIFn == LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t || // delete(void*, align_val_t, nothrow)
TLIFn == LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t) // delete[](void*, align_val_t, nothrow)
TLIFn == LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t || // delete[](void*, align_val_t, nothrow)
TLIFn == LibFunc_ZdlPvjSt11align_val_t || // delete(void*, unsigned long, align_val_t)
TLIFn == LibFunc_ZdlPvmSt11align_val_t || // delete(void*, unsigned long, align_val_t)
TLIFn == LibFunc_ZdaPvjSt11align_val_t || // delete[](void*, unsigned int, align_val_t)
TLIFn == LibFunc_ZdaPvmSt11align_val_t) // delete[](void*, unsigned long, align_val_t)
ExpectedNumParams = 3;
else
return false;

View File

@ -1218,6 +1218,14 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
case LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t:
// void operator delete[](void*, align_val_t, nothrow)
case LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t:
// void operator delete(void*, unsigned int, align_val_t)
case LibFunc_ZdlPvjSt11align_val_t:
// void operator delete(void*, unsigned long, align_val_t)
case LibFunc_ZdlPvmSt11align_val_t:
// void operator delete[](void*, unsigned int, align_val_t);
case LibFunc_ZdaPvjSt11align_val_t:
// void operator delete[](void*, unsigned long, align_val_t);
case LibFunc_ZdaPvmSt11align_val_t:
return (NumParams == 3 && FTy.getParamType(0)->isPointerTy());
case LibFunc_memset_pattern16:

View File

@ -267,7 +267,14 @@ declare void @_ZdaPvSt11align_val_t(i8*, i64) nobuiltin
declare void @_ZdlPvSt11align_val_tRKSt9nothrow_t(i8*, i64, i8*) nobuiltin
; delete[](void*, align_val_t, nothrow)
declare void @_ZdaPvSt11align_val_tRKSt9nothrow_t(i8*, i64, i8*) nobuiltin
; delete(void*, unsigned int, align_val_t)
declare void @_ZdlPvjSt11align_val_t(i8*, i32, i32) nobuiltin
; delete(void*, unsigned long, align_val_t)
declare void @_ZdlPvmSt11align_val_t(i8*, i64, i64) nobuiltin
; delete[](void*, unsigned int, align_val_t)
declare void @_ZdaPvjSt11align_val_t(i8*, i32, i32) nobuiltin
; delete[](void*, unsigned long, align_val_t)
declare void @_ZdaPvmSt11align_val_t(i8*, i64, i64) nobuiltin
define void @test8() {
; CHECK-LABEL: @test8(
@ -302,6 +309,14 @@ define void @test8() {
call void @_ZdlPvSt11align_val_tRKSt9nothrow_t(i8* %nwjat, i64 8, i8* %nt) builtin
%najat = call i8* @_ZnajSt11align_val_tRKSt9nothrow_t(i32 32, i32 8, i8* %nt) builtin
call void @_ZdaPvSt11align_val_tRKSt9nothrow_t(i8* %najat, i64 8, i8* %nt) builtin
%nwa2 = call i8* @_ZnwmSt11align_val_t(i64 32, i64 8) builtin
call void @_ZdlPvmSt11align_val_t(i8* %nwa2, i64 32, i64 8) builtin
%nwja2 = call i8* @_ZnwjSt11align_val_t(i32 32, i32 8) builtin
call void @_ZdlPvjSt11align_val_t(i8* %nwa2, i32 32, i32 8) builtin
%naa2 = call i8* @_ZnamSt11align_val_t(i64 32, i64 8) builtin
call void @_ZdaPvmSt11align_val_t(i8* %naa2, i64 32, i64 8) builtin
%naja2 = call i8* @_ZnajSt11align_val_t(i32 32, i32 8) builtin
call void @_ZdaPvjSt11align_val_t(i8* %naja2, i32 32, i32 8) builtin
ret void
}

View File

@ -415,13 +415,17 @@ TEST_F(TargetLibraryInfoTest, ValidProto) {
"declare void @_ZdaPvSt11align_val_t(i8*, i64)\n"
"declare void @_ZdaPvSt11align_val_tRKSt9nothrow_t(i8*, i64, %struct*)\n"
"declare void @_ZdaPvj(i8*, i32)\n"
"declare void @_ZdaPvjSt11align_val_t(i8*, i32, i32)\n"
"declare void @_ZdaPvm(i8*, i64)\n"
"declare void @_ZdaPvmSt11align_val_t(i8*, i64, i64)\n"
"declare void @_ZdlPv(i8*)\n"
"declare void @_ZdlPvRKSt9nothrow_t(i8*, %struct*)\n"
"declare void @_ZdlPvSt11align_val_t(i8*, i64)\n"
"declare void @_ZdlPvSt11align_val_tRKSt9nothrow_t(i8*, i64, %struct*)\n"
"declare void @_ZdlPvj(i8*, i32)\n"
"declare void @_ZdlPvjSt11align_val_t(i8*, i32, i32)\n"
"declare void @_ZdlPvm(i8*, i64)\n"
"declare void @_ZdlPvmSt11align_val_t(i8*, i64, i64)\n"
"declare i8* @_Znaj(i32)\n"
"declare i8* @_ZnajRKSt9nothrow_t(i32, %struct*)\n"
"declare i8* @_ZnajSt11align_val_t(i32, i32)\n"