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 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-pc-windows-msvc"
8 define internal void @add(ptr %this, ptr sret(i32) %r) {
10 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
11 ; TUNIT-LABEL: define {{[^@]+}}@add
12 ; TUNIT-SAME: (ptr noalias nocapture nofree nonnull readnone align 8 dereferenceable(8) [[THIS:%.*]], ptr noalias nocapture nofree noundef nonnull writeonly sret(i32) align 4 dereferenceable(4) [[R:%.*]]) #[[ATTR0:[0-9]+]] {
13 ; TUNIT-NEXT: store i32 undef, ptr [[R]], align 4
14 ; TUNIT-NEXT: ret void
16 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
17 ; CGSCC-LABEL: define {{[^@]+}}@add
18 ; CGSCC-SAME: (ptr noalias nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) [[THIS:%.*]], ptr noalias nocapture nofree noundef nonnull writeonly sret(i32) align 4 dereferenceable(4) [[R:%.*]]) #[[ATTR0:[0-9]+]] {
19 ; CGSCC-NEXT: [[BP:%.*]] = getelementptr { i32, i32 }, ptr [[THIS]], i32 0, i32 1
20 ; CGSCC-NEXT: [[A:%.*]] = load i32, ptr [[THIS]], align 8
21 ; CGSCC-NEXT: [[B:%.*]] = load i32, ptr [[BP]], align 4
22 ; CGSCC-NEXT: [[AB:%.*]] = add i32 [[A]], [[B]]
23 ; CGSCC-NEXT: store i32 [[AB]], ptr [[R]], align 4
24 ; CGSCC-NEXT: ret void
26 %ap = getelementptr {i32, i32}, ptr %this, i32 0, i32 0
27 %bp = getelementptr {i32, i32}, ptr %this, i32 0, i32 1
28 %a = load i32, ptr %ap
29 %b = load i32, ptr %bp
36 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
37 ; TUNIT-LABEL: define {{[^@]+}}@f
38 ; TUNIT-SAME: () #[[ATTR1:[0-9]+]] {
39 ; TUNIT-NEXT: [[R:%.*]] = alloca i32, align 4
40 ; TUNIT-NEXT: call void @add(ptr noalias nocapture nofree nonnull readnone align 8 dereferenceable(8) undef, ptr noalias nocapture nofree noundef nonnull writeonly sret(i32) align 4 dereferenceable(4) [[R]]) #[[ATTR2:[0-9]+]]
41 ; TUNIT-NEXT: ret void
43 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
44 ; CGSCC-LABEL: define {{[^@]+}}@f
45 ; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
46 ; CGSCC-NEXT: [[R:%.*]] = alloca i32, align 4
47 ; CGSCC-NEXT: [[PAIR:%.*]] = alloca { i32, i32 }, align 8
48 ; CGSCC-NEXT: call void @add(ptr noalias nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) [[PAIR]], ptr noalias nocapture nofree noundef nonnull writeonly sret(i32) align 4 dereferenceable(4) [[R]]) #[[ATTR2:[0-9]+]]
49 ; CGSCC-NEXT: ret void
52 %pair = alloca {i32, i32}
54 call void @add(ptr %pair, ptr sret(i32) %r)
58 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
59 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
60 ; TUNIT: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn memory(write) }
62 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
63 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
64 ; CGSCC: attributes #[[ATTR2]] = { nofree nounwind willreturn }
66 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: