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
5 ; Mostly check we do not crash on these uses
7 define internal void @internal(ptr %fp) {
10 ; TUNIT-LABEL: define {{[^@]+}}@internal
11 ; TUNIT-SAME: (ptr nonnull [[FP:%.*]]) {
13 ; TUNIT-NEXT: [[A:%.*]] = alloca i32, align 4
14 ; TUNIT-NEXT: call void @foo(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A]]) #[[ATTR1:[0-9]+]]
15 ; TUNIT-NEXT: call void [[FP]](ptr nonnull @foo)
16 ; TUNIT-NEXT: call void @callback1(ptr noundef nonnull @foo)
17 ; TUNIT-NEXT: call void @callback2(ptr noundef nonnull @foo)
18 ; TUNIT-NEXT: call void @callback2(ptr nonnull [[FP]])
19 ; TUNIT-NEXT: call void [[FP]](ptr [[A]])
20 ; TUNIT-NEXT: ret void
22 ; CGSCC-LABEL: define {{[^@]+}}@internal
23 ; CGSCC-SAME: (ptr noundef nonnull [[FP:%.*]]) {
25 ; CGSCC-NEXT: [[A:%.*]] = alloca i32, align 4
26 ; CGSCC-NEXT: call void @foo(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A]]) #[[ATTR1:[0-9]+]]
27 ; CGSCC-NEXT: call void [[FP]](ptr nonnull @foo)
28 ; CGSCC-NEXT: call void @callback1(ptr noundef nonnull @foo)
29 ; CGSCC-NEXT: call void @callback2(ptr noundef nonnull @foo)
30 ; CGSCC-NEXT: call void @callback2(ptr noundef nonnull [[FP]])
31 ; CGSCC-NEXT: call void [[FP]](ptr [[A]])
32 ; CGSCC-NEXT: ret void
35 %a = alloca i32, align 4
36 call void @foo(ptr nonnull %a)
37 call void %fp(ptr @foo)
38 call void @callback1(ptr nonnull @foo)
39 call void @callback2(ptr @foo)
40 call void @callback2(ptr %fp)
45 define void @external(ptr %fp) {
48 ; TUNIT-LABEL: define {{[^@]+}}@external
49 ; TUNIT-SAME: (ptr [[FP:%.*]]) {
51 ; TUNIT-NEXT: [[A:%.*]] = alloca i32, align 4
52 ; TUNIT-NEXT: call void @foo(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A]]) #[[ATTR1]]
53 ; TUNIT-NEXT: call void @callback1(ptr noundef nonnull @foo)
54 ; TUNIT-NEXT: call void @callback2(ptr noundef nonnull @foo)
55 ; TUNIT-NEXT: call void @callback2(ptr [[FP]])
56 ; TUNIT-NEXT: call void [[FP]](ptr @foo)
57 ; TUNIT-NEXT: call void [[FP]](ptr [[A]])
58 ; TUNIT-NEXT: call void @internal(ptr nonnull [[FP]])
59 ; TUNIT-NEXT: ret void
61 ; CGSCC-LABEL: define {{[^@]+}}@external
62 ; CGSCC-SAME: (ptr [[FP:%.*]]) {
64 ; CGSCC-NEXT: [[A:%.*]] = alloca i32, align 4
65 ; CGSCC-NEXT: call void @foo(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A]]) #[[ATTR1]]
66 ; CGSCC-NEXT: call void @callback1(ptr noundef nonnull @foo)
67 ; CGSCC-NEXT: call void @callback2(ptr noundef nonnull @foo)
68 ; CGSCC-NEXT: call void @callback2(ptr [[FP]])
69 ; CGSCC-NEXT: call void [[FP]](ptr @foo)
70 ; CGSCC-NEXT: call void [[FP]](ptr [[A]])
71 ; CGSCC-NEXT: call void @internal(ptr noundef nonnull [[FP]])
72 ; CGSCC-NEXT: ret void
75 %a = alloca i32, align 4
76 call void @foo(ptr nonnull %a)
77 call void @callback1(ptr nonnull @foo)
78 call void @callback2(ptr @foo)
79 call void @callback2(ptr %fp)
80 call void %fp(ptr @foo)
82 call void @internal(ptr %fp)
86 define internal void @foo(ptr %a) {
88 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
89 ; CHECK-LABEL: define {{[^@]+}}@foo
90 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR0:[0-9]+]] {
92 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4
93 ; CHECK-NEXT: ret void
100 declare void @callback1(ptr)
101 declare void @callback2(ptr)
103 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
104 ; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind willreturn memory(write) }
106 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
107 ; CGSCC: attributes #[[ATTR1]] = { nofree nounwind willreturn memory(write) }