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