diff --git a/llvm/test/Analysis/GlobalsModRef/indirect-global.ll b/llvm/test/Analysis/GlobalsModRef/indirect-global.ll --- a/llvm/test/Analysis/GlobalsModRef/indirect-global.ll +++ b/llvm/test/Analysis/GlobalsModRef/indirect-global.ll @@ -9,7 +9,7 @@ @G = internal global i32* null ; [#uses=3] -declare noalias i8* @malloc(i32) +declare noalias i8* @malloc(i32) allockind("alloc,uninitialized") allocsize(0) inaccessiblememonly define void @malloc_init() { ; CHECK-LABEL: @malloc_init( ; CHECK-NEXT: [[A:%.*]] = call dereferenceable_or_null(4) i8* @malloc(i32 4) @@ -38,7 +38,7 @@ @G2 = internal global i32* null ; [#uses=3] -declare noalias i8* @calloc(i32, i32) +declare noalias i8* @calloc(i32, i32) allockind("alloc,zeroed") allocsize(0,1) inaccessiblememonly define void @calloc_init() { ; CHECK-LABEL: @calloc_init( ; CHECK-NEXT: [[A:%.*]] = call dereferenceable_or_null(4) i8* @calloc(i32 4, i32 1) diff --git a/llvm/test/Instrumentation/BoundsChecking/simple.ll b/llvm/test/Instrumentation/BoundsChecking/simple.ll --- a/llvm/test/Instrumentation/BoundsChecking/simple.ll +++ b/llvm/test/Instrumentation/BoundsChecking/simple.ll @@ -6,9 +6,9 @@ @.str_as1 = private addrspace(1) constant [8 x i8] c"abcdefg\00" ; <[8 x i8] addrspace(1)*> -declare noalias i8* @malloc(i64) nounwind -declare noalias i8* @calloc(i64, i64) nounwind -declare noalias i8* @realloc(i8* nocapture, i64) nounwind +declare noalias i8* @malloc(i64) nounwind allocsize(0) +declare noalias i8* @calloc(i64, i64) nounwind allocsize(0,1) +declare noalias i8* @realloc(i8* nocapture allocptr, i64) nounwind allocsize(1) ; CHECK: @f1 define void @f1() nounwind { diff --git a/llvm/test/Transforms/Attributor/heap_to_stack.ll b/llvm/test/Transforms/Attributor/heap_to_stack.ll --- a/llvm/test/Transforms/Attributor/heap_to_stack.ll +++ b/llvm/test/Transforms/Attributor/heap_to_stack.ll @@ -1,10 +1,10 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals -; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=5 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM +; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=8 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=8 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM ; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM -declare noalias i8* @malloc(i64) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) declare void @nocapture_func_frees_pointer(i8* nocapture) @@ -26,7 +26,7 @@ declare i32 @no_return_call() noreturn -declare void @free(i8* nocapture) +declare void @free(i8* nocapture) allockind("free") declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind @@ -34,24 +34,24 @@ ; IS________OPM-LABEL: define {{[^@]+}}@h2s_value_simplify_interaction ; IS________OPM-SAME: (i1 [[C:%.*]], i8* nocapture nofree readnone [[A:%.*]]) { ; IS________OPM-NEXT: entry: -; IS________OPM-NEXT: [[M:%.*]] = tail call noalias align 16 i8* @malloc(i64 noundef 4) +; IS________OPM-NEXT: [[M_H2S:%.*]] = alloca i8, i64 4, align 16 ; IS________OPM-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]] ; IS________OPM: t: ; IS________OPM-NEXT: br i1 false, label [[DEAD:%.*]], label [[F2:%.*]] ; IS________OPM: f: ; IS________OPM-NEXT: br label [[J:%.*]] ; IS________OPM: f2: -; IS________OPM-NEXT: [[C1:%.*]] = bitcast i8* [[M]] to i32* +; IS________OPM-NEXT: [[C1:%.*]] = bitcast i8* [[M_H2S]] to i32* ; IS________OPM-NEXT: [[C2:%.*]] = bitcast i32* [[C1]] to i8* ; IS________OPM-NEXT: [[L:%.*]] = load i8, i8* [[C2]], align 16 ; IS________OPM-NEXT: call void @usei8(i8 [[L]]) -; IS________OPM-NEXT: call void @no_sync_func(i8* nocapture nofree noundef align 16 [[C2]]) #[[ATTR5:[0-9]+]] +; IS________OPM-NEXT: call void @no_sync_func(i8* nocapture nofree noundef align 16 [[C2]]) #[[ATTR10:[0-9]+]] ; IS________OPM-NEXT: br label [[J]] ; IS________OPM: dead: ; IS________OPM-NEXT: unreachable ; IS________OPM: j: -; IS________OPM-NEXT: [[PHI:%.*]] = phi i8* [ [[M]], [[F]] ], [ null, [[F2]] ] -; IS________OPM-NEXT: tail call void @no_sync_func(i8* nocapture nofree noundef align 16 [[PHI]]) #[[ATTR5]] +; IS________OPM-NEXT: [[PHI:%.*]] = phi i8* [ [[M_H2S]], [[F]] ], [ null, [[F2]] ] +; IS________OPM-NEXT: tail call void @no_sync_func(i8* nocapture nofree noundef align 16 [[PHI]]) #[[ATTR10]] ; IS________OPM-NEXT: ret void ; ; IS________NPM-LABEL: define {{[^@]+}}@h2s_value_simplify_interaction @@ -66,13 +66,13 @@ ; IS________NPM: f2: ; IS________NPM-NEXT: [[L:%.*]] = load i8, i8* [[M_H2S]], align 16 ; IS________NPM-NEXT: call void @usei8(i8 [[L]]) -; IS________NPM-NEXT: call void @no_sync_func(i8* nocapture nofree noundef align 16 [[M_H2S]]) #[[ATTR6:[0-9]+]] +; IS________NPM-NEXT: call void @no_sync_func(i8* nocapture nofree noundef align 16 [[M_H2S]]) #[[ATTR10:[0-9]+]] ; IS________NPM-NEXT: br label [[J]] ; IS________NPM: dead: ; IS________NPM-NEXT: unreachable ; IS________NPM: j: ; IS________NPM-NEXT: [[PHI:%.*]] = phi i8* [ [[M_H2S]], [[F]] ], [ null, [[F2]] ] -; IS________NPM-NEXT: tail call void @no_sync_func(i8* nocapture nofree noundef align 16 [[PHI]]) #[[ATTR6]] +; IS________NPM-NEXT: tail call void @no_sync_func(i8* nocapture nofree noundef align 16 [[PHI]]) #[[ATTR10]] ; IS________NPM-NEXT: ret void ; entry: @@ -146,16 +146,10 @@ ; TEST 3 - 1 malloc, 1 free define void @test3() { -; IS________OPM-LABEL: define {{[^@]+}}@test3() { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[TMP1]]) -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP1]]) -; IS________OPM-NEXT: ret void -; -; IS________NPM-LABEL: define {{[^@]+}}@test3() { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[DOTH2S]]) -; IS________NPM-NEXT: ret void +; CHECK-LABEL: define {{[^@]+}}@test3() { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[DOTH2S]]) +; CHECK-NEXT: ret void ; %1 = tail call noalias i8* @malloc(i64 4) tail call void @no_sync_func(i8* %1) @@ -166,9 +160,8 @@ define void @test3a(i8* %p) { ; IS________OPM-LABEL: define {{[^@]+}}@test3a ; IS________OPM-SAME: (i8* nocapture [[P:%.*]]) { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: tail call void @nofree_arg_only(i8* nocapture nofree [[TMP1]], i8* nocapture [[P]]) -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP1]]) +; IS________OPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; IS________OPM-NEXT: tail call void @nofree_arg_only(i8* nocapture nofree [[DOTH2S]], i8* nocapture [[P]]) ; IS________OPM-NEXT: ret void ; ; IS________NPM-LABEL: define {{[^@]+}}@test3a @@ -183,14 +176,13 @@ ret void } -declare noalias i8* @aligned_alloc(i64, i64) +declare noalias i8* @aligned_alloc(i64, i64) allockind("alloc,uninitialized,aligned") allocsize(1) define void @test3b(i8* %p) { ; IS________OPM-LABEL: define {{[^@]+}}@test3b ; IS________OPM-SAME: (i8* nocapture [[P:%.*]]) { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @aligned_alloc(i64 noundef 32, i64 noundef 128) -; IS________OPM-NEXT: tail call void @nofree_arg_only(i8* nocapture nofree [[TMP1]], i8* nocapture [[P]]) -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP1]]) +; IS________OPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 128, align 1 +; IS________OPM-NEXT: tail call void @nofree_arg_only(i8* nocapture nofree [[DOTH2S]], i8* nocapture [[P]]) ; IS________OPM-NEXT: ret void ; ; IS________NPM-LABEL: define {{[^@]+}}@test3b @@ -207,11 +199,16 @@ ; leave alone non-constant alignments. define void @test3c(i64 %alignment) { -; CHECK-LABEL: define {{[^@]+}}@test3c -; CHECK-SAME: (i64 [[ALIGNMENT:%.*]]) { -; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias i8* @aligned_alloc(i64 [[ALIGNMENT]], i64 noundef 128) -; CHECK-NEXT: tail call void @free(i8* noalias nocapture [[TMP1]]) -; CHECK-NEXT: ret void +; IS________OPM-LABEL: define {{[^@]+}}@test3c +; IS________OPM-SAME: (i64 [[ALIGNMENT:%.*]]) { +; IS________OPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 128, align 1 +; IS________OPM-NEXT: ret void +; +; IS________NPM-LABEL: define {{[^@]+}}@test3c +; IS________NPM-SAME: (i64 [[ALIGNMENT:%.*]]) { +; IS________NPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @aligned_alloc(i64 [[ALIGNMENT]], i64 noundef 128) +; IS________NPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP1]]) +; IS________NPM-NEXT: ret void ; %1 = tail call noalias i8* @aligned_alloc(i64 %alignment, i64 128) tail call void @free(i8* %1) @@ -222,9 +219,8 @@ define void @test3d(i8* %p) { ; IS________OPM-LABEL: define {{[^@]+}}@test3d ; IS________OPM-SAME: (i8* nocapture [[P:%.*]]) { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @aligned_alloc(i64 noundef 33, i64 noundef 128) -; IS________OPM-NEXT: tail call void @nofree_arg_only(i8* nocapture nofree [[TMP1]], i8* nocapture [[P]]) -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP1]]) +; IS________OPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 128, align 1 +; IS________OPM-NEXT: tail call void @nofree_arg_only(i8* nocapture nofree [[DOTH2S]], i8* nocapture [[P]]) ; IS________OPM-NEXT: ret void ; ; IS________NPM-LABEL: define {{[^@]+}}@test3d @@ -241,20 +237,14 @@ ret void } -declare noalias i8* @calloc(i64, i64) +declare noalias i8* @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1) define void @test0() { -; IS________OPM-LABEL: define {{[^@]+}}@test0() { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @calloc(i64 noundef 2, i64 noundef 4) -; IS________OPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[TMP1]]) -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP1]]) -; IS________OPM-NEXT: ret void -; -; IS________NPM-LABEL: define {{[^@]+}}@test0() { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 8, align 1 -; IS________NPM-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DOTH2S]], i8 0, i64 8, i1 false) -; IS________NPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[DOTH2S]]) -; IS________NPM-NEXT: ret void +; CHECK-LABEL: define {{[^@]+}}@test0() { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 8, align 1 +; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DOTH2S]], i8 0, i64 8, i1 false) +; CHECK-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[DOTH2S]]) +; CHECK-NEXT: ret void ; %1 = tail call noalias i8* @calloc(i64 2, i64 4) tail call void @no_sync_func(i8* %1) @@ -264,15 +254,10 @@ ; TEST 4 define void @test4() { -; IS________OPM-LABEL: define {{[^@]+}}@test4() { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: tail call void @nofree_func(i8* noalias nocapture nofree [[TMP1]]) -; IS________OPM-NEXT: ret void -; -; IS________NPM-LABEL: define {{[^@]+}}@test4() { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: tail call void @nofree_func(i8* noalias nocapture nofree [[DOTH2S]]) -; IS________NPM-NEXT: ret void +; CHECK-LABEL: define {{[^@]+}}@test4() { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: tail call void @nofree_func(i8* noalias nocapture nofree [[DOTH2S]]) +; CHECK-NEXT: ret void ; %1 = tail call noalias i8* @malloc(i64 4) tail call void @nofree_func(i8* %1) @@ -285,17 +270,16 @@ define void @test5(i32, i8* %p) { ; IS________OPM-LABEL: define {{[^@]+}}@test5 ; IS________OPM-SAME: (i32 [[TMP0:%.*]], i8* nocapture [[P:%.*]]) { -; IS________OPM-NEXT: [[TMP2:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0 -; IS________OPM-NEXT: br i1 [[TMP3]], label [[TMP5:%.*]], label [[TMP4:%.*]] +; IS________OPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; IS________OPM-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP0]], 0 +; IS________OPM-NEXT: br i1 [[TMP2]], label [[TMP4:%.*]], label [[TMP3:%.*]] +; IS________OPM: 3: +; IS________OPM-NEXT: tail call void @nofree_func(i8* noalias nocapture nofree [[DOTH2S]]) +; IS________OPM-NEXT: br label [[TMP5:%.*]] ; IS________OPM: 4: -; IS________OPM-NEXT: tail call void @nofree_func(i8* noalias nocapture nofree [[TMP2]]) -; IS________OPM-NEXT: br label [[TMP6:%.*]] +; IS________OPM-NEXT: tail call void @nofree_arg_only(i8* nocapture nofree [[DOTH2S]], i8* nocapture [[P]]) +; IS________OPM-NEXT: br label [[TMP5]] ; IS________OPM: 5: -; IS________OPM-NEXT: tail call void @nofree_arg_only(i8* nocapture nofree [[TMP2]], i8* nocapture [[P]]) -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP2]]) -; IS________OPM-NEXT: br label [[TMP6]] -; IS________OPM: 6: ; IS________OPM-NEXT: ret void ; ; IS________NPM-LABEL: define {{[^@]+}}@test5 @@ -332,33 +316,18 @@ ; TEST 6 - all exit paths have a call to free define void @test6(i32) { -; IS________OPM-LABEL: define {{[^@]+}}@test6 -; IS________OPM-SAME: (i32 [[TMP0:%.*]]) { -; IS________OPM-NEXT: [[TMP2:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0 -; IS________OPM-NEXT: br i1 [[TMP3]], label [[TMP5:%.*]], label [[TMP4:%.*]] -; IS________OPM: 4: -; IS________OPM-NEXT: tail call void @nofree_func(i8* noalias nocapture nofree [[TMP2]]) -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP2]]) -; IS________OPM-NEXT: br label [[TMP6:%.*]] -; IS________OPM: 5: -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture [[TMP2]]) -; IS________OPM-NEXT: br label [[TMP6]] -; IS________OPM: 6: -; IS________OPM-NEXT: ret void -; -; IS________NPM-LABEL: define {{[^@]+}}@test6 -; IS________NPM-SAME: (i32 [[TMP0:%.*]]) { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP0]], 0 -; IS________NPM-NEXT: br i1 [[TMP2]], label [[TMP4:%.*]], label [[TMP3:%.*]] -; IS________NPM: 3: -; IS________NPM-NEXT: tail call void @nofree_func(i8* noalias nocapture nofree [[DOTH2S]]) -; IS________NPM-NEXT: br label [[TMP5:%.*]] -; IS________NPM: 4: -; IS________NPM-NEXT: br label [[TMP5]] -; IS________NPM: 5: -; IS________NPM-NEXT: ret void +; CHECK-LABEL: define {{[^@]+}}@test6 +; CHECK-SAME: (i32 [[TMP0:%.*]]) { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP0]], 0 +; CHECK-NEXT: br i1 [[TMP2]], label [[TMP4:%.*]], label [[TMP3:%.*]] +; CHECK: 3: +; CHECK-NEXT: tail call void @nofree_func(i8* noalias nocapture nofree [[DOTH2S]]) +; CHECK-NEXT: br label [[TMP5:%.*]] +; CHECK: 4: +; CHECK-NEXT: br label [[TMP5]] +; CHECK: 5: +; CHECK-NEXT: ret void ; %2 = tail call noalias i8* @malloc(i64 4) %3 = icmp eq i32 %0, 0 @@ -380,15 +349,10 @@ ; TEST 7 - free is dead. define void @test7() { -; IS________OPM-LABEL: define {{[^@]+}}@test7() { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: [[TMP2:%.*]] = tail call i32 @no_return_call() #[[ATTR3:[0-9]+]] -; IS________OPM-NEXT: unreachable -; -; IS________NPM-LABEL: define {{[^@]+}}@test7() { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: [[TMP1:%.*]] = tail call i32 @no_return_call() #[[ATTR3:[0-9]+]] -; IS________NPM-NEXT: unreachable +; CHECK-LABEL: define {{[^@]+}}@test7() { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @no_return_call() #[[ATTR4:[0-9]+]] +; CHECK-NEXT: unreachable ; %1 = tail call noalias i8* @malloc(i64 4) tail call i32 @no_return_call() @@ -420,23 +384,14 @@ ; TEST 9 - FIXME: malloc should be converted. define void @test9() { -; IS________OPM-LABEL: define {{[^@]+}}@test9() { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[TMP1]]) -; IS________OPM-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32* -; IS________OPM-NEXT: store i32 10, i32* [[TMP2]], align 4 -; IS________OPM-NEXT: tail call void @foo_nounw(i32* nofree noundef align 4 [[TMP2]]) #[[ATTR5]] -; IS________OPM-NEXT: tail call void @free(i8* nocapture noundef nonnull align 4 dereferenceable(4) [[TMP1]]) -; IS________OPM-NEXT: ret void -; -; IS________NPM-LABEL: define {{[^@]+}}@test9() { -; IS________NPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________NPM-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[TMP1]]) -; IS________NPM-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32* -; IS________NPM-NEXT: store i32 10, i32* [[TMP2]], align 4 -; IS________NPM-NEXT: tail call void @foo_nounw(i32* nofree noundef align 4 [[TMP2]]) #[[ATTR6]] -; IS________NPM-NEXT: tail call void @free(i8* nocapture noundef nonnull align 4 dereferenceable(4) [[TMP1]]) -; IS________NPM-NEXT: ret void +; CHECK-LABEL: define {{[^@]+}}@test9() { +; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) +; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[TMP1]]) +; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32* +; CHECK-NEXT: store i32 10, i32* [[TMP2]], align 4 +; CHECK-NEXT: tail call void @foo_nounw(i32* nofree noundef align 4 [[TMP2]]) #[[ATTR10:[0-9]+]] +; CHECK-NEXT: tail call void @free(i8* nocapture noundef nonnull align 4 dereferenceable(4) [[TMP1]]) +; CHECK-NEXT: ret void ; %1 = tail call noalias i8* @malloc(i64 4) tail call void @no_sync_func(i8* %1) @@ -451,22 +406,13 @@ ; TEST 10 - 1 malloc, 1 free define i32 @test10() { -; IS________OPM-LABEL: define {{[^@]+}}@test10() { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[TMP1]]) -; IS________OPM-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32* -; IS________OPM-NEXT: store i32 10, i32* [[TMP2]], align 4 -; IS________OPM-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP2]], align 4 -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture noundef nonnull align 4 dereferenceable(4) [[TMP1]]) -; IS________OPM-NEXT: ret i32 [[TMP3]] -; -; IS________NPM-LABEL: define {{[^@]+}}@test10() { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[DOTH2S]]) -; IS________NPM-NEXT: [[TMP1:%.*]] = bitcast i8* [[DOTH2S]] to i32* -; IS________NPM-NEXT: store i32 10, i32* [[TMP1]], align 4 -; IS________NPM-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP1]], align 4 -; IS________NPM-NEXT: ret i32 [[TMP2]] +; CHECK-LABEL: define {{[^@]+}}@test10() { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[DOTH2S]]) +; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[DOTH2S]] to i32* +; CHECK-NEXT: store i32 10, i32* [[TMP1]], align 4 +; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP1]], align 4 +; CHECK-NEXT: ret i32 [[TMP2]] ; %1 = tail call noalias i8* @malloc(i64 4) tail call void @no_sync_func(i8* %1) @@ -478,24 +424,14 @@ } define i32 @test_lifetime() { -; IS________OPM-LABEL: define {{[^@]+}}@test_lifetime() { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[TMP1]]) -; IS________OPM-NEXT: call void @llvm.lifetime.start.p0i8(i64 noundef 4, i8* noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[TMP1]]) -; IS________OPM-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32* -; IS________OPM-NEXT: store i32 10, i32* [[TMP2]], align 4 -; IS________OPM-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP2]], align 4 -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture noundef nonnull align 4 dereferenceable(4) [[TMP1]]) -; IS________OPM-NEXT: ret i32 [[TMP3]] -; -; IS________NPM-LABEL: define {{[^@]+}}@test_lifetime() { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[DOTH2S]]) -; IS________NPM-NEXT: call void @llvm.lifetime.start.p0i8(i64 noundef 4, i8* noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[DOTH2S]]) -; IS________NPM-NEXT: [[TMP1:%.*]] = bitcast i8* [[DOTH2S]] to i32* -; IS________NPM-NEXT: store i32 10, i32* [[TMP1]], align 4 -; IS________NPM-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP1]], align 4 -; IS________NPM-NEXT: ret i32 [[TMP2]] +; CHECK-LABEL: define {{[^@]+}}@test_lifetime() { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree [[DOTH2S]]) +; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 noundef 4, i8* noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[DOTH2S]]) +; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[DOTH2S]] to i32* +; CHECK-NEXT: store i32 10, i32* [[TMP1]], align 4 +; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP1]], align 4 +; CHECK-NEXT: ret i32 [[TMP2]] ; %1 = tail call noalias i8* @malloc(i64 4) tail call void @no_sync_func(i8* %1) @@ -510,16 +446,10 @@ ; TEST 11 define void @test11() { -; IS________OPM-LABEL: define {{[^@]+}}@test11() { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: tail call void @sync_will_return(i8* [[TMP1]]) #[[ATTR5]] -; IS________OPM-NEXT: tail call void @free(i8* nocapture [[TMP1]]) -; IS________OPM-NEXT: ret void -; -; IS________NPM-LABEL: define {{[^@]+}}@test11() { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: tail call void @sync_will_return(i8* [[DOTH2S]]) #[[ATTR6]] -; IS________NPM-NEXT: ret void +; CHECK-LABEL: define {{[^@]+}}@test11() { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: tail call void @sync_will_return(i8* [[DOTH2S]]) #[[ATTR10]] +; CHECK-NEXT: ret void ; %1 = tail call noalias i8* @malloc(i64 4) tail call void @sync_will_return(i8* %1) @@ -529,67 +459,35 @@ ; TEST 12 define i32 @irreducible_cfg(i32 %0) { -; IS________OPM-LABEL: define {{[^@]+}}@irreducible_cfg -; IS________OPM-SAME: (i32 [[TMP0:%.*]]) { -; IS________OPM-NEXT: [[TMP2:%.*]] = call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: [[TMP3:%.*]] = bitcast i8* [[TMP2]] to i32* -; IS________OPM-NEXT: store i32 10, i32* [[TMP3]], align 4 -; IS________OPM-NEXT: [[TMP4:%.*]] = icmp eq i32 [[TMP0]], 1 -; IS________OPM-NEXT: br i1 [[TMP4]], label [[TMP5:%.*]], label [[TMP7:%.*]] -; IS________OPM: 5: -; IS________OPM-NEXT: [[TMP6:%.*]] = add nsw i32 [[TMP0]], 5 -; IS________OPM-NEXT: br label [[TMP13:%.*]] -; IS________OPM: 7: -; IS________OPM-NEXT: br label [[TMP8:%.*]] -; IS________OPM: 8: -; IS________OPM-NEXT: [[DOT0:%.*]] = phi i32 [ [[TMP14:%.*]], [[TMP13]] ], [ 1, [[TMP7]] ] -; IS________OPM-NEXT: [[TMP9:%.*]] = load i32, i32* [[TMP3]], align 4 -; IS________OPM-NEXT: [[TMP10:%.*]] = add nsw i32 [[TMP9]], -1 -; IS________OPM-NEXT: store i32 [[TMP10]], i32* [[TMP3]], align 4 -; IS________OPM-NEXT: [[TMP11:%.*]] = icmp ne i32 [[TMP9]], 0 -; IS________OPM-NEXT: br i1 [[TMP11]], label [[TMP12:%.*]], label [[TMP15:%.*]] -; IS________OPM: 12: -; IS________OPM-NEXT: br label [[TMP13]] -; IS________OPM: 13: -; IS________OPM-NEXT: [[DOT1:%.*]] = phi i32 [ [[TMP6]], [[TMP5]] ], [ [[DOT0]], [[TMP12]] ] -; IS________OPM-NEXT: [[TMP14]] = add nsw i32 [[DOT1]], 1 -; IS________OPM-NEXT: br label [[TMP8]] -; IS________OPM: 15: -; IS________OPM-NEXT: [[TMP16:%.*]] = load i32, i32* [[TMP3]], align 4 -; IS________OPM-NEXT: [[TMP17:%.*]] = bitcast i32* [[TMP3]] to i8* -; IS________OPM-NEXT: call void @free(i8* nocapture noundef [[TMP17]]) -; IS________OPM-NEXT: [[TMP18:%.*]] = load i32, i32* [[TMP3]], align 4 -; IS________OPM-NEXT: ret i32 [[TMP18]] -; -; IS________NPM-LABEL: define {{[^@]+}}@irreducible_cfg -; IS________NPM-SAME: (i32 [[TMP0:%.*]]) { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: [[TMP2:%.*]] = bitcast i8* [[DOTH2S]] to i32* -; IS________NPM-NEXT: store i32 10, i32* [[TMP2]], align 4 -; IS________NPM-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 1 -; IS________NPM-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP6:%.*]] -; IS________NPM: 4: -; IS________NPM-NEXT: [[TMP5:%.*]] = add nsw i32 [[TMP0]], 5 -; IS________NPM-NEXT: br label [[TMP12:%.*]] -; IS________NPM: 6: -; IS________NPM-NEXT: br label [[TMP7:%.*]] -; IS________NPM: 7: -; IS________NPM-NEXT: [[DOT0:%.*]] = phi i32 [ [[TMP13:%.*]], [[TMP12]] ], [ 1, [[TMP6]] ] -; IS________NPM-NEXT: [[TMP8:%.*]] = load i32, i32* [[TMP2]], align 4 -; IS________NPM-NEXT: [[TMP9:%.*]] = add nsw i32 [[TMP8]], -1 -; IS________NPM-NEXT: store i32 [[TMP9]], i32* [[TMP2]], align 4 -; IS________NPM-NEXT: [[TMP10:%.*]] = icmp ne i32 [[TMP8]], 0 -; IS________NPM-NEXT: br i1 [[TMP10]], label [[TMP11:%.*]], label [[TMP14:%.*]] -; IS________NPM: 11: -; IS________NPM-NEXT: br label [[TMP12]] -; IS________NPM: 12: -; IS________NPM-NEXT: [[DOT1:%.*]] = phi i32 [ [[TMP5]], [[TMP4]] ], [ [[DOT0]], [[TMP11]] ] -; IS________NPM-NEXT: [[TMP13]] = add nsw i32 [[DOT1]], 1 -; IS________NPM-NEXT: br label [[TMP7]] -; IS________NPM: 14: -; IS________NPM-NEXT: [[TMP15:%.*]] = bitcast i32* [[TMP2]] to i8* -; IS________NPM-NEXT: [[TMP16:%.*]] = load i32, i32* [[TMP2]], align 4 -; IS________NPM-NEXT: ret i32 [[TMP16]] +; CHECK-LABEL: define {{[^@]+}}@irreducible_cfg +; CHECK-SAME: (i32 [[TMP0:%.*]]) { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[DOTH2S]] to i32* +; CHECK-NEXT: store i32 10, i32* [[TMP2]], align 4 +; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 1 +; CHECK-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP6:%.*]] +; CHECK: 4: +; CHECK-NEXT: [[TMP5:%.*]] = add nsw i32 [[TMP0]], 5 +; CHECK-NEXT: br label [[TMP12:%.*]] +; CHECK: 6: +; CHECK-NEXT: br label [[TMP7:%.*]] +; CHECK: 7: +; CHECK-NEXT: [[DOT0:%.*]] = phi i32 [ [[TMP13:%.*]], [[TMP12]] ], [ 1, [[TMP6]] ] +; CHECK-NEXT: [[TMP8:%.*]] = load i32, i32* [[TMP2]], align 4 +; CHECK-NEXT: [[TMP9:%.*]] = add nsw i32 [[TMP8]], -1 +; CHECK-NEXT: store i32 [[TMP9]], i32* [[TMP2]], align 4 +; CHECK-NEXT: [[TMP10:%.*]] = icmp ne i32 [[TMP8]], 0 +; CHECK-NEXT: br i1 [[TMP10]], label [[TMP11:%.*]], label [[TMP14:%.*]] +; CHECK: 11: +; CHECK-NEXT: br label [[TMP12]] +; CHECK: 12: +; CHECK-NEXT: [[DOT1:%.*]] = phi i32 [ [[TMP5]], [[TMP4]] ], [ [[DOT0]], [[TMP11]] ] +; CHECK-NEXT: [[TMP13]] = add nsw i32 [[DOT1]], 1 +; CHECK-NEXT: br label [[TMP7]] +; CHECK: 14: +; CHECK-NEXT: [[TMP15:%.*]] = bitcast i32* [[TMP2]] to i8* +; CHECK-NEXT: [[TMP16:%.*]] = load i32, i32* [[TMP2]], align 4 +; CHECK-NEXT: ret i32 [[TMP16]] ; %2 = call noalias i8* @malloc(i64 4) %3 = bitcast i8* %2 to i32* @@ -630,43 +528,24 @@ define i32 @malloc_in_loop(i32 %0) { -; IS________OPM-LABEL: define {{[^@]+}}@malloc_in_loop -; IS________OPM-SAME: (i32 [[TMP0:%.*]]) { -; IS________OPM-NEXT: [[TMP2:%.*]] = alloca i32, align 4 -; IS________OPM-NEXT: [[TMP3:%.*]] = alloca i32*, align 8 -; IS________OPM-NEXT: store i32 [[TMP0]], i32* [[TMP2]], align 4 -; IS________OPM-NEXT: br label [[TMP4:%.*]] -; IS________OPM: 4: -; IS________OPM-NEXT: [[TMP5:%.*]] = load i32, i32* [[TMP2]], align 4 -; IS________OPM-NEXT: [[TMP6:%.*]] = add nsw i32 [[TMP5]], -1 -; IS________OPM-NEXT: store i32 [[TMP6]], i32* [[TMP2]], align 4 -; IS________OPM-NEXT: [[TMP7:%.*]] = icmp sgt i32 [[TMP6]], 0 -; IS________OPM-NEXT: br i1 [[TMP7]], label [[TMP8:%.*]], label [[TMP11:%.*]] -; IS________OPM: 8: -; IS________OPM-NEXT: [[TMP9:%.*]] = call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: [[TMP10:%.*]] = bitcast i8* [[TMP9]] to i32* -; IS________OPM-NEXT: br label [[TMP4]] -; IS________OPM: 11: -; IS________OPM-NEXT: ret i32 5 -; -; IS________NPM-LABEL: define {{[^@]+}}@malloc_in_loop -; IS________NPM-SAME: (i32 [[TMP0:%.*]]) { -; IS________NPM-NEXT: [[TMP2:%.*]] = alloca i32, align 4 -; IS________NPM-NEXT: [[TMP3:%.*]] = alloca i32*, align 8 -; IS________NPM-NEXT: store i32 [[TMP0]], i32* [[TMP2]], align 4 -; IS________NPM-NEXT: br label [[TMP4:%.*]] -; IS________NPM: 4: -; IS________NPM-NEXT: [[TMP5:%.*]] = load i32, i32* [[TMP2]], align 4 -; IS________NPM-NEXT: [[TMP6:%.*]] = add nsw i32 [[TMP5]], -1 -; IS________NPM-NEXT: store i32 [[TMP6]], i32* [[TMP2]], align 4 -; IS________NPM-NEXT: [[TMP7:%.*]] = icmp sgt i32 [[TMP6]], 0 -; IS________NPM-NEXT: br i1 [[TMP7]], label [[TMP8:%.*]], label [[TMP10:%.*]] -; IS________NPM: 8: -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: [[TMP9:%.*]] = bitcast i8* [[DOTH2S]] to i32* -; IS________NPM-NEXT: br label [[TMP4]] -; IS________NPM: 10: -; IS________NPM-NEXT: ret i32 5 +; CHECK-LABEL: define {{[^@]+}}@malloc_in_loop +; CHECK-SAME: (i32 [[TMP0:%.*]]) { +; CHECK-NEXT: [[TMP2:%.*]] = alloca i32, align 4 +; CHECK-NEXT: [[TMP3:%.*]] = alloca i32*, align 8 +; CHECK-NEXT: store i32 [[TMP0]], i32* [[TMP2]], align 4 +; CHECK-NEXT: br label [[TMP4:%.*]] +; CHECK: 4: +; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* [[TMP2]], align 4 +; CHECK-NEXT: [[TMP6:%.*]] = add nsw i32 [[TMP5]], -1 +; CHECK-NEXT: store i32 [[TMP6]], i32* [[TMP2]], align 4 +; CHECK-NEXT: [[TMP7:%.*]] = icmp sgt i32 [[TMP6]], 0 +; CHECK-NEXT: br i1 [[TMP7]], label [[TMP8:%.*]], label [[TMP10:%.*]] +; CHECK: 8: +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: [[TMP9:%.*]] = bitcast i8* [[DOTH2S]] to i32* +; CHECK-NEXT: br label [[TMP4]] +; CHECK: 10: +; CHECK-NEXT: ret i32 5 ; %2 = alloca i32, align 4 %3 = alloca i32*, align 8 @@ -776,20 +655,12 @@ } define void @test16a(i8 %v, i8** %P) { -; IS________OPM-LABEL: define {{[^@]+}}@test16a -; IS________OPM-SAME: (i8 [[V:%.*]], i8** nocapture nofree readnone [[P:%.*]]) { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: store i8 [[V]], i8* [[TMP1]], align 1 -; IS________OPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree noundef nonnull dereferenceable(1) [[TMP1]]) -; IS________OPM-NEXT: tail call void @free(i8* noalias nocapture noundef nonnull dereferenceable(1) [[TMP1]]) -; IS________OPM-NEXT: ret void -; -; IS________NPM-LABEL: define {{[^@]+}}@test16a -; IS________NPM-SAME: (i8 [[V:%.*]], i8** nocapture nofree readnone [[P:%.*]]) { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: store i8 [[V]], i8* [[DOTH2S]], align 1 -; IS________NPM-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree noundef nonnull dereferenceable(1) [[DOTH2S]]) -; IS________NPM-NEXT: ret void +; CHECK-LABEL: define {{[^@]+}}@test16a +; CHECK-SAME: (i8 [[V:%.*]], i8** nocapture nofree readnone [[P:%.*]]) { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: store i8 [[V]], i8* [[DOTH2S]], align 1 +; CHECK-NEXT: tail call void @no_sync_func(i8* noalias nocapture nofree noundef nonnull dereferenceable(1) [[DOTH2S]]) +; CHECK-NEXT: ret void ; %1 = tail call noalias i8* @malloc(i64 4) store i8 %v, i8* %1 @@ -815,20 +686,12 @@ } define void @test16c(i8 %v, i8** %P) { -; IS________OPM-LABEL: define {{[^@]+}}@test16c -; IS________OPM-SAME: (i8 [[V:%.*]], i8** nocapture nofree writeonly [[P:%.*]]) { -; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4) -; IS________OPM-NEXT: store i8* [[TMP1]], i8** [[P]], align 8 -; IS________OPM-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[TMP1]]) #[[ATTR5]] -; IS________OPM-NEXT: tail call void @free(i8* nocapture [[TMP1]]) -; IS________OPM-NEXT: ret void -; -; IS________NPM-LABEL: define {{[^@]+}}@test16c -; IS________NPM-SAME: (i8 [[V:%.*]], i8** nocapture nofree writeonly [[P:%.*]]) { -; IS________NPM-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 -; IS________NPM-NEXT: store i8* [[DOTH2S]], i8** [[P]], align 8 -; IS________NPM-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[DOTH2S]]) #[[ATTR6]] -; IS________NPM-NEXT: ret void +; CHECK-LABEL: define {{[^@]+}}@test16c +; CHECK-SAME: (i8 [[V:%.*]], i8** nocapture nofree writeonly [[P:%.*]]) { +; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1 +; CHECK-NEXT: store i8* [[DOTH2S]], i8** [[P]], align 8 +; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[DOTH2S]]) #[[ATTR10]] +; CHECK-NEXT: ret void ; %1 = tail call noalias i8* @malloc(i64 4) store i8* %1, i8** %P @@ -849,18 +712,15 @@ ret void } ;. -; IS________OPM: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn } -; IS________OPM: attributes #[[ATTR1:[0-9]+]] = { nofree nosync willreturn } -; IS________OPM: attributes #[[ATTR2:[0-9]+]] = { nofree nounwind } -; IS________OPM: attributes #[[ATTR3]] = { noreturn } -; IS________OPM: attributes #[[ATTR4:[0-9]+]] = { argmemonly nocallback nofree nosync nounwind willreturn } -; IS________OPM: attributes #[[ATTR5]] = { nounwind } -;. -; IS________NPM: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn } -; IS________NPM: attributes #[[ATTR1:[0-9]+]] = { nofree nosync willreturn } -; IS________NPM: attributes #[[ATTR2:[0-9]+]] = { nofree nounwind } -; IS________NPM: attributes #[[ATTR3]] = { noreturn } -; IS________NPM: attributes #[[ATTR4:[0-9]+]] = { argmemonly nocallback nofree nosync nounwind willreturn } -; IS________NPM: attributes #[[ATTR5:[0-9]+]] = { argmemonly nofree nounwind willreturn writeonly } -; IS________NPM: attributes #[[ATTR6]] = { nounwind } +; CHECK: attributes #[[ATTR0:[0-9]+]] = { allockind("alloc,uninitialized") allocsize(0) } +; CHECK: attributes #[[ATTR1:[0-9]+]] = { nounwind willreturn } +; CHECK: attributes #[[ATTR2:[0-9]+]] = { nofree nosync willreturn } +; CHECK: attributes #[[ATTR3:[0-9]+]] = { nofree nounwind } +; CHECK: attributes #[[ATTR4]] = { noreturn } +; CHECK: attributes #[[ATTR5:[0-9]+]] = { allockind("free") } +; CHECK: attributes #[[ATTR6:[0-9]+]] = { argmemonly nocallback nofree nosync nounwind willreturn } +; CHECK: attributes #[[ATTR7:[0-9]+]] = { allockind("alloc,uninitialized,aligned") allocsize(1) } +; CHECK: attributes #[[ATTR8:[0-9]+]] = { allockind("alloc,zeroed") allocsize(0,1) } +; CHECK: attributes #[[ATTR9:[0-9]+]] = { argmemonly nofree nounwind willreturn writeonly } +; CHECK: attributes #[[ATTR10]] = { nounwind } ;. diff --git a/llvm/test/Transforms/Attributor/lowerheap.ll b/llvm/test/Transforms/Attributor/lowerheap.ll --- a/llvm/test/Transforms/Attributor/lowerheap.ll +++ b/llvm/test/Transforms/Attributor/lowerheap.ll @@ -6,25 +6,17 @@ declare i64 @subfn(i8*) #0 -declare noalias i8* @malloc(i64) -declare noalias i8* @calloc(i64, i64) -declare void @free(i8*) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc" +declare noalias i8* @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1) "alloc-family"="malloc" +declare void @free(i8*) allockind("free") "alloc-family"="malloc" define i64 @f(i64 %len) { -; IS________OPM-LABEL: define {{[^@]+}}@f -; IS________OPM-SAME: (i64 [[LEN:%.*]]) { -; IS________OPM-NEXT: entry: -; IS________OPM-NEXT: [[MEM:%.*]] = call noalias i8* @malloc(i64 [[LEN]]) -; IS________OPM-NEXT: [[RES:%.*]] = call i64 @subfn(i8* [[MEM]]) #[[ATTR1:[0-9]+]] -; IS________OPM-NEXT: call void @free(i8* [[MEM]]) -; IS________OPM-NEXT: ret i64 [[RES]] -; -; IS________NPM-LABEL: define {{[^@]+}}@f -; IS________NPM-SAME: (i64 [[LEN:%.*]]) { -; IS________NPM-NEXT: entry: -; IS________NPM-NEXT: [[TMP0:%.*]] = alloca i8, i64 [[LEN]], align 1 -; IS________NPM-NEXT: [[RES:%.*]] = call i64 @subfn(i8* [[TMP0]]) #[[ATTR2:[0-9]+]] -; IS________NPM-NEXT: ret i64 [[RES]] +; CHECK-LABEL: define {{[^@]+}}@f +; CHECK-SAME: (i64 [[LEN:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT: [[MEM_H2S:%.*]] = alloca i8, i64 [[LEN]], align 1 +; CHECK-NEXT: [[RES:%.*]] = call i64 @subfn(i8* [[MEM_H2S]]) #[[ATTR5:[0-9]+]] +; CHECK-NEXT: ret i64 [[RES]] ; entry: %mem = call i8* @malloc(i64 %len) @@ -35,22 +27,14 @@ define i64 @g(i64 %len) { -; IS________OPM-LABEL: define {{[^@]+}}@g -; IS________OPM-SAME: (i64 [[LEN:%.*]]) { -; IS________OPM-NEXT: entry: -; IS________OPM-NEXT: [[MEM:%.*]] = call noalias i8* @calloc(i64 [[LEN]], i64 noundef 8) -; IS________OPM-NEXT: [[RES:%.*]] = call i64 @subfn(i8* [[MEM]]) #[[ATTR1]] -; IS________OPM-NEXT: call void @free(i8* [[MEM]]) -; IS________OPM-NEXT: ret i64 [[RES]] -; -; IS________NPM-LABEL: define {{[^@]+}}@g -; IS________NPM-SAME: (i64 [[LEN:%.*]]) { -; IS________NPM-NEXT: entry: -; IS________NPM-NEXT: [[TMP0:%.*]] = mul i64 [[LEN]], 8 -; IS________NPM-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[TMP0]], align 1 -; IS________NPM-NEXT: call void @llvm.memset.p0i8.i64(i8* [[TMP1]], i8 0, i64 [[TMP0]], i1 false) -; IS________NPM-NEXT: [[RES:%.*]] = call i64 @subfn(i8* [[TMP1]]) #[[ATTR2]] -; IS________NPM-NEXT: ret i64 [[RES]] +; CHECK-LABEL: define {{[^@]+}}@g +; CHECK-SAME: (i64 [[LEN:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT: [[TMP0:%.*]] = mul i64 [[LEN]], 8 +; CHECK-NEXT: [[MEM_H2S:%.*]] = alloca i8, i64 [[TMP0]], align 1 +; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[MEM_H2S]], i8 0, i64 [[TMP0]], i1 false) +; CHECK-NEXT: [[RES:%.*]] = call i64 @subfn(i8* [[MEM_H2S]]) #[[ATTR5]] +; CHECK-NEXT: ret i64 [[RES]] ; entry: %mem = call i8* @calloc(i64 %len, i64 8) @@ -61,10 +45,10 @@ attributes #0 = { nounwind willreturn } ;. -; IS________OPM: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn } -; IS________OPM: attributes #[[ATTR1]] = { nounwind } -;. -; IS________NPM: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn } -; IS________NPM: attributes #[[ATTR1:[0-9]+]] = { argmemonly nofree nounwind willreturn writeonly } -; IS________NPM: attributes #[[ATTR2]] = { nounwind } +; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn } +; CHECK: attributes #[[ATTR1:[0-9]+]] = { allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc" } +; CHECK: attributes #[[ATTR2:[0-9]+]] = { allockind("alloc,zeroed") allocsize(0,1) "alloc-family"="malloc" } +; CHECK: attributes #[[ATTR3:[0-9]+]] = { allockind("free") "alloc-family"="malloc" } +; CHECK: attributes #[[ATTR4:[0-9]+]] = { argmemonly nofree nounwind willreturn writeonly } +; CHECK: attributes #[[ATTR5]] = { nounwind } ;. diff --git a/llvm/test/Transforms/Coroutines/coro-split-00.ll b/llvm/test/Transforms/Coroutines/coro-split-00.ll --- a/llvm/test/Transforms/Coroutines/coro-split-00.ll +++ b/llvm/test/Transforms/Coroutines/coro-split-00.ll @@ -74,8 +74,8 @@ declare i8* @llvm.coro.begin(token, i8*) declare i1 @llvm.coro.end(i8*, i1) -declare noalias i8* @malloc(i32) +declare noalias i8* @malloc(i32) allockind("alloc,uninitialized") "alloc-family"="malloc" declare void @print(i32) -declare void @free(i8*) willreturn +declare void @free(i8*) willreturn allockind("free") "alloc-family"="malloc" !0 = !{i32 846595819, i8** null} diff --git a/llvm/test/Transforms/Coroutines/coro-split-hidden.ll b/llvm/test/Transforms/Coroutines/coro-split-hidden.ll --- a/llvm/test/Transforms/Coroutines/coro-split-hidden.ll +++ b/llvm/test/Transforms/Coroutines/coro-split-hidden.ll @@ -76,6 +76,6 @@ declare i8* @llvm.coro.begin(token, i8*) declare i1 @llvm.coro.end(i8*, i1) -declare noalias i8* @malloc(i32) +declare noalias i8* @malloc(i32) allockind("alloc,uninitialized") declare void @print(i32) -declare void @free(i8*) willreturn +declare void @free(i8*) willreturn allockind("free") diff --git a/llvm/test/Transforms/Coroutines/no-suspend.ll b/llvm/test/Transforms/Coroutines/no-suspend.ll --- a/llvm/test/Transforms/Coroutines/no-suspend.ll +++ b/llvm/test/Transforms/Coroutines/no-suspend.ll @@ -413,8 +413,8 @@ resume { i8*, i32 } %lpval } -declare i8* @malloc(i32) -declare void @free(i8*) willreturn +declare i8* @malloc(i32) allockind("alloc,uninitialized") allocsize(0) +declare void @free(i8*) willreturn allockind("free") declare void @print(i32) declare void @foo() diff --git a/llvm/test/Transforms/DeadStoreElimination/2016-07-17-UseAfterFree.ll b/llvm/test/Transforms/DeadStoreElimination/2016-07-17-UseAfterFree.ll --- a/llvm/test/Transforms/DeadStoreElimination/2016-07-17-UseAfterFree.ll +++ b/llvm/test/Transforms/DeadStoreElimination/2016-07-17-UseAfterFree.ll @@ -23,10 +23,10 @@ } ; Function Attrs: nounwind -declare void @free(i8* nocapture) local_unnamed_addr #0 +declare void @free(i8* nocapture allocptr) local_unnamed_addr #0 ; Function Attrs: argmemonly nounwind declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1) #1 -attributes #0 = { nounwind } +attributes #0 = { nounwind allockind("free")} attributes #1 = { argmemonly nounwind } diff --git a/llvm/test/Transforms/DeadStoreElimination/calloc-store.ll b/llvm/test/Transforms/DeadStoreElimination/calloc-store.ll --- a/llvm/test/Transforms/DeadStoreElimination/calloc-store.ll +++ b/llvm/test/Transforms/DeadStoreElimination/calloc-store.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -basic-aa -dse -S | FileCheck %s -declare noalias i8* @calloc(i64, i64) inaccessiblememonly +declare noalias i8* @calloc(i64, i64) inaccessiblememonly allockind("alloc,zeroed") define i32* @test1() { ; CHECK-LABEL: test1 diff --git a/llvm/test/Transforms/DeadStoreElimination/free.ll b/llvm/test/Transforms/DeadStoreElimination/free.ll --- a/llvm/test/Transforms/DeadStoreElimination/free.ll +++ b/llvm/test/Transforms/DeadStoreElimination/free.ll @@ -3,8 +3,8 @@ target datalayout = "e-p:64:64:64" -declare void @free(i8* nocapture) -declare noalias i8* @malloc(i64) +declare void @free(i8* nocapture) allockind("free") +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") define void @test(i32* %Q, i32* %P) { ; CHECK-LABEL: @test( diff --git a/llvm/test/Transforms/DeadStoreElimination/multiblock-malloc-free.ll b/llvm/test/Transforms/DeadStoreElimination/multiblock-malloc-free.ll --- a/llvm/test/Transforms/DeadStoreElimination/multiblock-malloc-free.ll +++ b/llvm/test/Transforms/DeadStoreElimination/multiblock-malloc-free.ll @@ -367,9 +367,9 @@ ret %struct.BitfieldStruct* %retval.0 } -attributes #0 = { nofree nounwind allocsize(0) } +attributes #0 = { nofree nounwind allocsize(0) allockind("alloc,uninitialized") } attributes #1 = { nofree nounwind } -attributes #2 = { nounwind } +attributes #2 = { nounwind allockind("free") } attributes #3 = { allocsize(0,1) } attributes #4 = { allocsize(0) } -attributes #5 = { nofree nounwind allocsize(0,1) } +attributes #5 = { nofree nounwind allocsize(0,1) allockind("alloc,zeroed") } diff --git a/llvm/test/Transforms/DeadStoreElimination/operand-bundles.ll b/llvm/test/Transforms/DeadStoreElimination/operand-bundles.ll --- a/llvm/test/Transforms/DeadStoreElimination/operand-bundles.ll +++ b/llvm/test/Transforms/DeadStoreElimination/operand-bundles.ll @@ -42,7 +42,7 @@ ret void } -declare noalias i8* @calloc(i64, i64) inaccessiblememonly +declare noalias i8* @calloc(i64, i64) inaccessiblememonly allockind("alloc,zeroed") define void @test4() { ; CHECK-LABEL: @test4 diff --git a/llvm/test/Transforms/DeadStoreElimination/simple.ll b/llvm/test/Transforms/DeadStoreElimination/simple.ll --- a/llvm/test/Transforms/DeadStoreElimination/simple.ll +++ b/llvm/test/Transforms/DeadStoreElimination/simple.ll @@ -264,9 +264,9 @@ } -declare noalias i8* @malloc(i64) willreturn +declare noalias i8* @malloc(i64) willreturn allockind("alloc,uninitialized") declare noalias i8* @custom_malloc(i32) willreturn -declare noalias i8* @calloc(i32, i32) willreturn +declare noalias i8* @calloc(i32, i32) willreturn allockind("alloc,zeroed") define void @test14(i32* %Q) { ; CHECK-LABEL: @test14( @@ -693,7 +693,7 @@ ret void } -declare void @free(i8* nocapture) +declare void @free(i8* nocapture) allockind("free") ; We cannot remove `store i32 1, i32* %p`, because @unknown_func may unwind ; and the caller may read %p while unwinding. diff --git a/llvm/test/Transforms/GVN/calloc-load-removal.ll b/llvm/test/Transforms/GVN/calloc-load-removal.ll --- a/llvm/test/Transforms/GVN/calloc-load-removal.ll +++ b/llvm/test/Transforms/GVN/calloc-load-removal.ll @@ -1,5 +1,4 @@ ; RUN: opt -S -basic-aa -gvn < %s | FileCheck %s -; RUN: opt -S -basic-aa -gvn -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" @@ -46,4 +45,4 @@ ; CHECK_NO_LIBCALLS: ret i32 % } -declare noalias i8* @calloc(i64, i64) +declare noalias i8* @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1) diff --git a/llvm/test/Transforms/GVN/malloc-load-removal.ll b/llvm/test/Transforms/GVN/malloc-load-removal.ll --- a/llvm/test/Transforms/GVN/malloc-load-removal.ll +++ b/llvm/test/Transforms/GVN/malloc-load-removal.ll @@ -1,11 +1,10 @@ ; RUN: opt -S -basic-aa -gvn < %s | FileCheck %s -; RUN: opt -S -basic-aa -gvn -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 noalias i8* @malloc(i64) nounwind +declare noalias i8* @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) define noalias i8* @test1() nounwind uwtable ssp { entry: @@ -55,7 +54,7 @@ ; CHECK_NO_LIBCALLS: icmp } -declare noalias i8* @aligned_alloc(i64, i64) nounwind +declare noalias i8* @aligned_alloc(i64 allocalign, i64) nounwind allockind("alloc,uninitialized,aligned") allocsize(1) define noalias i8* @test3() nounwind uwtable ssp { entry: diff --git a/llvm/test/Transforms/GVN/nonescaping-malloc.ll b/llvm/test/Transforms/GVN/nonescaping-malloc.ll --- a/llvm/test/Transforms/GVN/nonescaping-malloc.ll +++ b/llvm/test/Transforms/GVN/nonescaping-malloc.ll @@ -35,7 +35,7 @@ declare i64 @strlen(i8* nocapture) nounwind readonly -declare noalias i8* @malloc(i64) nounwind +declare noalias i8* @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) inaccessiblememonly declare i32 @_ZN4llvm13StringMapImpl15LookupBucketForENS_9StringRefE(%"struct.llvm::StringMapImpl"*, i64, i64) diff --git a/llvm/test/Transforms/GVN/nonescaping.ll b/llvm/test/Transforms/GVN/nonescaping.ll --- a/llvm/test/Transforms/GVN/nonescaping.ll +++ b/llvm/test/Transforms/GVN/nonescaping.ll @@ -4,8 +4,8 @@ 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" target triple = "x86_64-apple-darwin10.0" -declare noalias i8* @malloc(i64) nounwind -declare noalias i8* @calloc(i64, i64) +declare noalias i8* @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) inaccessiblememonly +declare noalias i8* @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1) inaccessiblememonly declare noalias i8* @_Znwm(i64) declare void @escape(i8*) diff --git a/llvm/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll b/llvm/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll --- a/llvm/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll +++ b/llvm/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll @@ -23,4 +23,4 @@ ret void } -declare noalias i8* @malloc(i64) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") diff --git a/llvm/test/Transforms/GlobalOpt/2021-08-03-StoreOnceLoadMultiCasts.ll b/llvm/test/Transforms/GlobalOpt/2021-08-03-StoreOnceLoadMultiCasts.ll --- a/llvm/test/Transforms/GlobalOpt/2021-08-03-StoreOnceLoadMultiCasts.ll +++ b/llvm/test/Transforms/GlobalOpt/2021-08-03-StoreOnceLoadMultiCasts.ll @@ -40,5 +40,5 @@ ret i32 %1 } -declare noalias align 16 i8* @malloc(i64) +declare noalias align 16 i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) declare void @f1() diff --git a/llvm/test/Transforms/GlobalOpt/calloc-promote.ll b/llvm/test/Transforms/GlobalOpt/calloc-promote.ll --- a/llvm/test/Transforms/GlobalOpt/calloc-promote.ll +++ b/llvm/test/Transforms/GlobalOpt/calloc-promote.ll @@ -45,5 +45,5 @@ ret i32 %res } -declare noalias align 16 i8* @calloc(i64, i64) +declare noalias align 16 i8* @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1) declare void @f1() diff --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll --- a/llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll +++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll @@ -16,7 +16,7 @@ ret void } -declare noalias i8* @malloc(i64) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) define i32 @get() { ; CHECK-LABEL: @get( diff --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll --- a/llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll +++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll @@ -17,7 +17,7 @@ ret void } -declare noalias i8* @malloc(i64) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) define void @foo(i64 %Size) nounwind noinline #0 { ; CHECK-LABEL: @foo( diff --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-4.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-4.ll --- a/llvm/test/Transforms/GlobalOpt/malloc-promote-4.ll +++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-4.ll @@ -58,4 +58,4 @@ ret i32 %1 } -declare dso_local noalias i8* @malloc(i64) +declare dso_local noalias i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) diff --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-5.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-5.ll --- a/llvm/test/Transforms/GlobalOpt/malloc-promote-5.ll +++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-5.ll @@ -44,5 +44,5 @@ ret i32 %res } -declare noalias align 16 i8* @malloc(i64) +declare noalias align 16 i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) declare void @f1() diff --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-opaque-ptr.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-opaque-ptr.ll --- a/llvm/test/Transforms/GlobalOpt/malloc-promote-opaque-ptr.ll +++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-opaque-ptr.ll @@ -5,7 +5,7 @@ @g2 = internal global ptr null @g3 = internal global ptr null -declare noalias i8* @malloc(i64) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) ;. ; CHECK: @[[G1_BODY_0:[a-zA-Z0-9_$"\\.-]+]] = internal unnamed_addr global i64 undef diff --git a/llvm/test/Transforms/GlobalOpt/null-check-is-use-pr35760.ll b/llvm/test/Transforms/GlobalOpt/null-check-is-use-pr35760.ll --- a/llvm/test/Transforms/GlobalOpt/null-check-is-use-pr35760.ll +++ b/llvm/test/Transforms/GlobalOpt/null-check-is-use-pr35760.ll @@ -42,6 +42,6 @@ ret void } -declare dso_local noalias i8* @malloc(i64) +declare dso_local noalias i8* @malloc(i64) inaccessiblememonly allockind("alloc,uninitialized") allocsize(0) declare dso_local i32 @puts(i8* nocapture readonly) diff --git a/llvm/test/Transforms/InstCombine/alloc-realloc-free.ll b/llvm/test/Transforms/InstCombine/alloc-realloc-free.ll --- a/llvm/test/Transforms/InstCombine/alloc-realloc-free.ll +++ b/llvm/test/Transforms/InstCombine/alloc-realloc-free.ll @@ -17,8 +17,8 @@ declare void @llvm.dbg.value(metadata, metadata, metadata) #3 attributes #0 = { mustprogress nounwind uwtable willreturn } -attributes #1 = { inaccessiblememonly mustprogress nofree nounwind willreturn } -attributes #2 = { inaccessiblemem_or_argmemonly mustprogress nounwind willreturn } -attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } +attributes #1 = { inaccessiblememonly mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") "alloc-family"="malloc" } +attributes #2 = { inaccessiblemem_or_argmemonly mustprogress nounwind willreturn allockind("realloc") "alloc-family"="malloc" } +attributes #3 = { nofree nosync nounwind readnone speculatable willreturn allockind("free") "alloc-family"="malloc" } attributes #4 = { nounwind } diff --git a/llvm/test/Transforms/InstCombine/badmalloc.ll b/llvm/test/Transforms/InstCombine/badmalloc.ll --- a/llvm/test/Transforms/InstCombine/badmalloc.ll +++ b/llvm/test/Transforms/InstCombine/badmalloc.ll @@ -3,8 +3,8 @@ 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" target triple = "x86_64-apple-darwin10.0" -declare noalias i8* @malloc(i64) nounwind -declare void @free(i8*) +declare noalias i8* @malloc(i64) nounwind allockind("alloc,uninitialized") "alloc-family"="malloc" +declare void @free(i8*) allockind("free") "alloc-family"="malloc" ; PR5130 define i1 @test1() { diff --git a/llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll b/llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll --- a/llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll +++ b/llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll @@ -192,12 +192,12 @@ declare void @bury(i32) local_unnamed_addr #2 ; Function Attrs: nounwind allocsize(0) -declare i8* @malloc(i64) +declare i8* @malloc(i64) nounwind allocsize(0) allockind("alloc,uninitialized") "alloc-family"="malloc" declare i8* @get_unknown_buffer() ; Function Attrs: nounwind -declare void @free(i8* nocapture) +declare void @free(i8* nocapture) nounwind allockind("free") "alloc-family"="malloc" ; Function Attrs: nounwind readnone speculatable declare i64 @llvm.objectsize.i64.p0i8(i8*, i1, i1, i1) diff --git a/llvm/test/Transforms/InstCombine/compare-unescaped.ll b/llvm/test/Transforms/InstCombine/compare-unescaped.ll --- a/llvm/test/Transforms/InstCombine/compare-unescaped.ll +++ b/llvm/test/Transforms/InstCombine/compare-unescaped.ll @@ -3,7 +3,7 @@ @gp = global i32* null, align 8 -declare noalias i8* @malloc(i64) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) define i1 @compare_global_trivialeq() { ; CHECK-LABEL: @compare_global_trivialeq( diff --git a/llvm/test/Transforms/InstCombine/deref-alloc-fns.ll b/llvm/test/Transforms/InstCombine/deref-alloc-fns.ll --- a/llvm/test/Transforms/InstCombine/deref-alloc-fns.ll +++ b/llvm/test/Transforms/InstCombine/deref-alloc-fns.ll @@ -3,13 +3,13 @@ ; RUN: opt -mtriple=x86_64-unknown-linux-gnu < %s -passes=instcombine -S | FileCheck %s --check-prefixes=CHECK,GNU -declare noalias i8* @malloc(i64) -declare noalias i8* @calloc(i64, i64) -declare noalias i8* @realloc(i8* nocapture, i64) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc" +declare noalias i8* @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1) "alloc-family"="malloc" +declare noalias i8* @realloc(i8* nocapture, i64) allockind("realloc") allocsize(1) "alloc-family"="malloc" declare noalias nonnull i8* @_Znam(i64) ; throwing version of 'new' declare noalias nonnull i8* @_Znwm(i64) ; throwing version of 'new' declare noalias i8* @strdup(i8*) -declare noalias i8* @aligned_alloc(i64, i64) +declare noalias i8* @aligned_alloc(i64 allocalign, i64) allockind("alloc,uninitialized,aligned") allocsize(1) "alloc-family"="malloc" declare noalias align 16 i8* @memalign(i64, i64) ; new[](unsigned int, align_val_t) declare noalias i8* @_ZnajSt11align_val_t(i64 %size, i64 %align) diff --git a/llvm/test/Transforms/InstCombine/getelementptr.ll b/llvm/test/Transforms/InstCombine/getelementptr.ll --- a/llvm/test/Transforms/InstCombine/getelementptr.ll +++ b/llvm/test/Transforms/InstCombine/getelementptr.ll @@ -552,7 +552,7 @@ ; CHECK-NEXT: [[T349:%.*]] = getelementptr [[STRUCT_SIGINFO_T:%.*]], %struct.siginfo_t* [[T344]], i64 0, i32 3, i32 0, i32 3, i32 0 ; CHECK-NEXT: [[T349350:%.*]] = bitcast i8** [[T349]] to i32* ; CHECK-NEXT: [[T351:%.*]] = load i32, i32* [[T349350]], align 8 -; CHECK-NEXT: [[T360:%.*]] = call i32 asm sideeffect "...", "=r,ir,*m,i,0,~{dirflag},~{fpsr},~{flags}"(i32 [[T351]], %struct.__large_struct* elementtype([[STRUCT___LARGE_STRUCT:%.*]]) null, i32 -14, i32 0) #[[ATTR0:[0-9]+]] +; CHECK-NEXT: [[T360:%.*]] = call i32 asm sideeffect "...", "=r,ir,*m,i,0,~{dirflag},~{fpsr},~{flags}"(i32 [[T351]], %struct.__large_struct* elementtype(%struct.__large_struct) null, i32 -14, i32 0) #[[ATTR0:[0-9]+]] ; CHECK-NEXT: unreachable ; entry: @@ -1313,7 +1313,7 @@ ret i8* %gep } -declare noalias i8* @malloc(i64) nounwind +declare noalias i8* @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) define i32 @test_gep_bitcast_malloc(%struct.A* %a) { ; CHECK-LABEL: @test_gep_bitcast_malloc( diff --git a/llvm/test/Transforms/InstCombine/malloc-free-mismatched.ll b/llvm/test/Transforms/InstCombine/malloc-free-mismatched.ll --- a/llvm/test/Transforms/InstCombine/malloc-free-mismatched.ll +++ b/llvm/test/Transforms/InstCombine/malloc-free-mismatched.ll @@ -3,7 +3,7 @@ define dso_local i32 @_Z6answeri(i32 %0) { ; CHECK-LABEL: @_Z6answeri( -; CHECK-NEXT: [[TMP2:%.*]] = call noalias nonnull dereferenceable(80) i8* @_Znam(i64 80) #[[ATTR1:[0-9]+]] +; CHECK-NEXT: [[TMP2:%.*]] = call noalias nonnull dereferenceable(80) i8* @_Znam(i64 80) #[[ATTR2:[0-9]+]] ; CHECK-NEXT: call void @free(i8* [[TMP2]]) ; CHECK-NEXT: ret i32 42 ; @@ -24,7 +24,7 @@ declare dso_local nonnull i8* @_Znam(i64) #1 ; Function Attrs: nounwind -declare dso_local void @free(i8*) +declare dso_local void @free(i8*) allockind("free") "alloc-family"="malloc" attributes #0 = { builtin allocsize(0) } -attributes #1 = { nobuiltin allocsize(0) } +attributes #1 = { nobuiltin allocsize(0) allockind("alloc,uninitialized") "alloc-family"="_Znam" } diff --git a/llvm/test/Transforms/InstCombine/malloc-free.ll b/llvm/test/Transforms/InstCombine/malloc-free.ll --- a/llvm/test/Transforms/InstCombine/malloc-free.ll +++ b/llvm/test/Transforms/InstCombine/malloc-free.ll @@ -26,10 +26,10 @@ ret i32 0 } -declare noalias i8* @calloc(i32, i32) nounwind -declare noalias i8* @malloc(i32) -declare noalias i8* @aligned_alloc(i32, i32) -declare void @free(i8*) +declare noalias i8* @calloc(i32, i32) nounwind allockind("alloc,zeroed") allocsize(0,1) "alloc-family"="malloc" +declare noalias i8* @malloc(i32) allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc" +declare noalias i8* @aligned_alloc(i32, i32) allockind("alloc,uninitialized,aligned") allocsize(1) "alloc-family"="malloc" +declare void @free(i8*) allockind("free") "alloc-family"="malloc" define i1 @foo() { ; CHECK-LABEL: @foo( diff --git a/llvm/test/Transforms/InstCombine/malloc_free_delete_nvptx.ll b/llvm/test/Transforms/InstCombine/malloc_free_delete_nvptx.ll --- a/llvm/test/Transforms/InstCombine/malloc_free_delete_nvptx.ll +++ b/llvm/test/Transforms/InstCombine/malloc_free_delete_nvptx.ll @@ -4,8 +4,8 @@ target triple = "nvptx64" declare void @user(i8*) -declare i8* @malloc(i64) -declare void @free(i8*) +declare i8* @malloc(i64) allockind("alloc,uninitialized") "alloc-family"="malloc" allocsize(0) +declare void @free(i8*) allockind("free") "alloc-family"="malloc" ; Ensure the nvptx backend states malloc & free are a thing so we can recognize ; so we will optimize them properly. In the test below the malloc-free chain is diff --git a/llvm/test/Transforms/InstCombine/objsize-64.ll b/llvm/test/Transforms/InstCombine/objsize-64.ll --- a/llvm/test/Transforms/InstCombine/objsize-64.ll +++ b/llvm/test/Transforms/InstCombine/objsize-64.ll @@ -2,7 +2,7 @@ ; RUN: opt < %s -passes=instcombine -S | FileCheck %s 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" -declare noalias i8* @malloc(i64) nounwind +declare noalias i8* @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) declare noalias nonnull i8* @_Znwm(i64) ; new(unsigned long) declare i32 @__gxx_personality_v0(...) declare void @__cxa_call_unexpected(i8*) diff --git a/llvm/test/Transforms/InstCombine/objsize.ll b/llvm/test/Transforms/InstCombine/objsize.ll --- a/llvm/test/Transforms/InstCombine/objsize.ll +++ b/llvm/test/Transforms/InstCombine/objsize.ll @@ -192,7 +192,7 @@ declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind -declare noalias i8* @malloc(i32) nounwind +declare noalias i8* @malloc(i32) nounwind allockind("alloc,uninitialized") allocsize(0) define i32 @test7(i8** %esc) { ; CHECK-LABEL: @test7( @@ -207,7 +207,7 @@ ret i32 %objsize } -declare noalias i8* @calloc(i32, i32) nounwind +declare noalias i8* @calloc(i32, i32) nounwind allockind("alloc,zeroed") allocsize(0,1) define i32 @test8(i8** %esc) { ; CHECK-LABEL: @test8( diff --git a/llvm/test/Transforms/InstCombine/realloc-free.ll b/llvm/test/Transforms/InstCombine/realloc-free.ll --- a/llvm/test/Transforms/InstCombine/realloc-free.ll +++ b/llvm/test/Transforms/InstCombine/realloc-free.ll @@ -6,14 +6,15 @@ ; CHECK-NEXT: tail call void @free(i8* [[TMP0:%.*]]) ; CHECK-NEXT: ret void ; - %2 = tail call align 16 dereferenceable_or_null(6) i8* @realloc(i8* %0, i64 6) #2 - tail call void @free(i8* %2) #2 + %2 = tail call align 16 dereferenceable_or_null(6) i8* @realloc(i8* %0, i64 6) #3 + tail call void @free(i8* %2) #3 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 #1 +declare dso_local void @free(i8* nocapture noundef) local_unnamed_addr #2 attributes #0 = { mustprogress nounwind uwtable willreturn } -attributes #1 = { inaccessiblemem_or_argmemonly mustprogress nounwind willreturn } -attributes #2 = { nounwind } +attributes #1 = { inaccessiblemem_or_argmemonly mustprogress nounwind willreturn allockind("realloc") } +attributes #2 = { inaccessiblemem_or_argmemonly mustprogress nounwind willreturn allockind("free") } +attributes #3 = { nounwind } diff --git a/llvm/test/Transforms/InstCombine/realloc.ll b/llvm/test/Transforms/InstCombine/realloc.ll --- a/llvm/test/Transforms/InstCombine/realloc.ll +++ b/llvm/test/Transforms/InstCombine/realloc.ll @@ -1,8 +1,8 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -passes=instcombine -S | FileCheck %s -declare i8* @realloc(i8*, i64) #1 -declare noalias i8* @malloc(i64) #1 +declare i8* @realloc(i8* allocptr, i64) allockind("realloc") allocsize(1) +declare noalias i8* @malloc(i64) allockind("alloc,uninitialized") define i8* @realloc_null_ptr() #0 { diff --git a/llvm/test/Transforms/LowerConstantIntrinsics/builtin-object-size-phi.ll b/llvm/test/Transforms/LowerConstantIntrinsics/builtin-object-size-phi.ll --- a/llvm/test/Transforms/LowerConstantIntrinsics/builtin-object-size-phi.ll +++ b/llvm/test/Transforms/LowerConstantIntrinsics/builtin-object-size-phi.ll @@ -5,7 +5,7 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" -declare dso_local noalias noundef i8* @malloc(i64 noundef) local_unnamed_addr +declare dso_local noalias noundef i8* @malloc(i64 noundef) local_unnamed_addr allocsize(0) declare i64 @llvm.objectsize.i64.p0i8(i8*, i1 immarg, i1 immarg, i1 immarg) @buffer = dso_local global [4 x i8] zeroinitializer, align 1 diff --git a/llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll b/llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll --- a/llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll +++ b/llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll @@ -139,7 +139,7 @@ ret i64 %objsize } -declare i8* @malloc(i64) +declare i8* @malloc(i64) allocsize(0) define i64 @test_objectsize_malloc() { ; CHECK-LABEL: @test_objectsize_malloc( diff --git a/llvm/test/Transforms/MemCpyOpt/memcpy.ll b/llvm/test/Transforms/MemCpyOpt/memcpy.ll --- a/llvm/test/Transforms/MemCpyOpt/memcpy.ll +++ b/llvm/test/Transforms/MemCpyOpt/memcpy.ll @@ -328,7 +328,7 @@ ret void } -declare noalias i8* @malloc(i32) willreturn +declare noalias i8* @malloc(i32) willreturn allockind("alloc,uninitialized") allocsize(0) ; rdar://11341081 %struct.big = type { [50 x i32] }