1; RUN: llc -verify-machineinstrs -disable-fp-elim -enable-shrink-wrap=false < %s -mtriple=aarch64-apple-ios -disable-post-ra | FileCheck --check-prefix=CHECK-APPLE %s 2; RUN: llc -verify-machineinstrs -disable-fp-elim -O0 < %s -mtriple=aarch64-apple-ios -disable-post-ra | FileCheck --check-prefix=CHECK-O0 %s 3 4declare i8* @malloc(i64) 5declare void @free(i8*) 6%swift_error = type {i64, i8} 7 8; This tests the basic usage of a swifterror parameter. "foo" is the function 9; that takes a swifterror parameter and "caller" is the caller of "foo". 10define float @foo(%swift_error** swifterror %error_ptr_ref) { 11; CHECK-APPLE-LABEL: foo: 12; CHECK-APPLE: orr w0, wzr, #0x10 13; CHECK-APPLE: malloc 14; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1 15; CHECK-APPLE: strb [[ID]], [x0, #8] 16; CHECK-APPLE: mov x19, x0 17; CHECK-APPLE-NOT: x19 18 19; CHECK-O0-LABEL: foo: 20; CHECK-O0: orr w{{.*}}, wzr, #0x10 21; CHECK-O0: malloc 22; CHECK-O0: mov x19, x0 23; CHECK-O0-NOT: x19 24; CHECK-O0: orr [[ID:w[0-9]+]], wzr, #0x1 25; CHECK-O0-NOT: x19 26; CHECK-O0: strb [[ID]], [x0, #8] 27; CHECK-O0-NOT: x19 28entry: 29 %call = call i8* @malloc(i64 16) 30 %call.0 = bitcast i8* %call to %swift_error* 31 store %swift_error* %call.0, %swift_error** %error_ptr_ref 32 %tmp = getelementptr inbounds i8, i8* %call, i64 8 33 store i8 1, i8* %tmp 34 ret float 1.0 35} 36 37; "caller" calls "foo" that takes a swifterror parameter. 38define float @caller(i8* %error_ref) { 39; CHECK-APPLE-LABEL: caller: 40; CHECK-APPLE: mov [[ID:x[0-9]+]], x0 41; CHECK-APPLE: mov x19, xzr 42; CHECK-APPLE: bl {{.*}}foo 43; CHECK-APPLE: cbnz x19 44; Access part of the error object and save it to error_ref 45; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x19, #8] 46; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]] 47; CHECK-APPLE: mov x0, x19 48; CHECK-APPLE: bl {{.*}}free 49 50; CHECK-O0-LABEL: caller: 51; CHECK-O0: mov x19 52; CHECK-O0: bl {{.*}}foo 53; CHECK-O0: mov [[ID:x[0-9]+]], x19 54; CHECK-O0: cbnz x19 55entry: 56 %error_ptr_ref = alloca swifterror %swift_error* 57 store %swift_error* null, %swift_error** %error_ptr_ref 58 %call = call float @foo(%swift_error** swifterror %error_ptr_ref) 59 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref 60 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null 61 %tmp = bitcast %swift_error* %error_from_foo to i8* 62 br i1 %had_error_from_foo, label %handler, label %cont 63cont: 64 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1 65 %t = load i8, i8* %v1 66 store i8 %t, i8* %error_ref 67 br label %handler 68handler: 69 call void @free(i8* %tmp) 70 ret float 1.0 71} 72 73; "caller2" is the caller of "foo", it calls "foo" inside a loop. 74define float @caller2(i8* %error_ref) { 75; CHECK-APPLE-LABEL: caller2: 76; CHECK-APPLE: mov [[ID:x[0-9]+]], x0 77; CHECK-APPLE: fmov [[CMP:s[0-9]+]], #1.0 78; CHECK-APPLE: mov x19, xzr 79; CHECK-APPLE: bl {{.*}}foo 80; CHECK-APPLE: cbnz x19 81; CHECK-APPLE: fcmp s0, [[CMP]] 82; CHECK-APPLE: b.le 83; Access part of the error object and save it to error_ref 84; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x19, #8] 85; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]] 86; CHECK-APPLE: mov x0, x19 87; CHECK-APPLE: bl {{.*}}free 88 89; CHECK-O0-LABEL: caller2: 90; CHECK-O0: mov x19 91; CHECK-O0: bl {{.*}}foo 92; CHECK-O0: mov [[ID:x[0-9]+]], x19 93; CHECK-O0: cbnz x19 94entry: 95 %error_ptr_ref = alloca swifterror %swift_error* 96 br label %bb_loop 97bb_loop: 98 store %swift_error* null, %swift_error** %error_ptr_ref 99 %call = call float @foo(%swift_error** swifterror %error_ptr_ref) 100 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref 101 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null 102 %tmp = bitcast %swift_error* %error_from_foo to i8* 103 br i1 %had_error_from_foo, label %handler, label %cont 104cont: 105 %cmp = fcmp ogt float %call, 1.000000e+00 106 br i1 %cmp, label %bb_end, label %bb_loop 107bb_end: 108 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1 109 %t = load i8, i8* %v1 110 store i8 %t, i8* %error_ref 111 br label %handler 112handler: 113 call void @free(i8* %tmp) 114 ret float 1.0 115} 116 117; "foo_if" is a function that takes a swifterror parameter, it sets swifterror 118; under a certain condition. 119define float @foo_if(%swift_error** swifterror %error_ptr_ref, i32 %cc) { 120; CHECK-APPLE-LABEL: foo_if: 121; CHECK-APPLE: cbz w0 122; CHECK-APPLE: orr w0, wzr, #0x10 123; CHECK-APPLE: malloc 124; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1 125; CHECK-APPLE: strb [[ID]], [x0, #8] 126; CHECK-APPLE: mov x19, x0 127; CHECK-APPLE-NOT: x19 128; CHECK-APPLE: ret 129 130; CHECK-O0-LABEL: foo_if: 131; spill x19 132; CHECK-O0: str x19, [sp, [[SLOT:#[0-9]+]]] 133; CHECK-O0: cbz w0 134; CHECK-O0: orr w{{.*}}, wzr, #0x10 135; CHECK-O0: malloc 136; CHECK-O0: mov [[ID:x[0-9]+]], x0 137; CHECK-O0: orr [[ID2:w[0-9]+]], wzr, #0x1 138; CHECK-O0: strb [[ID2]], [x0, #8] 139; CHECK-O0: mov x19, [[ID]] 140; CHECK-O0: ret 141; reload from stack 142; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp, [[SLOT]]] 143; CHECK-O0: mov x19, [[ID3]] 144; CHECK-O0: ret 145entry: 146 %cond = icmp ne i32 %cc, 0 147 br i1 %cond, label %gen_error, label %normal 148 149gen_error: 150 %call = call i8* @malloc(i64 16) 151 %call.0 = bitcast i8* %call to %swift_error* 152 store %swift_error* %call.0, %swift_error** %error_ptr_ref 153 %tmp = getelementptr inbounds i8, i8* %call, i64 8 154 store i8 1, i8* %tmp 155 ret float 1.0 156 157normal: 158 ret float 0.0 159} 160 161; "foo_loop" is a function that takes a swifterror parameter, it sets swifterror 162; under a certain condition inside a loop. 163define float @foo_loop(%swift_error** swifterror %error_ptr_ref, i32 %cc, float %cc2) { 164; CHECK-APPLE-LABEL: foo_loop: 165; CHECK-APPLE: mov x0, x19 166; CHECK-APPLE: cbz 167; CHECK-APPLE: orr w0, wzr, #0x10 168; CHECK-APPLE: malloc 169; CHECK-APPLE: strb w{{.*}}, [x0, #8] 170; CHECK-APPLE: fcmp 171; CHECK-APPLE: b.le 172; CHECK-APPLE: mov x19, x0 173; CHECK-APPLE: ret 174 175; CHECK-O0-LABEL: foo_loop: 176; spill x19 177; CHECK-O0: str x19, [sp, [[SLOT:#[0-9]+]]] 178; CHECK-O0: b [[BB1:[A-Za-z0-9_]*]] 179; CHECK-O0: [[BB1]]: 180; CHECK-O0: ldr x0, [sp, [[SLOT]]] 181; CHECK-O0: str x0, [sp, [[SLOT2:#[0-9]+]]] 182; CHECK-O0: cbz {{.*}}, [[BB2:[A-Za-z0-9_]*]] 183; CHECK-O0: orr w{{.*}}, wzr, #0x10 184; CHECK-O0: malloc 185; CHECK-O0: mov [[ID:x[0-9]+]], x0 186; CHECK-O0: strb w{{.*}}, [{{.*}}[[ID]], #8] 187; spill x0 188; CHECK-O0: str x0, [sp, [[SLOT2]]] 189; CHECK-O0:[[BB2]]: 190; CHECK-O0: ldr x0, [sp, [[SLOT2]]] 191; CHECK-O0: fcmp 192; CHECK-O0: str x0, [sp] 193; CHECK-O0: b.le [[BB1]] 194; reload from stack 195; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp] 196; CHECK-O0: mov x19, [[ID3]] 197; CHECK-O0: ret 198entry: 199 br label %bb_loop 200 201bb_loop: 202 %cond = icmp ne i32 %cc, 0 203 br i1 %cond, label %gen_error, label %bb_cont 204 205gen_error: 206 %call = call i8* @malloc(i64 16) 207 %call.0 = bitcast i8* %call to %swift_error* 208 store %swift_error* %call.0, %swift_error** %error_ptr_ref 209 %tmp = getelementptr inbounds i8, i8* %call, i64 8 210 store i8 1, i8* %tmp 211 br label %bb_cont 212 213bb_cont: 214 %cmp = fcmp ogt float %cc2, 1.000000e+00 215 br i1 %cmp, label %bb_end, label %bb_loop 216bb_end: 217 ret float 0.0 218} 219 220%struct.S = type { i32, i32, i32, i32, i32, i32 } 221 222; "foo_sret" is a function that takes a swifterror parameter, it also has a sret 223; parameter. 224define void @foo_sret(%struct.S* sret %agg.result, i32 %val1, %swift_error** swifterror %error_ptr_ref) { 225; CHECK-APPLE-LABEL: foo_sret: 226; CHECK-APPLE: mov [[SRET:x[0-9]+]], x8 227; CHECK-APPLE: orr w0, wzr, #0x10 228; CHECK-APPLE: malloc 229; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1 230; CHECK-APPLE: strb [[ID]], [x0, #8] 231; CHECK-APPLE: str w{{.*}}, [{{.*}}[[SRET]], #4] 232; CHECK-APPLE: mov x19, x0 233; CHECK-APPLE-NOT: x19 234 235; CHECK-O0-LABEL: foo_sret: 236; CHECK-O0: orr w{{.*}}, wzr, #0x10 237; spill x8 238; CHECK-O0-DAG: str x8 239; spill x19 240; CHECK-O0-DAG: str x19 241; CHECK-O0: malloc 242; CHECK-O0: orr [[ID:w[0-9]+]], wzr, #0x1 243; CHECK-O0: strb [[ID]], [x0, #8] 244; reload from stack 245; CHECK-O0: ldr [[SRET:x[0-9]+]] 246; CHECK-O0: str w{{.*}}, [{{.*}}[[SRET]], #4] 247; CHECK-O0: mov x19 248; CHECK-O0-NOT: x19 249entry: 250 %call = call i8* @malloc(i64 16) 251 %call.0 = bitcast i8* %call to %swift_error* 252 store %swift_error* %call.0, %swift_error** %error_ptr_ref 253 %tmp = getelementptr inbounds i8, i8* %call, i64 8 254 store i8 1, i8* %tmp 255 %v2 = getelementptr inbounds %struct.S, %struct.S* %agg.result, i32 0, i32 1 256 store i32 %val1, i32* %v2 257 ret void 258} 259 260; "caller3" calls "foo_sret" that takes a swifterror parameter. 261define float @caller3(i8* %error_ref) { 262; CHECK-APPLE-LABEL: caller3: 263; CHECK-APPLE: mov [[ID:x[0-9]+]], x0 264; CHECK-APPLE: mov x19, xzr 265; CHECK-APPLE: bl {{.*}}foo_sret 266; CHECK-APPLE: cbnz x19 267; Access part of the error object and save it to error_ref 268; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x19, #8] 269; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]] 270; CHECK-APPLE: mov x0, x19 271; CHECK-APPLE: bl {{.*}}free 272 273; CHECK-O0-LABEL: caller3: 274; spill x0 275; CHECK-O0: str x0 276; CHECK-O0: mov x19 277; CHECK-O0: bl {{.*}}foo_sret 278; CHECK-O0: mov [[ID2:x[0-9]+]], x19 279; CHECK-O0: cbnz [[ID2]] 280; Access part of the error object and save it to error_ref 281; reload from stack 282; CHECK-O0: ldrb [[CODE:w[0-9]+]] 283; CHECK-O0: ldr [[ID:x[0-9]+]] 284; CHECK-O0: strb [[CODE]], [{{.*}}[[ID]]] 285; CHECK-O0: bl {{.*}}free 286entry: 287 %s = alloca %struct.S, align 8 288 %error_ptr_ref = alloca swifterror %swift_error* 289 store %swift_error* null, %swift_error** %error_ptr_ref 290 call void @foo_sret(%struct.S* sret %s, i32 1, %swift_error** swifterror %error_ptr_ref) 291 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref 292 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null 293 %tmp = bitcast %swift_error* %error_from_foo to i8* 294 br i1 %had_error_from_foo, label %handler, label %cont 295cont: 296 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1 297 %t = load i8, i8* %v1 298 store i8 %t, i8* %error_ref 299 br label %handler 300handler: 301 call void @free(i8* %tmp) 302 ret float 1.0 303} 304 305; "foo_vararg" is a function that takes a swifterror parameter, it also has 306; variable number of arguments. 307declare void @llvm.va_start(i8*) nounwind 308define float @foo_vararg(%swift_error** swifterror %error_ptr_ref, ...) { 309; CHECK-APPLE-LABEL: foo_vararg: 310; CHECK-APPLE: orr w0, wzr, #0x10 311; CHECK-APPLE: malloc 312; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1 313; CHECK-APPLE: add [[ARGS:x[0-9]+]], [[TMP:x[0-9]+]], #16 314; CHECK-APPLE: strb [[ID]], [x0, #8] 315 316; First vararg 317; CHECK-APPLE-DAG: orr {{x[0-9]+}}, [[ARGS]], #0x8 318; CHECK-APPLE-DAG: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #16] 319; CHECK-APPLE: add {{x[0-9]+}}, {{x[0-9]+}}, #8 320; Second vararg 321; CHECK-APPLE: ldr {{w[0-9]+}}, [{{x[0-9]+}}] 322; CHECK-APPLE: add {{x[0-9]+}}, {{x[0-9]+}}, #8 323; Third vararg 324; CHECK-APPLE: ldr {{w[0-9]+}}, [{{x[0-9]+}}] 325 326; CHECK-APPLE: mov x19, x0 327; CHECK-APPLE-NOT: x19 328entry: 329 %call = call i8* @malloc(i64 16) 330 %call.0 = bitcast i8* %call to %swift_error* 331 store %swift_error* %call.0, %swift_error** %error_ptr_ref 332 %tmp = getelementptr inbounds i8, i8* %call, i64 8 333 store i8 1, i8* %tmp 334 335 %args = alloca i8*, align 8 336 %a10 = alloca i32, align 4 337 %a11 = alloca i32, align 4 338 %a12 = alloca i32, align 4 339 %v10 = bitcast i8** %args to i8* 340 call void @llvm.va_start(i8* %v10) 341 %v11 = va_arg i8** %args, i32 342 store i32 %v11, i32* %a10, align 4 343 %v12 = va_arg i8** %args, i32 344 store i32 %v12, i32* %a11, align 4 345 %v13 = va_arg i8** %args, i32 346 store i32 %v13, i32* %a12, align 4 347 348 ret float 1.0 349} 350 351; "caller4" calls "foo_vararg" that takes a swifterror parameter. 352define float @caller4(i8* %error_ref) { 353; CHECK-APPLE-LABEL: caller4: 354 355; CHECK-APPLE: mov [[ID:x[0-9]+]], x0 356; CHECK-APPLE: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #8] 357; CHECK-APPLE: str {{x[0-9]+}}, [sp] 358 359; CHECK-APPLE: mov x19, xzr 360; CHECK-APPLE: bl {{.*}}foo_vararg 361; CHECK-APPLE: cbnz x19 362; Access part of the error object and save it to error_ref 363; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x19, #8] 364; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]] 365; CHECK-APPLE: mov x0, x19 366; CHECK-APPLE: bl {{.*}}free 367entry: 368 %error_ptr_ref = alloca swifterror %swift_error* 369 store %swift_error* null, %swift_error** %error_ptr_ref 370 371 %a10 = alloca i32, align 4 372 %a11 = alloca i32, align 4 373 %a12 = alloca i32, align 4 374 store i32 10, i32* %a10, align 4 375 store i32 11, i32* %a11, align 4 376 store i32 12, i32* %a12, align 4 377 %v10 = load i32, i32* %a10, align 4 378 %v11 = load i32, i32* %a11, align 4 379 %v12 = load i32, i32* %a12, align 4 380 381 %call = call float (%swift_error**, ...) @foo_vararg(%swift_error** swifterror %error_ptr_ref, i32 %v10, i32 %v11, i32 %v12) 382 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref 383 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null 384 %tmp = bitcast %swift_error* %error_from_foo to i8* 385 br i1 %had_error_from_foo, label %handler, label %cont 386 387cont: 388 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1 389 %t = load i8, i8* %v1 390 store i8 %t, i8* %error_ref 391 br label %handler 392handler: 393 call void @free(i8* %tmp) 394 ret float 1.0 395} 396 397; Check that we don't blow up on tail calling swifterror argument functions. 398define float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) { 399entry: 400 %0 = tail call float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) 401 ret float %0 402} 403define swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) { 404entry: 405 %0 = tail call swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) 406 ret float %0 407} 408 409; CHECK-APPLE-LABEL: swifterror_clobber 410; CHECK-APPLE: mov [[REG:x[0-9]+]], x19 411; CHECK-APPLE: nop 412; CHECK-APPLE: mov x19, [[REG]] 413define swiftcc void @swifterror_clobber(%swift_error** nocapture swifterror %err) { 414 call void asm sideeffect "nop", "~{x19}"() 415 ret void 416} 417 418; CHECK-APPLE-LABEL: swifterror_reg_clobber 419; CHECK-APPLE: stp {{.*}}x19 420; CHECK-APPLE: nop 421; CHECK-APPLE: ldp {{.*}}x19 422define swiftcc void @swifterror_reg_clobber(%swift_error** nocapture %err) { 423 call void asm sideeffect "nop", "~{x19}"() 424 ret void 425} 426; CHECK-APPLE-LABEL: params_in_reg 427; Save callee saved registers and swifterror since it will be clobbered by the first call to params_in_reg2. 428; CHECK-APPLE: stp x19, x28, [sp 429; CHECK-APPLE: stp x27, x26, [sp 430; CHECK-APPLE: stp x25, x24, [sp 431; CHECK-APPLE: stp x23, x22, [sp 432; CHECK-APPLE: stp x21, x20, [sp 433; CHECK-APPLE: stp x29, x30, [sp 434; CHECK-APPLE: str x20, [sp 435; Store argument registers. 436; CHECK-APPLE: mov x23, x7 437; CHECK-APPLE: mov x24, x6 438; CHECK-APPLE: mov x25, x5 439; CHECK-APPLE: mov x26, x4 440; CHECK-APPLE: mov x27, x3 441; CHECK-APPLE: mov x28, x2 442; CHECK-APPLE: mov x21, x1 443; CHECK-APPLE: mov x22, x0 444; Setup call. 445; CHECK-APPLE: orr w0, wzr, #0x1 446; CHECK-APPLE: orr w1, wzr, #0x2 447; CHECK-APPLE: orr w2, wzr, #0x3 448; CHECK-APPLE: orr w3, wzr, #0x4 449; CHECK-APPLE: mov w4, #5 450; CHECK-APPLE: orr w5, wzr, #0x6 451; CHECK-APPLE: orr w6, wzr, #0x7 452; CHECK-APPLE: orr w7, wzr, #0x8 453; CHECK-APPLE: mov x20, xzr 454; CHECK-APPLE: mov x19, xzr 455; CHECK-APPLE: bl _params_in_reg2 456; Restore original arguments for next call. 457; CHECK-APPLE: mov x0, x22 458; CHECK-APPLE: mov x1, x21 459; CHECK-APPLE: mov x2, x28 460; CHECK-APPLE: mov x3, x27 461; CHECK-APPLE: mov x4, x26 462; CHECK-APPLE: mov x5, x25 463; CHECK-APPLE: mov x6, x24 464; CHECK-APPLE: mov x7, x23 465; Restore original swiftself argument and swifterror %err. 466; CHECK-APPLE: ldp x20, x19, [sp 467; CHECK-APPLE: bl _params_in_reg2 468; Restore calle save registers but don't clober swifterror x19. 469; CHECK-APPLE-NOT: x19 470; CHECK-APPLE: ldp x29, x30, [sp 471; CHECK-APPLE-NOT: x19 472; CHECK-APPLE: ldp x21, x20, [sp 473; CHECK-APPLE-NOT: x19 474; CHECK-APPLE: ldp x23, x22, [sp 475; CHECK-APPLE-NOT: x19 476; CHECK-APPLE: ldp x25, x24, [sp 477; CHECK-APPLE-NOT: x19 478; CHECK-APPLE: ldp x27, x26, [sp 479; CHECK-APPLE-NOT: x19 480; CHECK-APPLE: ldr x28, [sp 481; CHECK-APPLE-NOT: x19 482; CHECK-APPLE: ret 483define swiftcc void @params_in_reg(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) { 484 %error_ptr_ref = alloca swifterror %swift_error*, align 8 485 store %swift_error* null, %swift_error** %error_ptr_ref 486 call swiftcc void @params_in_reg2(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref) 487 call swiftcc void @params_in_reg2(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, i64 %7, i8* swiftself %8, %swift_error** nocapture swifterror %err) 488 ret void 489} 490declare swiftcc void @params_in_reg2(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) 491 492; CHECK-APPLE-LABEL: params_and_return_in_reg 493; Store callee saved registers. 494; CHECK-APPLE: stp x20, x28, [sp, #24 495; CHECK-APPLE: stp x27, x26, [sp 496; CHECK-APPLE: stp x25, x24, [sp 497; CHECK-APPLE: stp x23, x22, [sp 498; CHECK-APPLE: stp x21, x20, [sp 499; CHECK-APPLE: stp x29, x30, [sp 500; Save original arguments. 501; CHECK-APPLE: mov x23, x19 502; CHECK-APPLE: str x7, [sp, #16] 503; CHECK-APPLE: mov x24, x6 504; CHECK-APPLE: mov x25, x5 505; CHECK-APPLE: mov x26, x4 506; CHECK-APPLE: mov x27, x3 507; CHECK-APPLE: mov x28, x2 508; CHECK-APPLE: mov x21, x1 509; CHECK-APPLE: mov x22, x0 510; Setup call arguments. 511; CHECK-APPLE: orr w0, wzr, #0x1 512; CHECK-APPLE: orr w1, wzr, #0x2 513; CHECK-APPLE: orr w2, wzr, #0x3 514; CHECK-APPLE: orr w3, wzr, #0x4 515; CHECK-APPLE: mov w4, #5 516; CHECK-APPLE: orr w5, wzr, #0x6 517; CHECK-APPLE: orr w6, wzr, #0x7 518; CHECK-APPLE: orr w7, wzr, #0x8 519; CHECK-APPLE: mov x20, xzr 520; CHECK-APPLE: mov x19, xzr 521; CHECK-APPLE: bl _params_in_reg2 522; Store swifterror %error_ptr_ref. 523; CHECK-APPLE: str x19, [sp, #8] 524; Setup call arguments from original arguments. 525; CHECK-APPLE: mov x0, x22 526; CHECK-APPLE: mov x1, x21 527; CHECK-APPLE: mov x2, x28 528; CHECK-APPLE: mov x3, x27 529; CHECK-APPLE: mov x4, x26 530; CHECK-APPLE: mov x5, x25 531; CHECK-APPLE: mov x6, x24 532; CHECK-APPLE: ldp x7, x20, [sp, #16] 533; CHECK-APPLE: mov x19, x23 534; CHECK-APPLE: bl _params_and_return_in_reg2 535; Store return values. 536; CHECK-APPLE: mov x21, x0 537; CHECK-APPLE: mov x22, x1 538; CHECK-APPLE: mov x24, x2 539; CHECK-APPLE: mov x25, x3 540; CHECK-APPLE: mov x26, x4 541; CHECK-APPLE: mov x27, x5 542; CHECK-APPLE: mov x28, x6 543; CHECK-APPLE: mov x23, x7 544; Save swifterror %err. 545; CHECK-APPLE: str x19, [sp, #24] 546; Setup call. 547; CHECK-APPLE: orr w0, wzr, #0x1 548; CHECK-APPLE: orr w1, wzr, #0x2 549; CHECK-APPLE: orr w2, wzr, #0x3 550; CHECK-APPLE: orr w3, wzr, #0x4 551; CHECK-APPLE: mov w4, #5 552; CHECK-APPLE: orr w5, wzr, #0x6 553; CHECK-APPLE: orr w6, wzr, #0x7 554; CHECK-APPLE: orr w7, wzr, #0x8 555; CHECK-APPLE: mov x20, xzr 556; ... setup call with swiferror %error_ptr_ref. 557; CHECK-APPLE: ldr x19, [sp, #8] 558; CHECK-APPLE: bl _params_in_reg2 559; Restore return values for return from this function. 560; CHECK-APPLE: mov x0, x21 561; CHECK-APPLE: mov x1, x22 562; CHECK-APPLE: mov x2, x24 563; CHECK-APPLE: mov x3, x25 564; CHECK-APPLE: mov x4, x26 565; CHECK-APPLE: mov x5, x27 566; CHECK-APPLE: mov x6, x28 567; CHECK-APPLE: mov x7, x23 568; Restore swifterror %err and callee save registers. 569; CHECK-APPLE: ldp x19, x28, [sp, #24 570; CHECK-APPLE: ldp x29, x30, [sp 571; CHECK-APPLE: ldp x21, x20, [sp 572; CHECK-APPLE: ldp x23, x22, [sp 573; CHECK-APPLE: ldp x25, x24, [sp 574; CHECK-APPLE: ldp x27, x26, [sp 575; CHECK-APPLE: ret 576define swiftcc { i64, i64, i64, i64, i64, i64, i64, i64 } @params_and_return_in_reg(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) { 577 %error_ptr_ref = alloca swifterror %swift_error*, align 8 578 store %swift_error* null, %swift_error** %error_ptr_ref 579 call swiftcc void @params_in_reg2(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref) 580 %val = call swiftcc { i64, i64, i64, i64, i64, i64, i64, i64 } @params_and_return_in_reg2(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, i64 %7, i8* swiftself %8, %swift_error** nocapture swifterror %err) 581 call swiftcc void @params_in_reg2(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref) 582 ret { i64, i64, i64, i64, i64, i64, i64, i64 } %val 583} 584 585declare swiftcc { i64, i64, i64, i64, i64, i64, i64, i64 } @params_and_return_in_reg2(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) 586