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 ; Don't constant-propagate byval pointers, since they are not pointers!
7 %struct.MYstr = type { i8, i32 }
8 @mystr = internal global %struct.MYstr zeroinitializer ; <ptr> [#uses=3]
12 ; CHECK: @mystr = internal global %struct.MYstr zeroinitializer
14 define internal void @vfu1(ptr byval(%struct.MYstr) align 4 %u) nounwind {
15 ; CHECK: Function Attrs: nounwind memory(readwrite, argmem: none)
16 ; CHECK-LABEL: define {{[^@]+}}@vfu1
17 ; CHECK-SAME: (i8 [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR0:[0-9]+]] {
19 ; CHECK-NEXT: [[U_PRIV:%.*]] = alloca [[STRUCT_MYSTR:%.*]], align 8
20 ; CHECK-NEXT: store i8 [[TMP0]], ptr [[U_PRIV]], align 1
21 ; CHECK-NEXT: [[U_PRIV_B4:%.*]] = getelementptr i8, ptr [[U_PRIV]], i64 4
22 ; CHECK-NEXT: store i32 [[TMP1]], ptr [[U_PRIV_B4]], align 4
23 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr [[STRUCT_MYSTR]], ptr [[U_PRIV]], i32 0, i32 1
24 ; CHECK-NEXT: store i32 99, ptr [[TMP2]], align 4
25 ; CHECK-NEXT: store i8 97, ptr [[U_PRIV]], align 8
26 ; CHECK-NEXT: [[L:%.*]] = load i8, ptr [[U_PRIV]], align 8
27 ; CHECK-NEXT: call void @use(i8 [[L]])
28 ; CHECK-NEXT: br label [[RETURN:%.*]]
30 ; CHECK-NEXT: ret void
33 %0 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 1 ; <ptr> [#uses=1]
34 store i32 99, ptr %0, align 4
35 %1 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 0 ; <ptr> [#uses=1]
36 store i8 97, ptr %1, align 4
41 return: ; preds = %entry
45 define internal i32 @vfu2(ptr byval(%struct.MYstr) align 4 %u) nounwind readonly {
46 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
47 ; CHECK-LABEL: define {{[^@]+}}@vfu2
48 ; CHECK-SAME: (i8 [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR1:[0-9]+]] {
50 ; CHECK-NEXT: [[U_PRIV:%.*]] = alloca [[STRUCT_MYSTR:%.*]], align 8
51 ; CHECK-NEXT: store i8 [[TMP0]], ptr [[U_PRIV]], align 1
52 ; CHECK-NEXT: [[U_PRIV_B4:%.*]] = getelementptr i8, ptr [[U_PRIV]], i64 4
53 ; CHECK-NEXT: store i32 [[TMP1]], ptr [[U_PRIV_B4]], align 4
54 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr [[STRUCT_MYSTR]], ptr [[U_PRIV]], i32 0, i32 1
55 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
56 ; CHECK-NEXT: [[TMP4:%.*]] = load i8, ptr [[U_PRIV]], align 8
57 ; CHECK-NEXT: [[TMP5:%.*]] = zext i8 [[TMP4]] to i32
58 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP5]], [[TMP3]]
59 ; CHECK-NEXT: ret i32 [[TMP6]]
62 %0 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 1 ; <ptr> [#uses=1]
64 %2 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 0 ; <ptr> [#uses=1]
66 %4 = zext i8 %3 to i32
71 define i32 @unions() nounwind {
72 ; TUNIT: Function Attrs: nounwind
73 ; TUNIT-LABEL: define {{[^@]+}}@unions
74 ; TUNIT-SAME: () #[[ATTR2:[0-9]+]] {
76 ; TUNIT-NEXT: [[TMP0:%.*]] = load i8, ptr @mystr, align 8
77 ; TUNIT-NEXT: [[MYSTR_B41:%.*]] = getelementptr i8, ptr @mystr, i64 4
78 ; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr [[MYSTR_B41]], align 8
79 ; TUNIT-NEXT: call void @vfu1(i8 [[TMP0]], i32 [[TMP1]]) #[[ATTR2]]
80 ; TUNIT-NEXT: [[TMP2:%.*]] = load i8, ptr @mystr, align 8
81 ; TUNIT-NEXT: [[MYSTR_B4:%.*]] = getelementptr i8, ptr @mystr, i64 4
82 ; TUNIT-NEXT: [[TMP3:%.*]] = load i32, ptr [[MYSTR_B4]], align 8
83 ; TUNIT-NEXT: [[RESULT:%.*]] = call i32 @vfu2(i8 [[TMP2]], i32 [[TMP3]]) #[[ATTR3:[0-9]+]]
84 ; TUNIT-NEXT: ret i32 [[RESULT]]
86 ; CGSCC: Function Attrs: nounwind
87 ; CGSCC-LABEL: define {{[^@]+}}@unions
88 ; CGSCC-SAME: () #[[ATTR2:[0-9]+]] {
90 ; CGSCC-NEXT: [[TMP0:%.*]] = load i8, ptr @mystr, align 8
91 ; CGSCC-NEXT: [[MYSTR_B4:%.*]] = getelementptr i8, ptr @mystr, i64 4
92 ; CGSCC-NEXT: [[TMP1:%.*]] = load i32, ptr [[MYSTR_B4]], align 8
93 ; CGSCC-NEXT: call void @vfu1(i8 [[TMP0]], i32 [[TMP1]]) #[[ATTR2]]
94 ; CGSCC-NEXT: [[TMP2:%.*]] = load i8, ptr @mystr, align 8
95 ; CGSCC-NEXT: [[MYSTR_B41:%.*]] = getelementptr i8, ptr @mystr, i64 4
96 ; CGSCC-NEXT: [[TMP3:%.*]] = load i32, ptr [[MYSTR_B41]], align 8
97 ; CGSCC-NEXT: [[RESULT:%.*]] = call i32 @vfu2(i8 [[TMP2]], i32 [[TMP3]]) #[[ATTR2]]
98 ; CGSCC-NEXT: ret i32 [[RESULT]]
101 call void @vfu1(ptr byval(%struct.MYstr) align 4 @mystr) nounwind
102 %result = call i32 @vfu2(ptr byval(%struct.MYstr) align 4 @mystr) nounwind
106 define internal i32 @vfu2_v2(ptr byval(%struct.MYstr) align 4 %u) nounwind readonly {
107 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
108 ; CHECK-LABEL: define {{[^@]+}}@vfu2_v2
109 ; CHECK-SAME: (i8 [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR1]] {
111 ; CHECK-NEXT: [[U_PRIV:%.*]] = alloca [[STRUCT_MYSTR:%.*]], align 8
112 ; CHECK-NEXT: store i8 [[TMP0]], ptr [[U_PRIV]], align 1
113 ; CHECK-NEXT: [[U_PRIV_B4:%.*]] = getelementptr i8, ptr [[U_PRIV]], i64 4
114 ; CHECK-NEXT: store i32 [[TMP1]], ptr [[U_PRIV_B4]], align 4
115 ; CHECK-NEXT: [[Z:%.*]] = getelementptr [[STRUCT_MYSTR]], ptr [[U_PRIV]], i32 0, i32 1
116 ; CHECK-NEXT: store i32 99, ptr [[Z]], align 4
117 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr [[STRUCT_MYSTR]], ptr [[U_PRIV]], i32 0, i32 1
118 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
119 ; CHECK-NEXT: [[TMP4:%.*]] = load i8, ptr [[U_PRIV]], align 8
120 ; CHECK-NEXT: [[TMP5:%.*]] = zext i8 [[TMP4]] to i32
121 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP5]], [[TMP3]]
122 ; CHECK-NEXT: ret i32 [[TMP6]]
125 %z = getelementptr %struct.MYstr, ptr %u, i32 0, i32 1
126 store i32 99, ptr %z, align 4
127 %0 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 1 ; <ptr> [#uses=1]
128 %1 = load i32, ptr %0
129 %2 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 0 ; <ptr> [#uses=1]
131 %4 = zext i8 %3 to i32
136 define i32 @unions_v2() nounwind {
137 ; TUNIT: Function Attrs: nounwind
138 ; TUNIT-LABEL: define {{[^@]+}}@unions_v2
139 ; TUNIT-SAME: () #[[ATTR2]] {
141 ; TUNIT-NEXT: [[TMP0:%.*]] = load i8, ptr @mystr, align 8
142 ; TUNIT-NEXT: [[MYSTR_B41:%.*]] = getelementptr i8, ptr @mystr, i64 4
143 ; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr [[MYSTR_B41]], align 8
144 ; TUNIT-NEXT: call void @vfu1(i8 [[TMP0]], i32 [[TMP1]]) #[[ATTR2]]
145 ; TUNIT-NEXT: [[TMP2:%.*]] = load i8, ptr @mystr, align 8
146 ; TUNIT-NEXT: [[MYSTR_B4:%.*]] = getelementptr i8, ptr @mystr, i64 4
147 ; TUNIT-NEXT: [[TMP3:%.*]] = load i32, ptr [[MYSTR_B4]], align 8
148 ; TUNIT-NEXT: [[RESULT:%.*]] = call i32 @vfu2_v2(i8 [[TMP2]], i32 [[TMP3]]) #[[ATTR3]]
149 ; TUNIT-NEXT: ret i32 [[RESULT]]
151 ; CGSCC: Function Attrs: nounwind
152 ; CGSCC-LABEL: define {{[^@]+}}@unions_v2
153 ; CGSCC-SAME: () #[[ATTR2]] {
155 ; CGSCC-NEXT: call void @vfu1(i8 noundef 0, i32 noundef 0) #[[ATTR2]]
156 ; CGSCC-NEXT: [[RESULT:%.*]] = call i32 @vfu2_v2(i8 noundef 0, i32 noundef 0) #[[ATTR2]]
157 ; CGSCC-NEXT: ret i32 [[RESULT]]
160 call void @vfu1(ptr byval(%struct.MYstr) align 4 @mystr) nounwind
161 %result = call i32 @vfu2_v2(ptr byval(%struct.MYstr) align 4 @mystr) nounwind
165 ; TUNIT: attributes #[[ATTR0]] = { nounwind memory(readwrite, argmem: none) }
166 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
167 ; TUNIT: attributes #[[ATTR2]] = { nounwind }
168 ; TUNIT: attributes #[[ATTR3]] = { nounwind memory(read) }
170 ; CGSCC: attributes #[[ATTR0]] = { nounwind memory(readwrite, argmem: none) }
171 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
172 ; CGSCC: attributes #[[ATTR2]] = { nounwind }