1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -verify-machineinstrs -mtriple=aarch64-unknown-linux < %s | FileCheck %s 3; RUN: llc -verify-machineinstrs -mtriple=arm64-apple-ios < %s | FileCheck %s --check-prefix=CHECK-APPLE 4 5; Check CSR split can work properly for tests below. 6 7@a = common dso_local local_unnamed_addr global i32 0, align 4 8 9define dso_local signext i32 @test1(i32* %b) local_unnamed_addr { 10; CHECK-LABEL: test1: 11; CHECK: // %bb.0: // %entry 12; CHECK-NEXT: stp x30, x19, [sp, #-16]! // 16-byte Folded Spill 13; CHECK-NEXT: .cfi_def_cfa_offset 16 14; CHECK-NEXT: .cfi_offset w19, -8 15; CHECK-NEXT: .cfi_offset w30, -16 16; CHECK-NEXT: adrp x8, a 17; CHECK-NEXT: ldrsw x8, [x8, :lo12:a] 18; CHECK-NEXT: cmp x8, x0 19; CHECK-NEXT: b.eq .LBB0_2 20; CHECK-NEXT: // %bb.1: // %if.end 21; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload 22; CHECK-NEXT: ret 23; CHECK-NEXT: .LBB0_2: // %if.then 24; CHECK-NEXT: mov x19, x0 25; CHECK-NEXT: bl callVoid 26; CHECK-NEXT: mov x0, x19 27; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload 28; CHECK-NEXT: b callNonVoid 29; 30; CHECK-APPLE-LABEL: test1: 31; CHECK-APPLE: ; %bb.0: ; %entry 32; CHECK-APPLE-NEXT: stp x20, x19, [sp, #-32]! ; 16-byte Folded Spill 33; CHECK-APPLE-NEXT: stp x29, x30, [sp, #16] ; 16-byte Folded Spill 34; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 32 35; CHECK-APPLE-NEXT: .cfi_offset w30, -8 36; CHECK-APPLE-NEXT: .cfi_offset w29, -16 37; CHECK-APPLE-NEXT: .cfi_offset w19, -24 38; CHECK-APPLE-NEXT: .cfi_offset w20, -32 39; CHECK-APPLE-NEXT: Lloh0: 40; CHECK-APPLE-NEXT: adrp x8, _a@PAGE 41; CHECK-APPLE-NEXT: Lloh1: 42; CHECK-APPLE-NEXT: ldrsw x8, [x8, _a@PAGEOFF] 43; CHECK-APPLE-NEXT: cmp x8, x0 44; CHECK-APPLE-NEXT: b.eq LBB0_2 45; CHECK-APPLE-NEXT: ; %bb.1: ; %if.end 46; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload 47; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload 48; CHECK-APPLE-NEXT: ret 49; CHECK-APPLE-NEXT: LBB0_2: ; %if.then 50; CHECK-APPLE-NEXT: mov x19, x0 51; CHECK-APPLE-NEXT: bl _callVoid 52; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload 53; CHECK-APPLE-NEXT: mov x0, x19 54; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload 55; CHECK-APPLE-NEXT: b _callNonVoid 56; CHECK-APPLE-NEXT: .loh AdrpLdr Lloh0, Lloh1 57entry: 58 %0 = load i32, i32* @a, align 4, !tbaa !2 59 %conv = sext i32 %0 to i64 60 %1 = inttoptr i64 %conv to i32* 61 %cmp = icmp eq i32* %1, %b 62 br i1 %cmp, label %if.then, label %if.end 63 64if.then: ; preds = %entry 65 %call = tail call signext i32 bitcast (i32 (...)* @callVoid to i32 ()*)() 66 %call2 = tail call signext i32 @callNonVoid(i32* %b) 67 br label %if.end 68 69if.end: ; preds = %if.then, %entry 70 %retval.0 = phi i32 [ %call2, %if.then ], [ undef, %entry ] 71 ret i32 %retval.0 72} 73 74declare signext i32 @callVoid(...) local_unnamed_addr 75 76declare signext i32 @callNonVoid(i32*) local_unnamed_addr 77 78define dso_local signext i32 @test2(i32* %p1) local_unnamed_addr { 79; CHECK-LABEL: test2: 80; CHECK: // %bb.0: // %entry 81; CHECK-NEXT: stp x30, x19, [sp, #-16]! // 16-byte Folded Spill 82; CHECK-NEXT: .cfi_def_cfa_offset 16 83; CHECK-NEXT: .cfi_offset w19, -8 84; CHECK-NEXT: .cfi_offset w30, -16 85; CHECK-NEXT: cbz x0, .LBB1_2 86; CHECK-NEXT: // %bb.1: // %if.end 87; CHECK-NEXT: adrp x8, a 88; CHECK-NEXT: ldrsw x8, [x8, :lo12:a] 89; CHECK-NEXT: mov x19, x0 90; CHECK-NEXT: cmp x8, x0 91; CHECK-NEXT: b.eq .LBB1_3 92; CHECK-NEXT: .LBB1_2: // %return 93; CHECK-NEXT: mov w0, wzr 94; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload 95; CHECK-NEXT: ret 96; CHECK-NEXT: .LBB1_3: // %if.then2 97; CHECK-NEXT: bl callVoid 98; CHECK-NEXT: mov x0, x19 99; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload 100; CHECK-NEXT: b callNonVoid 101; 102; CHECK-APPLE-LABEL: test2: 103; CHECK-APPLE: ; %bb.0: ; %entry 104; CHECK-APPLE-NEXT: stp x20, x19, [sp, #-32]! ; 16-byte Folded Spill 105; CHECK-APPLE-NEXT: stp x29, x30, [sp, #16] ; 16-byte Folded Spill 106; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 32 107; CHECK-APPLE-NEXT: .cfi_offset w30, -8 108; CHECK-APPLE-NEXT: .cfi_offset w29, -16 109; CHECK-APPLE-NEXT: .cfi_offset w19, -24 110; CHECK-APPLE-NEXT: .cfi_offset w20, -32 111; CHECK-APPLE-NEXT: cbz x0, LBB1_2 112; CHECK-APPLE-NEXT: ; %bb.1: ; %if.end 113; CHECK-APPLE-NEXT: Lloh2: 114; CHECK-APPLE-NEXT: adrp x8, _a@PAGE 115; CHECK-APPLE-NEXT: Lloh3: 116; CHECK-APPLE-NEXT: ldrsw x8, [x8, _a@PAGEOFF] 117; CHECK-APPLE-NEXT: mov x19, x0 118; CHECK-APPLE-NEXT: cmp x8, x0 119; CHECK-APPLE-NEXT: b.eq LBB1_3 120; CHECK-APPLE-NEXT: LBB1_2: ; %return 121; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload 122; CHECK-APPLE-NEXT: mov w0, wzr 123; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload 124; CHECK-APPLE-NEXT: ret 125; CHECK-APPLE-NEXT: LBB1_3: ; %if.then2 126; CHECK-APPLE-NEXT: bl _callVoid 127; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload 128; CHECK-APPLE-NEXT: mov x0, x19 129; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload 130; CHECK-APPLE-NEXT: b _callNonVoid 131; CHECK-APPLE-NEXT: .loh AdrpLdr Lloh2, Lloh3 132entry: 133 %tobool = icmp eq i32* %p1, null 134 br i1 %tobool, label %return, label %if.end 135 136if.end: ; preds = %entry 137 %0 = load i32, i32* @a, align 4, !tbaa !2 138 %conv = sext i32 %0 to i64 139 %1 = inttoptr i64 %conv to i32* 140 %cmp = icmp eq i32* %1, %p1 141 br i1 %cmp, label %if.then2, label %return 142 143if.then2: ; preds = %if.end 144 %call = tail call signext i32 bitcast (i32 (...)* @callVoid to i32 ()*)() 145 %call3 = tail call signext i32 @callNonVoid(i32* nonnull %p1) 146 br label %return 147 148return: ; preds = %if.end, %entry, %if.then2 149 %retval.0 = phi i32 [ %call3, %if.then2 ], [ 0, %entry ], [ 0, %if.end ] 150 ret i32 %retval.0 151} 152 153 154define dso_local i8* @test3(i8** nocapture %p1, i8 zeroext %p2) local_unnamed_addr { 155; CHECK-LABEL: test3: 156; CHECK: // %bb.0: // %entry 157; CHECK-NEXT: str x30, [sp, #-32]! // 8-byte Folded Spill 158; CHECK-NEXT: stp x20, x19, [sp, #16] // 16-byte Folded Spill 159; CHECK-NEXT: .cfi_def_cfa_offset 32 160; CHECK-NEXT: .cfi_offset w19, -8 161; CHECK-NEXT: .cfi_offset w20, -16 162; CHECK-NEXT: .cfi_offset w30, -32 163; CHECK-NEXT: ldr x19, [x0] 164; CHECK-NEXT: cbz x19, .LBB2_2 165; CHECK-NEXT: // %bb.1: // %land.rhs 166; CHECK-NEXT: mov x20, x0 167; CHECK-NEXT: mov x0, x19 168; CHECK-NEXT: bl bar 169; CHECK-NEXT: str x0, [x20] 170; CHECK-NEXT: .LBB2_2: // %land.end 171; CHECK-NEXT: mov x0, x19 172; CHECK-NEXT: ldp x20, x19, [sp, #16] // 16-byte Folded Reload 173; CHECK-NEXT: ldr x30, [sp], #32 // 8-byte Folded Reload 174; CHECK-NEXT: ret 175; 176; CHECK-APPLE-LABEL: test3: 177; CHECK-APPLE: ; %bb.0: ; %entry 178; CHECK-APPLE-NEXT: stp x20, x19, [sp, #-32]! ; 16-byte Folded Spill 179; CHECK-APPLE-NEXT: stp x29, x30, [sp, #16] ; 16-byte Folded Spill 180; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 32 181; CHECK-APPLE-NEXT: .cfi_offset w30, -8 182; CHECK-APPLE-NEXT: .cfi_offset w29, -16 183; CHECK-APPLE-NEXT: .cfi_offset w19, -24 184; CHECK-APPLE-NEXT: .cfi_offset w20, -32 185; CHECK-APPLE-NEXT: ldr x19, [x0] 186; CHECK-APPLE-NEXT: cbz x19, LBB2_2 187; CHECK-APPLE-NEXT: ; %bb.1: ; %land.rhs 188; CHECK-APPLE-NEXT: mov x20, x0 189; CHECK-APPLE-NEXT: mov x0, x19 190; CHECK-APPLE-NEXT: bl _bar 191; CHECK-APPLE-NEXT: str x0, [x20] 192; CHECK-APPLE-NEXT: LBB2_2: ; %land.end 193; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload 194; CHECK-APPLE-NEXT: mov x0, x19 195; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload 196; CHECK-APPLE-NEXT: ret 197entry: 198 %0 = load i8*, i8** %p1, align 8, !tbaa !6 199 %tobool = icmp eq i8* %0, null 200 br i1 %tobool, label %land.end, label %land.rhs 201 202land.rhs: ; preds = %entry 203 %call = tail call i8* @bar(i8* nonnull %0, i8 zeroext %p2) 204 store i8* %call, i8** %p1, align 8, !tbaa !6 205 br label %land.end 206 207land.end: ; preds = %entry, %land.rhs 208 ret i8* %0 209} 210 211declare i8* @bar(i8*, i8 zeroext) local_unnamed_addr 212 213 214!llvm.module.flags = !{!0} 215!llvm.ident = !{!1} 216 217!0 = !{i32 1, !"wchar_size", i32 4} 218!1 = !{!"clang version 10.0.0 (trunk 367381) (llvm/trunk 367388)"} 219!2 = !{!3, !3, i64 0} 220!3 = !{!"int", !4, i64 0} 221!4 = !{!"omnipotent char", !5, i64 0} 222!5 = !{!"Simple C/C++ TBAA"} 223!6 = !{!7, !7, i64 0} 224!7 = !{!"any pointer", !4, i64 0} 225