1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
9 ; static ptr foo(ptr arg) { return arg; }
10 ; static ptr bar(ptr arg) { return arg; }
14 ; pthread_create(&thread, NULL, foo, NULL);
15 ; pthread_create(&thread, NULL, bar, &GlobalVPtr);
19 ; Verify the constant values NULL and &GlobalVPtr are propagated into foo and
22 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
24 %union.pthread_attr_t = type { i64, [48 x i8] }
26 @GlobalVPtr = common dso_local global ptr null, align 8
28 ; FIXME: nocapture & noalias for @GlobalVPtr in %call1
29 ; FIXME: nocapture & noalias for %alloc2 in %call3
32 ; CHECK: @GlobalVPtr = common dso_local global ptr null, align 8
34 define dso_local i32 @main() {
35 ; TUNIT-LABEL: define {{[^@]+}}@main() {
37 ; TUNIT-NEXT: [[ALLOC1:%.*]] = alloca i8, align 8
38 ; TUNIT-NEXT: [[ALLOC2:%.*]] = alloca i8, align 8
39 ; TUNIT-NEXT: [[THREAD:%.*]] = alloca i64, align 8
40 ; TUNIT-NEXT: [[CALL:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef align 4294967296 null, ptr noundef nonnull @foo, ptr nofree readnone align 4294967296 undef)
41 ; TUNIT-NEXT: [[CALL1:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef align 4294967296 null, ptr noundef nonnull @bar, ptr noalias nocapture nofree nonnull readnone align 8 dereferenceable(8) undef)
42 ; TUNIT-NEXT: [[CALL2:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef align 4294967296 null, ptr noundef nonnull @baz, ptr noalias nocapture nofree noundef nonnull readnone align 8 dereferenceable(1) [[ALLOC1]])
43 ; TUNIT-NEXT: [[CALL3:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef align 4294967296 null, ptr noundef nonnull @buz, ptr noalias nofree noundef nonnull readnone align 8 dereferenceable(1) "no-capture-maybe-returned" [[ALLOC2]])
44 ; TUNIT-NEXT: ret i32 0
46 ; CGSCC-LABEL: define {{[^@]+}}@main() {
48 ; CGSCC-NEXT: [[ALLOC1:%.*]] = alloca i8, align 8
49 ; CGSCC-NEXT: [[ALLOC2:%.*]] = alloca i8, align 8
50 ; CGSCC-NEXT: [[THREAD:%.*]] = alloca i64, align 8
51 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef align 4294967296 null, ptr noundef nonnull @foo, ptr nofree noundef readnone align 4294967296 null)
52 ; CGSCC-NEXT: [[CALL1:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef align 4294967296 null, ptr noundef nonnull @bar, ptr noalias nocapture nofree noundef nonnull readnone align 8 dereferenceable(8) @GlobalVPtr)
53 ; CGSCC-NEXT: [[CALL2:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef align 4294967296 null, ptr noundef nonnull @baz, ptr noalias nocapture nofree noundef nonnull readnone align 8 dereferenceable(1) [[ALLOC1]])
54 ; CGSCC-NEXT: [[CALL3:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef align 4294967296 null, ptr noundef nonnull @buz, ptr noalias nofree noundef nonnull readnone align 8 dereferenceable(1) [[ALLOC2]])
55 ; CGSCC-NEXT: ret i32 0
58 %alloc1 = alloca i8, align 8
59 %alloc2 = alloca i8, align 8
60 %thread = alloca i64, align 8
61 %call = call i32 @pthread_create(ptr nonnull %thread, ptr null, ptr nonnull @foo, ptr null)
62 %call1 = call i32 @pthread_create(ptr nonnull %thread, ptr null, ptr nonnull @bar, ptr @GlobalVPtr)
63 %call2 = call i32 @pthread_create(ptr nonnull %thread, ptr null, ptr nonnull @baz, ptr nocapture %alloc1)
64 %call3 = call i32 @pthread_create(ptr nonnull %thread, ptr null, ptr nonnull @buz, ptr %alloc2)
68 declare !callback !0 dso_local i32 @pthread_create(ptr, ptr, ptr, ptr)
70 define internal ptr @foo(ptr %arg) {
71 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
72 ; CHECK-LABEL: define {{[^@]+}}@foo
73 ; CHECK-SAME: (ptr noalias nocapture nofree readnone align 4294967296 [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
75 ; CHECK-NEXT: ret ptr null
81 define internal ptr @bar(ptr %arg) {
82 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
83 ; CHECK-LABEL: define {{[^@]+}}@bar
84 ; CHECK-SAME: (ptr noalias nocapture nofree nonnull readnone align 8 dereferenceable(8) [[ARG:%.*]]) #[[ATTR0]] {
86 ; CHECK-NEXT: ret ptr @GlobalVPtr
92 define internal ptr @baz(ptr %arg) {
93 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
94 ; CHECK-LABEL: define {{[^@]+}}@baz
95 ; CHECK-SAME: (ptr noalias nofree noundef nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[ARG:%.*]]) #[[ATTR0]] {
97 ; CHECK-NEXT: ret ptr [[ARG]]
103 define internal ptr @buz(ptr %arg) {
104 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
105 ; CHECK-LABEL: define {{[^@]+}}@buz
106 ; CHECK-SAME: (ptr noalias nofree noundef nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[ARG:%.*]]) #[[ATTR0]] {
108 ; CHECK-NEXT: ret ptr [[ARG]]
114 !1 = !{i64 2, i64 3, i1 false}
117 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
119 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
121 ; TUNIT: [[META0:![0-9]+]] = !{[[META1:![0-9]+]]}
122 ; TUNIT: [[META1]] = !{i64 2, i64 3, i1 false}
124 ; CGSCC: [[META0:![0-9]+]] = !{[[META1:![0-9]+]]}
125 ; CGSCC: [[META1]] = !{i64 2, i64 3, i1 false}