1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -max-heap-to-stack-size=-1 -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -max-heap-to-stack-size=-1 -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
5 declare i64 @subfn(ptr) #0
7 declare noalias ptr @malloc(i64) allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc"
8 declare noalias ptr @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1) "alloc-family"="malloc"
9 declare void @free(ptr) allockind("free") "alloc-family"="malloc"
11 define i64 @f(i64 %len) {
12 ; CHECK-LABEL: define {{[^@]+}}@f
13 ; CHECK-SAME: (i64 [[LEN:%.*]]) {
15 ; CHECK-NEXT: [[MEM_H2S:%.*]] = alloca i8, i64 [[LEN]], align 1
16 ; CHECK-NEXT: [[RES:%.*]] = call i64 @subfn(ptr [[MEM_H2S]]) #[[ATTR5:[0-9]+]]
17 ; CHECK-NEXT: ret i64 [[RES]]
20 %mem = call ptr @malloc(i64 %len)
21 %res = call i64 @subfn(ptr %mem)
22 call void @free(ptr %mem)
27 define i64 @g(i64 %len) {
28 ; CHECK-LABEL: define {{[^@]+}}@g
29 ; CHECK-SAME: (i64 [[LEN:%.*]]) {
31 ; CHECK-NEXT: [[TMP0:%.*]] = mul i64 [[LEN]], 8
32 ; CHECK-NEXT: [[MEM_H2S:%.*]] = alloca i8, i64 [[TMP0]], align 1
33 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr [[MEM_H2S]], i8 0, i64 [[TMP0]], i1 false)
34 ; CHECK-NEXT: [[RES:%.*]] = call i64 @subfn(ptr [[MEM_H2S]]) #[[ATTR5]]
35 ; CHECK-NEXT: ret i64 [[RES]]
38 %mem = call ptr @calloc(i64 %len, i64 8)
39 %res = call i64 @subfn(ptr %mem)
40 call void @free(ptr %mem)
44 attributes #0 = { nounwind willreturn }
46 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn }
47 ; CHECK: attributes #[[ATTR1:[0-9]+]] = { allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc" }
48 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { allockind("alloc,zeroed") allocsize(0,1) "alloc-family"="malloc" }
49 ; CHECK: attributes #[[ATTR3:[0-9]+]] = { allockind("free") "alloc-family"="malloc" }
50 ; CHECK: attributes #[[ATTR4:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }
51 ; CHECK: attributes #[[ATTR5]] = { nounwind }
53 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: