1 // RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -I%S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,LIN64,NoNewStructPathTBAA 2 // RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -I%S -new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,LIN64,NewStructPathTBAA 3 4 // RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -I%S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,WIN64,NoNewStructPathTBAA 5 // RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -I%S -new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,WIN64,NewStructPathTBAA 6 7 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -I%S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,LIN32,NoNewStructPathTBAA 8 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -I%S -new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,LIN32,NewStructPathTBAA 9 10 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -I%S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,WIN32,NoNewStructPathTBAA 11 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -I%S -new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,WIN32,NewStructPathTBAA 12 13 namespace std { 14 class type_info { public: virtual ~type_info(); private: const char * name; }; 15 } // namespace std 16 17 // Ensure that the layout for these structs is the same as the normal bitfield 18 // layouts. 19 struct BitFieldsByte { 20 _ExtInt(7) A : 3; 21 _ExtInt(7) B : 3; 22 _ExtInt(7) C : 2; 23 }; 24 // CHECK: %struct.BitFieldsByte = type { i8 } 25 26 struct BitFieldsShort { 27 _ExtInt(15) A : 3; 28 _ExtInt(15) B : 3; 29 _ExtInt(15) C : 2; 30 }; 31 // LIN: %struct.BitFieldsShort = type { i8, i8 } 32 // WIN: %struct.BitFieldsShort = type { i16 } 33 34 struct BitFieldsInt { 35 _ExtInt(31) A : 3; 36 _ExtInt(31) B : 3; 37 _ExtInt(31) C : 2; 38 }; 39 // LIN: %struct.BitFieldsInt = type { i8, [3 x i8] } 40 // WIN: %struct.BitFieldsInt = type { i32 } 41 42 struct BitFieldsLong { 43 _ExtInt(63) A : 3; 44 _ExtInt(63) B : 3; 45 _ExtInt(63) C : 2; 46 }; 47 // LIN64: %struct.BitFieldsLong = type { i8, [7 x i8] } 48 // LIN32: %struct.BitFieldsLong = type { i8, [3 x i8] } 49 // WIN: %struct.BitFieldsLong = type { i64 } 50 51 struct HasExtIntFirst { 52 _ExtInt(35) A; 53 int B; 54 }; 55 // CHECK: %struct.HasExtIntFirst = type { i35, i32 } 56 57 struct HasExtIntLast { 58 int A; 59 _ExtInt(35) B; 60 }; 61 // CHECK: %struct.HasExtIntLast = type { i32, i35 } 62 63 struct HasExtIntMiddle { 64 int A; 65 _ExtInt(35) B; 66 int C; 67 }; 68 // CHECK: %struct.HasExtIntMiddle = type { i32, i35, i32 } 69 70 // Force emitting of the above structs. 71 void StructEmit() { 72 BitFieldsByte A; 73 BitFieldsShort B; 74 BitFieldsInt C; 75 BitFieldsLong D; 76 77 HasExtIntFirst E; 78 HasExtIntLast F; 79 HasExtIntMiddle G; 80 } 81 82 void BitfieldAssignment() { 83 // LIN: define{{.*}} void @_Z18BitfieldAssignmentv 84 // WIN: define dso_local void @"?BitfieldAssignment@@YAXXZ" 85 BitFieldsByte B; 86 B.A = 3; 87 B.B = 2; 88 B.C = 1; 89 // First one is used for the lifetime start, skip that. 90 // CHECK: bitcast %struct.BitFieldsByte* 91 // CHECK: %[[BFType:.+]] = bitcast %struct.BitFieldsByte* 92 // CHECK: %[[LOADA:.+]] = load i8, i8* %[[BFType]] 93 // CHECK: %[[CLEARA:.+]] = and i8 %[[LOADA]], -8 94 // CHECK: %[[SETA:.+]] = or i8 %[[CLEARA]], 3 95 // CHECK: %[[BFType:.+]] = bitcast %struct.BitFieldsByte* 96 // CHECK: %[[LOADB:.+]] = load i8, i8* %[[BFType]] 97 // CHECK: %[[CLEARB:.+]] = and i8 %[[LOADB]], -57 98 // CHECK: %[[SETB:.+]] = or i8 %[[CLEARB]], 16 99 // CHECK: %[[BFType:.+]] = bitcast %struct.BitFieldsByte* 100 // CHECK: %[[LOADC:.+]] = load i8, i8* %[[BFType]] 101 // CHECK: %[[CLEARC:.+]] = and i8 %[[LOADC]], 63 102 // CHECK: %[[SETC:.+]] = or i8 %[[CLEARC]], 64 103 } 104 105 enum AsEnumUnderlyingType : _ExtInt(9) { 106 A,B,C 107 }; 108 109 void UnderlyingTypeUsage(AsEnumUnderlyingType Param) { 110 // LIN: define{{.*}} void @_Z19UnderlyingTypeUsage20AsEnumUnderlyingType(i9 signext % 111 // WIN64: define dso_local void @"?UnderlyingTypeUsage@@YAXW4AsEnumUnderlyingType@@@Z"(i9 % 112 // WIN32: define dso_local void @"?UnderlyingTypeUsage@@YAXW4AsEnumUnderlyingType@@@Z"(i9 signext % 113 AsEnumUnderlyingType Var; 114 // CHECK: alloca i9, align 2 115 // CHECK: store i9 %{{.*}}, align 2 116 } 117 118 unsigned _ExtInt(33) ManglingTestRetParam(unsigned _ExtInt(33) Param) { 119 // LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i64 % 120 // LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i33 % 121 // WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_UExtInt@$0CB@@__clang@@U12@@Z"(i33 122 return 0; 123 } 124 125 _ExtInt(33) ManglingTestRetParam(_ExtInt(33) Param) { 126 // LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i64 % 127 // LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i33 % 128 // WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_ExtInt@$0CB@@__clang@@U12@@Z"(i33 129 return 0; 130 } 131 132 template<typename T> 133 void ManglingTestTemplateParam(T&); 134 template<_ExtInt(99) T> 135 void ManglingTestNTTP(); 136 137 void ManglingInstantiator() { 138 // LIN: define{{.*}} void @_Z20ManglingInstantiatorv() 139 // WIN: define dso_local void @"?ManglingInstantiator@@YAXXZ"() 140 _ExtInt(93) A; 141 ManglingTestTemplateParam(A); 142 // LIN: call void @_Z25ManglingTestTemplateParamIU7_ExtIntILi93EEiEvRT_(i93* 143 // WIN64: call void @"??$ManglingTestTemplateParam@U?$_ExtInt@$0FN@@__clang@@@@YAXAEAU?$_ExtInt@$0FN@@__clang@@@Z"(i93* 144 // WIN32: call void @"??$ManglingTestTemplateParam@U?$_ExtInt@$0FN@@__clang@@@@YAXAAU?$_ExtInt@$0FN@@__clang@@@Z"(i93* 145 constexpr _ExtInt(93) B = 993; 146 ManglingTestNTTP<38>(); 147 // LIN: call void @_Z16ManglingTestNTTPILU7_ExtIntILi99EEi38EEvv() 148 // WIN: call void @"??$ManglingTestNTTP@$0CG@@@YAXXZ"() 149 ManglingTestNTTP<B>(); 150 // LIN: call void @_Z16ManglingTestNTTPILU7_ExtIntILi99EEi993EEvv() 151 // WIN: call void @"??$ManglingTestNTTP@$0DOB@@@YAXXZ"() 152 } 153 154 void TakesVarargs(int i, ...) { 155 // LIN: define{{.*}} void @_Z12TakesVarargsiz(i32 %i, ...) 156 // WIN: define dso_local void @"?TakesVarargs@@YAXHZZ"(i32 %i, ...) 157 158 __builtin_va_list args; 159 // LIN64: %[[ARGS:.+]] = alloca [1 x %struct.__va_list_tag] 160 // LIN32: %[[ARGS:.+]] = alloca i8* 161 // WIN: %[[ARGS:.+]] = alloca i8* 162 __builtin_va_start(args, i); 163 // LIN64: %[[STARTAD:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] 164 // LIN64: %[[STARTAD1:.+]] = bitcast %struct.__va_list_tag* %[[STARTAD]] to i8* 165 // LIN64: call void @llvm.va_start(i8* %[[STARTAD1]]) 166 // LIN32: %[[ARGSLLIFETIMESTART:.+]] = bitcast i8** %[[ARGS]] to i8* 167 // LIN32: %[[ARGSSTART:.+]] = bitcast i8** %[[ARGS]] to i8* 168 // LIN32: call void @llvm.va_start(i8* %[[ARGSSTART]]) 169 // WIN: %[[ARGSLLIFETIMESTART:.+]] = bitcast i8** %[[ARGS]] to i8* 170 // WIN: %[[ARGSSTART:.+]] = bitcast i8** %[[ARGS]] to i8* 171 // WIN: call void @llvm.va_start(i8* %[[ARGSSTART]]) 172 173 _ExtInt(92) A = __builtin_va_arg(args, _ExtInt(92)); 174 // LIN64: %[[AD1:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] 175 // LIN64: %[[OFA_P1:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD1]], i32 0, i32 0 176 // LIN64: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P1]] 177 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 32 178 // LIN64: br i1 %[[FITSINGP]] 179 // LIN64: %[[BC1:.+]] = phi i92* 180 // LIN64: %[[LOAD1:.+]] = load i92, i92* %[[BC1]] 181 // LIN64: store i92 %[[LOAD1]], i92* 182 183 // LIN32: %[[CUR1:.+]] = load i8*, i8** %[[ARGS]] 184 // LIN32: %[[NEXT1:.+]] = getelementptr inbounds i8, i8* %[[CUR1]], i32 12 185 // LIN32: store i8* %[[NEXT1]], i8** %[[ARGS]] 186 // LIN32: %[[BC1:.+]] = bitcast i8* %[[CUR1]] to i92* 187 // LIN32: %[[LOADV1:.+]] = load i92, i92* %[[BC1]] 188 // LIN32: store i92 %[[LOADV1]], i92* 189 190 // WIN64: %[[CUR1:.+]] = load i8*, i8** %[[ARGS]] 191 // WIN64: %[[NEXT1:.+]] = getelementptr inbounds i8, i8* %[[CUR1]], i64 8 192 // WIN64: store i8* %[[NEXT1]], i8** %[[ARGS]] 193 // WIN64: %[[BC1:.+]] = bitcast i8* %[[CUR1]] to i92** 194 // WIN64: %[[LOADP1:.+]] = load i92*, i92** %[[BC1]] 195 // WIN64: %[[LOADV1:.+]] = load i92, i92* %[[LOADP1]] 196 // WIN64: store i92 %[[LOADV1]], i92* 197 198 // WIN32: %[[CUR1:.+]] = load i8*, i8** %[[ARGS]] 199 // WIN32: %[[NEXT1:.+]] = getelementptr inbounds i8, i8* %[[CUR1]], i32 16 200 // WIN32: store i8* %[[NEXT1]], i8** %[[ARGS]] 201 // WIN32: %[[BC1:.+]] = bitcast i8* %[[CUR1]] to i92* 202 // WIN32: %[[LOADV1:.+]] = load i92, i92* %[[BC1]] 203 // WIN32: store i92 %[[LOADV1]], i92* 204 205 206 _ExtInt(31) B = __builtin_va_arg(args, _ExtInt(31)); 207 // LIN64: %[[AD2:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] 208 // LIN64: %[[OFA_P2:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD2]], i32 0, i32 0 209 // LIN64: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P2]] 210 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 40 211 // LIN64: br i1 %[[FITSINGP]] 212 // LIN64: %[[BC1:.+]] = phi i31* 213 // LIN64: %[[LOAD1:.+]] = load i31, i31* %[[BC1]] 214 // LIN64: store i31 %[[LOAD1]], i31* 215 216 // LIN32: %[[CUR2:.+]] = load i8*, i8** %[[ARGS]] 217 // LIN32: %[[NEXT2:.+]] = getelementptr inbounds i8, i8* %[[CUR2]], i32 4 218 // LIN32: store i8* %[[NEXT2]], i8** %[[ARGS]] 219 // LIN32: %[[BC2:.+]] = bitcast i8* %[[CUR2]] to i31* 220 // LIN32: %[[LOADV2:.+]] = load i31, i31* %[[BC2]] 221 // LIN32: store i31 %[[LOADV2]], i31* 222 223 // WIN64: %[[CUR2:.+]] = load i8*, i8** %[[ARGS]] 224 // WIN64: %[[NEXT2:.+]] = getelementptr inbounds i8, i8* %[[CUR2]], i64 8 225 // WIN64: store i8* %[[NEXT2]], i8** %[[ARGS]] 226 // WIN64: %[[BC2:.+]] = bitcast i8* %[[CUR2]] to i31* 227 // WIN64: %[[LOADV2:.+]] = load i31, i31* %[[BC2]] 228 // WIN64: store i31 %[[LOADV2]], i31* 229 230 // WIN32: %[[CUR2:.+]] = load i8*, i8** %[[ARGS]] 231 // WIN32: %[[NEXT2:.+]] = getelementptr inbounds i8, i8* %[[CUR2]], i32 4 232 // WIN32: store i8* %[[NEXT2]], i8** %[[ARGS]] 233 // WIN32: %[[BC2:.+]] = bitcast i8* %[[CUR2]] to i31* 234 // WIN32: %[[LOADV2:.+]] = load i31, i31* %[[BC2]] 235 // WIN32: store i31 %[[LOADV2]], i31* 236 237 _ExtInt(16) C = __builtin_va_arg(args, _ExtInt(16)); 238 // LIN64: %[[AD3:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] 239 // LIN64: %[[OFA_P3:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD3]], i32 0, i32 0 240 // LIN64: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P3]] 241 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 40 242 // LIN64: br i1 %[[FITSINGP]] 243 // LIN64: %[[BC1:.+]] = phi i16* 244 // LIN64: %[[LOAD1:.+]] = load i16, i16* %[[BC1]] 245 // LIN64: store i16 %[[LOAD1]], i16* 246 247 // LIN32: %[[CUR3:.+]] = load i8*, i8** %[[ARGS]] 248 // LIN32: %[[NEXT3:.+]] = getelementptr inbounds i8, i8* %[[CUR3]], i32 4 249 // LIN32: store i8* %[[NEXT3]], i8** %[[ARGS]] 250 // LIN32: %[[BC3:.+]] = bitcast i8* %[[CUR3]] to i16* 251 // LIN32: %[[LOADV3:.+]] = load i16, i16* %[[BC3]] 252 // LIN32: store i16 %[[LOADV3]], i16* 253 254 // WIN64: %[[CUR3:.+]] = load i8*, i8** %[[ARGS]] 255 // WIN64: %[[NEXT3:.+]] = getelementptr inbounds i8, i8* %[[CUR3]], i64 8 256 // WIN64: store i8* %[[NEXT3]], i8** %[[ARGS]] 257 // WIN64: %[[BC3:.+]] = bitcast i8* %[[CUR3]] to i16* 258 // WIN64: %[[LOADV3:.+]] = load i16, i16* %[[BC3]] 259 // WIN64: store i16 %[[LOADV3]], i16* 260 261 // WIN32: %[[CUR3:.+]] = load i8*, i8** %[[ARGS]] 262 // WIN32: %[[NEXT3:.+]] = getelementptr inbounds i8, i8* %[[CUR3]], i32 4 263 // WIN32: store i8* %[[NEXT3]], i8** %[[ARGS]] 264 // WIN32: %[[BC3:.+]] = bitcast i8* %[[CUR3]] to i16* 265 // WIN32: %[[LOADV3:.+]] = load i16, i16* %[[BC3]] 266 // WIN32: store i16 %[[LOADV3]], i16* 267 268 269 _ExtInt(129) D = __builtin_va_arg(args, _ExtInt(129)); 270 // LIN64: %[[AD4:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] 271 // LIN64: %[[OFA_P4:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD4]], i32 0, i32 2 272 // LIN64: %[[OFA4:.+]] = load i8*, i8** %[[OFA_P4]] 273 // LIN64: %[[BC4:.+]] = bitcast i8* %[[OFA4]] to i129* 274 // LIN64: %[[OFANEXT4:.+]] = getelementptr i8, i8* %[[OFA4]], i32 24 275 // LIN64: store i8* %[[OFANEXT4]], i8** %[[OFA_P4]] 276 // LIN64: %[[LOAD4:.+]] = load i129, i129* %[[BC4]] 277 // LIN64: store i129 %[[LOAD4]], i129* 278 279 // LIN32: %[[CUR4:.+]] = load i8*, i8** %[[ARGS]] 280 // LIN32: %[[NEXT4:.+]] = getelementptr inbounds i8, i8* %[[CUR4]], i32 20 281 // LIN32: store i8* %[[NEXT4]], i8** %[[ARGS]] 282 // LIN32: %[[BC4:.+]] = bitcast i8* %[[CUR4]] to i129* 283 // LIN32: %[[LOADV4:.+]] = load i129, i129* %[[BC4]] 284 // LIN32: store i129 %[[LOADV4]], i129* 285 286 // WIN64: %[[CUR4:.+]] = load i8*, i8** %[[ARGS]] 287 // WIN64: %[[NEXT4:.+]] = getelementptr inbounds i8, i8* %[[CUR4]], i64 8 288 // WIN64: store i8* %[[NEXT4]], i8** %[[ARGS]] 289 // WIN64: %[[BC4:.+]] = bitcast i8* %[[CUR4]] to i129** 290 // WIN64: %[[LOADP4:.+]] = load i129*, i129** %[[BC4]] 291 // WIN64: %[[LOADV4:.+]] = load i129, i129* %[[LOADP4]] 292 // WIN64: store i129 %[[LOADV4]], i129* 293 294 // WIN32: %[[CUR4:.+]] = load i8*, i8** %[[ARGS]] 295 // WIN32: %[[NEXT4:.+]] = getelementptr inbounds i8, i8* %[[CUR4]], i32 24 296 // WIN32: store i8* %[[NEXT4]], i8** %[[ARGS]] 297 // WIN32: %[[BC4:.+]] = bitcast i8* %[[CUR4]] to i129* 298 // WIN32: %[[LOADV4:.+]] = load i129, i129* %[[BC4]] 299 // WIN32: store i129 %[[LOADV4]], i129* 300 301 _ExtInt(8388600) E = __builtin_va_arg(args, _ExtInt(8388600)); 302 // LIN64: %[[AD5:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] 303 // LIN64: %[[OFA_P5:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD5]], i32 0, i32 2 304 // LIN64: %[[OFA5:.+]] = load i8*, i8** %[[OFA_P5]] 305 // LIN64: %[[BC5:.+]] = bitcast i8* %[[OFA5]] to i8388600* 306 // LIN64: %[[OFANEXT5:.+]] = getelementptr i8, i8* %[[OFA5]], i32 1048576 307 // LIN64: store i8* %[[OFANEXT5]], i8** %[[OFA_P5]] 308 // LIN64: %[[LOAD5:.+]] = load i8388600, i8388600* %[[BC5]] 309 // LIN64: store i8388600 %[[LOAD5]], i8388600* 310 311 // LIN32: %[[CUR5:.+]] = load i8*, i8** %[[ARGS]] 312 // LIN32: %[[NEXT5:.+]] = getelementptr inbounds i8, i8* %[[CUR5]], i32 1048576 313 // LIN32: store i8* %[[NEXT5]], i8** %[[ARGS]] 314 // LIN32: %[[BC5:.+]] = bitcast i8* %[[CUR5]] to i8388600* 315 // LIN32: %[[LOADV5:.+]] = load i8388600, i8388600* %[[BC5]] 316 // LIN32: store i8388600 %[[LOADV5]], i8388600* 317 318 // WIN64: %[[CUR5:.+]] = load i8*, i8** %[[ARGS]] 319 // WIN64: %[[NEXT5:.+]] = getelementptr inbounds i8, i8* %[[CUR5]], i64 8 320 // WIN64: store i8* %[[NEXT5]], i8** %[[ARGS]] 321 // WIN64: %[[BC5:.+]] = bitcast i8* %[[CUR5]] to i8388600** 322 // WIN64: %[[LOADP5:.+]] = load i8388600*, i8388600** %[[BC5]] 323 // WIN64: %[[LOADV5:.+]] = load i8388600, i8388600* %[[LOADP5]] 324 // WIN64: store i8388600 %[[LOADV5]], i8388600* 325 326 // WIN32: %[[CUR5:.+]] = load i8*, i8** %[[ARGS]] 327 // WIN32: %[[NEXT5:.+]] = getelementptr inbounds i8, i8* %[[CUR5]], i32 1048576 328 // WIN32: store i8* %[[NEXT5]], i8** %[[ARGS]] 329 // WIN32: %[[BC5:.+]] = bitcast i8* %[[CUR5]] to i8388600* 330 // WIN32: %[[LOADV5:.+]] = load i8388600, i8388600* %[[BC5]] 331 // WIN32: store i8388600 %[[LOADV5]], i8388600* 332 333 __builtin_va_end(args); 334 // LIN64: %[[ENDAD:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] 335 // LIN64: %[[ENDAD1:.+]] = bitcast %struct.__va_list_tag* %[[ENDAD]] to i8* 336 // LIN64: call void @llvm.va_end(i8* %[[ENDAD1]]) 337 // LIN32: %[[ARGSEND:.+]] = bitcast i8** %[[ARGS]] to i8* 338 // LIN32: call void @llvm.va_end(i8* %[[ARGSEND]]) 339 // WIN: %[[ARGSEND:.+]] = bitcast i8** %[[ARGS]] to i8* 340 // WIN: call void @llvm.va_end(i8* %[[ARGSEND]]) 341 } 342 void typeid_tests() { 343 // LIN: define{{.*}} void @_Z12typeid_testsv() 344 // WIN: define dso_local void @"?typeid_tests@@YAXXZ"() 345 unsigned _ExtInt(33) U33_1, U33_2; 346 _ExtInt(33) S33_1, S33_2; 347 _ExtInt(32) S32_1, S32_2; 348 349 auto A = typeid(U33_1); 350 // LIN64: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*)) 351 // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*)) 352 // WIN64: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) 353 // WIN32: call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) 354 auto B = typeid(U33_2); 355 // LIN64: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*)) 356 // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*)) 357 // WIN64: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) 358 // WIN32: call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) 359 auto C = typeid(S33_1); 360 // LIN64: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*)) 361 // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*)) 362 // WIN64: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) 363 // WIN32: call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) 364 auto D = typeid(S33_2); 365 // LIN64: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*)) 366 // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*)) 367 // WIN64: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) 368 // WIN32: call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) 369 auto E = typeid(S32_1); 370 // LIN64: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*)) 371 // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*)) 372 // WIN64: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) 373 // WIN32: call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) 374 auto F = typeid(S32_2); 375 // LIN64: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*)) 376 // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*)) 377 // WIN64: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) 378 // WIN32: call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) 379 } 380 381 void ExplicitCasts() { 382 // LIN: define{{.*}} void @_Z13ExplicitCastsv() 383 // WIN: define dso_local void @"?ExplicitCasts@@YAXXZ"() 384 385 _ExtInt(33) a; 386 _ExtInt(31) b; 387 int i; 388 389 a = i; 390 // CHECK: %[[CONV:.+]] = sext i32 %{{.+}} to i33 391 b = i; 392 // CHECK: %[[CONV:.+]] = trunc i32 %{{.+}} to i31 393 i = a; 394 // CHECK: %[[CONV:.+]] = trunc i33 %{{.+}} to i32 395 i = b; 396 // CHECK: %[[CONV:.+]] = sext i31 %{{.+}} to i32 397 } 398 399 struct S { 400 _ExtInt(17) A; 401 _ExtInt(8388600) B; 402 _ExtInt(17) C; 403 }; 404 405 void OffsetOfTest() { 406 // LIN: define{{.*}} void @_Z12OffsetOfTestv() 407 // WIN: define dso_local void @"?OffsetOfTest@@YAXXZ"() 408 409 auto A = __builtin_offsetof(S,A); 410 // CHECK: store i{{.+}} 0, i{{.+}}* %{{.+}} 411 auto B = __builtin_offsetof(S,B); 412 // LIN64: store i{{.+}} 8, i{{.+}}* %{{.+}} 413 // LIN32: store i{{.+}} 4, i{{.+}}* %{{.+}} 414 // WIN: store i{{.+}} 8, i{{.+}}* %{{.+}} 415 auto C = __builtin_offsetof(S,C); 416 // LIN64: store i{{.+}} 1048584, i{{.+}}* %{{.+}} 417 // LIN32: store i{{.+}} 1048580, i{{.+}}* %{{.+}} 418 // WIN: store i{{.+}} 1048584, i{{.+}}* %{{.+}} 419 } 420 421 422 void ShiftExtIntByConstant(_ExtInt(28) Ext) { 423 // LIN: define{{.*}} void @_Z21ShiftExtIntByConstantU7_ExtIntILi28EEi 424 // WIN: define dso_local void @"?ShiftExtIntByConstant@@YAXU?$_ExtInt@$0BM@@__clang@@@Z" 425 Ext << 7; 426 // CHECK: shl i28 %{{.+}}, 7 427 Ext >> 7; 428 // CHECK: ashr i28 %{{.+}}, 7 429 Ext << -7; 430 // CHECK: shl i28 %{{.+}}, -7 431 Ext >> -7; 432 // CHECK: ashr i28 %{{.+}}, -7 433 434 // UB in C/C++, Defined in OpenCL. 435 Ext << 29; 436 // CHECK: shl i28 %{{.+}}, 29 437 Ext >> 29; 438 // CHECK: ashr i28 %{{.+}}, 29 439 } 440 441 void ConstantShiftByExtInt(_ExtInt(28) Ext, _ExtInt(65) LargeExt) { 442 // LIN: define{{.*}} void @_Z21ConstantShiftByExtIntU7_ExtIntILi28EEiU7_ExtIntILi65EEi 443 // WIN: define dso_local void @"?ConstantShiftByExtInt@@YAXU?$_ExtInt@$0BM@@__clang@@U?$_ExtInt@$0EB@@2@@Z" 444 10 << Ext; 445 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32 446 // CHECK: shl i32 10, %[[PROMO]] 447 10 >> Ext; 448 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32 449 // CHECK: ashr i32 10, %[[PROMO]] 450 10 << LargeExt; 451 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32 452 // CHECK: shl i32 10, %[[PROMO]] 453 10 >> LargeExt; 454 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32 455 // CHECK: ashr i32 10, %[[PROMO]] 456 } 457 458 void Shift(_ExtInt(28) Ext, _ExtInt(65) LargeExt, int i) { 459 // LIN: define{{.*}} void @_Z5ShiftU7_ExtIntILi28EEiU7_ExtIntILi65EEii 460 // WIN: define dso_local void @"?Shift@@YAXU?$_ExtInt@$0BM@@__clang@@U?$_ExtInt@$0EB@@2@H@Z" 461 i << Ext; 462 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32 463 // CHECK: shl i32 {{.+}}, %[[PROMO]] 464 i >> Ext; 465 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32 466 // CHECK: ashr i32 {{.+}}, %[[PROMO]] 467 468 i << LargeExt; 469 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32 470 // CHECK: shl i32 {{.+}}, %[[PROMO]] 471 i >> LargeExt; 472 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32 473 // CHECK: ashr i32 {{.+}}, %[[PROMO]] 474 475 Ext << i; 476 // CHECK: %[[PROMO:.+]] = trunc i32 %{{.+}} to i28 477 // CHECK: shl i28 {{.+}}, %[[PROMO]] 478 Ext >> i; 479 // CHECK: %[[PROMO:.+]] = trunc i32 %{{.+}} to i28 480 // CHECK: ashr i28 {{.+}}, %[[PROMO]] 481 482 LargeExt << i; 483 // CHECK: %[[PROMO:.+]] = zext i32 %{{.+}} to i65 484 // CHECK: shl i65 {{.+}}, %[[PROMO]] 485 LargeExt >> i; 486 // CHECK: %[[PROMO:.+]] = zext i32 %{{.+}} to i65 487 // CHECK: ashr i65 {{.+}}, %[[PROMO]] 488 489 Ext << LargeExt; 490 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i28 491 // CHECK: shl i28 {{.+}}, %[[PROMO]] 492 Ext >> LargeExt; 493 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i28 494 // CHECK: ashr i28 {{.+}}, %[[PROMO]] 495 496 LargeExt << Ext; 497 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i65 498 // CHECK: shl i65 {{.+}}, %[[PROMO]] 499 LargeExt >> Ext; 500 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i65 501 // CHECK: ashr i65 {{.+}}, %[[PROMO]] 502 } 503 504 void ComplexTest(_Complex _ExtInt(12) first, 505 _Complex _ExtInt(33) second) { 506 // LIN: define{{.*}} void @_Z11ComplexTestCU7_ExtIntILi12EEiCU7_ExtIntILi33EEi 507 // WIN: define dso_local void @"?ComplexTest@@YAXU?$_Complex@U?$_ExtInt@$0M@@__clang@@@__clang@@U?$_Complex@U?$_ExtInt@$0CB@@__clang@@@2@@Z" 508 first + second; 509 // CHECK: %[[FIRST_REALP:.+]] = getelementptr inbounds { i12, i12 }, { i12, i12 }* %{{.+}}, i32 0, i32 0 510 // CHECK: %[[FIRST_REAL:.+]] = load i12, i12* %[[FIRST_REALP]] 511 // CHECK: %[[FIRST_IMAGP:.+]] = getelementptr inbounds { i12, i12 }, { i12, i12 }* %{{.+}}, i32 0, i32 1 512 // CHECK: %[[FIRST_IMAG:.+]] = load i12, i12* %[[FIRST_IMAGP]] 513 // CHECK: %[[FIRST_REAL_CONV:.+]] = sext i12 %[[FIRST_REAL]] 514 // CHECK: %[[FIRST_IMAG_CONV:.+]] = sext i12 %[[FIRST_IMAG]] 515 // CHECK: %[[SECOND_REALP:.+]] = getelementptr inbounds { i33, i33 }, { i33, i33 }* %{{.+}}, i32 0, i32 0 516 // CHECK: %[[SECOND_REAL:.+]] = load i33, i33* %[[SECOND_REALP]] 517 // CHECK: %[[SECOND_IMAGP:.+]] = getelementptr inbounds { i33, i33 }, { i33, i33 }* %{{.+}}, i32 0, i32 1 518 // CHECK: %[[SECOND_IMAG:.+]] = load i33, i33* %[[SECOND_IMAGP]] 519 // CHECK: %[[REAL:.+]] = add i33 %[[FIRST_REAL_CONV]], %[[SECOND_REAL]] 520 // CHECK: %[[IMAG:.+]] = add i33 %[[FIRST_IMAG_CONV]], %[[SECOND_IMAG]] 521 } 522 523 // Ensure that these types don't alias the normal int types. 524 void TBAATest(_ExtInt(sizeof(int) * 8) ExtInt, 525 unsigned _ExtInt(sizeof(int) * 8) ExtUInt, 526 _ExtInt(6) Other) { 527 // CHECK-DAG: store i32 %{{.+}}, i32* %{{.+}}, align 4, !tbaa ![[EXTINT_TBAA:.+]] 528 // CHECK-DAG: store i32 %{{.+}}, i32* %{{.+}}, align 4, !tbaa ![[EXTINT_TBAA]] 529 // CHECK-DAG: store i6 %{{.+}}, i6* %{{.+}}, align 1, !tbaa ![[EXTINT6_TBAA:.+]] 530 ExtInt = 5; 531 ExtUInt = 5; 532 Other = 5; 533 } 534 535 // NoNewStructPathTBAA-DAG: ![[CHAR_TBAA_ROOT:.+]] = !{!"omnipotent char", ![[TBAA_ROOT:.+]], i64 0} 536 // NoNewStructPathTBAA-DAG: ![[TBAA_ROOT]] = !{!"Simple C++ TBAA"} 537 // NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA]] = !{![[EXTINT_TBAA_ROOT:.+]], ![[EXTINT_TBAA_ROOT]], i64 0} 538 // NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{!"_ExtInt(32)", ![[CHAR_TBAA_ROOT]], i64 0} 539 // NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA]] = !{![[EXTINT6_TBAA_ROOT:.+]], ![[EXTINT6_TBAA_ROOT]], i64 0} 540 // NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{!"_ExtInt(6)", ![[CHAR_TBAA_ROOT]], i64 0} 541 542 // NewStructPathTBAA-DAG: ![[CHAR_TBAA_ROOT:.+]] = !{![[TBAA_ROOT:.+]], i64 1, !"omnipotent char"} 543 // NewStructPathTBAA-DAG: ![[TBAA_ROOT]] = !{!"Simple C++ TBAA"} 544 // NewStructPathTBAA-DAG: ![[EXTINT_TBAA]] = !{![[EXTINT_TBAA_ROOT:.+]], ![[EXTINT_TBAA_ROOT]], i64 0, i64 4} 545 // NewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 4, !"_ExtInt(32)"} 546 // NewStructPathTBAA-DAG: ![[EXTINT6_TBAA]] = !{![[EXTINT6_TBAA_ROOT:.+]], ![[EXTINT6_TBAA_ROOT]], i64 0, i64 1} 547 // NewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 1, !"_ExtInt(6)"} 548