MemoryBuiltins: remove malloc-family funcs from list
We no longer need specialized knowledge of these allocator functions in this file since we have the correct attributes available now. As far as I can tell the changes in the attributor tests are due to things getting more consistent on alloc-family once we remove the static list entries. The two test changes in NewGVN merit extra scrutiny: NewGVN appears to be _extremely_ sensitive to the inaccessiblememonly for reasons that are beyond me. As a result, I had-enumerated all the attributes on allocation functions in those two tests instead of using -inferattrs. I assumed that the two -disable-simplify-libcalls tests there no longer are sensible since the function declaration now includes all the relevant attributes. Differential Revision: https://reviews.llvm.org/D130107
This commit is contained in:
parent
12c0bf8ba9
commit
85063090e9
|
@ -115,9 +115,7 @@ struct AllocFnsTy {
|
|||
// FIXME: certain users need more information. E.g., SimplifyLibCalls needs to
|
||||
// know which functions are nounwind, noalias, nocapture parameters, etc.
|
||||
static const std::pair<LibFunc, AllocFnsTy> AllocationFnData[] = {
|
||||
{LibFunc_malloc, {MallocLike, 1, 0, -1, -1, MallocFamily::Malloc}},
|
||||
{LibFunc_vec_malloc, {MallocLike, 1, 0, -1, -1, MallocFamily::VecMalloc}},
|
||||
{LibFunc_valloc, {MallocLike, 1, 0, -1, -1, MallocFamily::Malloc}},
|
||||
{LibFunc_Znwj, {OpNewLike, 1, 0, -1, -1, MallocFamily::CPPNew}}, // new(unsigned int)
|
||||
{LibFunc_ZnwjRKSt9nothrow_t, {MallocLike, 2, 0, -1, -1, MallocFamily::CPPNew}}, // new(unsigned int, nothrow)
|
||||
{LibFunc_ZnwjSt11align_val_t, {OpNewLike, 2, 0, -1, 1, MallocFamily::CPPNewAligned}}, // new(unsigned int, align_val_t)
|
||||
|
@ -142,13 +140,9 @@ static const std::pair<LibFunc, AllocFnsTy> AllocationFnData[] = {
|
|||
{LibFunc_msvc_new_array_int_nothrow, {MallocLike, 2, 0, -1, -1, MallocFamily::MSVCArrayNew}}, // new[](unsigned int, nothrow)
|
||||
{LibFunc_msvc_new_array_longlong, {OpNewLike, 1, 0, -1, -1, MallocFamily::MSVCArrayNew}}, // new[](unsigned long long)
|
||||
{LibFunc_msvc_new_array_longlong_nothrow, {MallocLike, 2, 0, -1, -1, MallocFamily::MSVCArrayNew}}, // new[](unsigned long long, nothrow)
|
||||
{LibFunc_aligned_alloc, {AlignedAllocLike, 2, 1, -1, 0, MallocFamily::Malloc}},
|
||||
{LibFunc_memalign, {AlignedAllocLike, 2, 1, -1, 0, MallocFamily::Malloc}},
|
||||
{LibFunc_calloc, {CallocLike, 2, 0, 1, -1, MallocFamily::Malloc}},
|
||||
{LibFunc_vec_calloc, {CallocLike, 2, 0, 1, -1, MallocFamily::VecMalloc}},
|
||||
{LibFunc_realloc, {ReallocLike, 2, 1, -1, -1, MallocFamily::Malloc}},
|
||||
{LibFunc_vec_realloc, {ReallocLike, 2, 1, -1, -1, MallocFamily::VecMalloc}},
|
||||
{LibFunc_reallocf, {ReallocLike, 2, 1, -1, -1, MallocFamily::Malloc}},
|
||||
{LibFunc_strdup, {StrDupLike, 1, -1, -1, -1, MallocFamily::Malloc}},
|
||||
{LibFunc_dunder_strdup, {StrDupLike, 1, -1, -1, -1, MallocFamily::Malloc}},
|
||||
{LibFunc_strndup, {StrDupLike, 2, 1, -1, -1, MallocFamily::Malloc}},
|
||||
|
@ -488,7 +482,6 @@ struct FreeFnsTy {
|
|||
|
||||
// clang-format off
|
||||
static const std::pair<LibFunc, FreeFnsTy> FreeFnData[] = {
|
||||
{LibFunc_free, {1, MallocFamily::Malloc}},
|
||||
{LibFunc_vec_free, {1, MallocFamily::VecMalloc}},
|
||||
{LibFunc_ZdlPv, {1, MallocFamily::CPPNew}}, // operator delete(void*)
|
||||
{LibFunc_ZdaPv, {1, MallocFamily::CPPNewArray}}, // operator delete[](void*)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,8 +12,8 @@ define dso_local void @test() local_unnamed_addr #0 {
|
|||
}
|
||||
|
||||
declare dso_local noalias noundef i8* @malloc(i64 noundef) local_unnamed_addr #1
|
||||
declare dso_local noalias noundef i8* @realloc(i8* nocapture, i64 noundef) local_unnamed_addr #2
|
||||
declare dso_local void @free(i8* nocapture noundef) local_unnamed_addr #2
|
||||
declare dso_local noalias noundef i8* @realloc(i8* nocapture allocptr, i64 noundef) local_unnamed_addr #2
|
||||
declare dso_local void @free(i8* nocapture allocptr noundef) local_unnamed_addr #2
|
||||
declare void @llvm.dbg.value(metadata, metadata, metadata) #3
|
||||
|
||||
attributes #0 = { mustprogress nounwind uwtable willreturn }
|
||||
|
|
|
@ -11,8 +11,8 @@ define dso_local void @_Z3fooPv(i8* nocapture %0) local_unnamed_addr #0 {
|
|||
ret void
|
||||
}
|
||||
|
||||
declare dso_local noalias noundef i8* @realloc(i8* nocapture, i64 noundef) local_unnamed_addr #1
|
||||
declare dso_local void @free(i8* nocapture noundef) local_unnamed_addr #2
|
||||
declare dso_local noalias noundef i8* @realloc(i8* allocptr nocapture, i64 noundef) local_unnamed_addr #1
|
||||
declare dso_local void @free(i8* allocptr nocapture noundef) local_unnamed_addr #2
|
||||
|
||||
attributes #0 = { mustprogress nounwind uwtable willreturn }
|
||||
attributes #1 = { inaccessiblemem_or_argmemonly mustprogress nounwind willreturn allockind("realloc") }
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
; RUN: opt -S -passes=newgvn < %s | FileCheck %s
|
||||
; RUN: opt -S -passes=newgvn -disable-simplify-libcalls < %s | FileCheck %s -check-prefix=CHECK_NO_LIBCALLS
|
||||
; Check that loads from calloc are recognized as being zero.
|
||||
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
|
@ -15,11 +14,6 @@ define i32 @test1() {
|
|||
; CHECK-LABEL: @test1(
|
||||
; CHECK-NOT: %3 = load i32, i32* %2, align 4
|
||||
; CHECK: ret i32 0
|
||||
|
||||
; CHECK_NO_LIBCALLS-LABEL: @test1(
|
||||
; CHECK_NO_LIBCALLS: load
|
||||
; CHECK_NO_LIBCALLS: ret i32 %
|
||||
|
||||
}
|
||||
|
||||
declare noalias i8* @calloc(i64, i64)
|
||||
declare noalias i8* @calloc(i64, i64) mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) "alloc-family"="malloc"
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
; RUN: opt -S -passes=newgvn < %s | FileCheck %s
|
||||
; RUN: opt -S -passes=newgvn -disable-simplify-libcalls < %s | FileCheck %s -check-prefix=CHECK_NO_LIBCALLS
|
||||
; PR13694
|
||||
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.8.0"
|
||||
|
||||
declare i8* @malloc(i64) nounwind
|
||||
declare i8* @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc"
|
||||
|
||||
define noalias i8* @test1() nounwind uwtable ssp {
|
||||
entry:
|
||||
|
@ -24,10 +23,6 @@ if.end: ; preds = %if.then, %entry
|
|||
; CHECK-LABEL: @test1(
|
||||
; CHECK-NOT: load
|
||||
; CHECK-NOT: icmp
|
||||
|
||||
; CHECK_NO_LIBCALLS-LABEL: @test1(
|
||||
; CHECK_NO_LIBCALLS: load
|
||||
; CHECK_NO_LIBCALLS: icmp
|
||||
}
|
||||
|
||||
declare i8* @_Znwm(i64) nounwind
|
||||
|
@ -49,13 +44,9 @@ if.end: ; preds = %if.then, %entry
|
|||
; CHECK-LABEL: @test2(
|
||||
; CHECK-NOT: load
|
||||
; CHECK-NOT: icmp
|
||||
|
||||
; CHECK_NO_LIBCALLS-LABEL: @test2(
|
||||
; CHECK_NO_LIBCALLS: load
|
||||
; CHECK_NO_LIBCALLS: icmp
|
||||
}
|
||||
|
||||
declare i8* @aligned_alloc(i64, i64) nounwind
|
||||
declare i8* @aligned_alloc(i64 allocalign, i64) nounwind allockind("alloc,uninitialized,aligned") allocsize(1) "alloc-family"="malloc"
|
||||
|
||||
define noalias i8* @test3() nounwind uwtable ssp {
|
||||
entry:
|
||||
|
@ -74,8 +65,4 @@ if.end: ; preds = %if.then, %entry
|
|||
; CHECK-LABEL: @test3(
|
||||
; CHECK-NOT: load
|
||||
; CHECK-NOT: icmp
|
||||
|
||||
; CHECK_NO_LIBCALLS-LABEL: @test3(
|
||||
; CHECK_NO_LIBCALLS: load
|
||||
; CHECK_NO_LIBCALLS: icmp
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue