1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown-linux < %s | FileCheck %s 3; RUN: llc -verify-machineinstrs -mtriple=i386-unknown-linux < %s | FileCheck %s --check-prefix=CHECK-32BIT 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: pushq %rbx 13; CHECK-NEXT: .cfi_def_cfa_offset 16 14; CHECK-NEXT: .cfi_offset %rbx, -16 15; CHECK-NEXT: movslq {{.*}}(%rip), %rax 16; CHECK-NEXT: cmpq %rdi, %rax 17; CHECK-NEXT: je .LBB0_2 18; CHECK-NEXT: # %bb.1: # %if.end 19; CHECK-NEXT: popq %rbx 20; CHECK-NEXT: .cfi_def_cfa_offset 8 21; CHECK-NEXT: retq 22; CHECK-NEXT: .LBB0_2: # %if.then 23; CHECK-NEXT: .cfi_def_cfa_offset 16 24; CHECK-NEXT: movq %rdi, %rbx 25; CHECK-NEXT: callq callVoid@PLT 26; CHECK-NEXT: movq %rbx, %rdi 27; CHECK-NEXT: popq %rbx 28; CHECK-NEXT: .cfi_def_cfa_offset 8 29; CHECK-NEXT: jmp callNonVoid@PLT # TAILCALL 30; 31; CHECK-32BIT-LABEL: test1: 32; CHECK-32BIT: # %bb.0: # %entry 33; CHECK-32BIT-NEXT: subl $12, %esp 34; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16 35; CHECK-32BIT-NEXT: movl {{[0-9]+}}(%esp), %eax 36; CHECK-32BIT-NEXT: cmpl %eax, a 37; CHECK-32BIT-NEXT: je .LBB0_2 38; CHECK-32BIT-NEXT: # %bb.1: # %if.end 39; CHECK-32BIT-NEXT: addl $12, %esp 40; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4 41; CHECK-32BIT-NEXT: retl 42; CHECK-32BIT-NEXT: .LBB0_2: # %if.then 43; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16 44; CHECK-32BIT-NEXT: calll callVoid@PLT 45; CHECK-32BIT-NEXT: addl $12, %esp 46; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4 47; CHECK-32BIT-NEXT: jmp callNonVoid@PLT # TAILCALL 48entry: 49 %0 = load i32, i32* @a, align 4, !tbaa !2 50 %conv = sext i32 %0 to i64 51 %1 = inttoptr i64 %conv to i32* 52 %cmp = icmp eq i32* %1, %b 53 br i1 %cmp, label %if.then, label %if.end 54 55if.then: ; preds = %entry 56 %call = tail call signext i32 bitcast (i32 (...)* @callVoid to i32 ()*)() 57 %call2 = tail call signext i32 @callNonVoid(i32* %b) 58 br label %if.end 59 60if.end: ; preds = %if.then, %entry 61 %retval.0 = phi i32 [ %call2, %if.then ], [ undef, %entry ] 62 ret i32 %retval.0 63} 64 65declare signext i32 @callVoid(...) local_unnamed_addr 66 67declare signext i32 @callNonVoid(i32*) local_unnamed_addr 68 69define dso_local signext i32 @test2(i32* %p1) local_unnamed_addr { 70; CHECK-LABEL: test2: 71; CHECK: # %bb.0: # %entry 72; CHECK-NEXT: pushq %rbx 73; CHECK-NEXT: .cfi_def_cfa_offset 16 74; CHECK-NEXT: .cfi_offset %rbx, -16 75; CHECK-NEXT: testq %rdi, %rdi 76; CHECK-NEXT: je .LBB1_2 77; CHECK-NEXT: # %bb.1: # %if.end 78; CHECK-NEXT: movq %rdi, %rbx 79; CHECK-NEXT: movslq {{.*}}(%rip), %rax 80; CHECK-NEXT: cmpq %rdi, %rax 81; CHECK-NEXT: je .LBB1_3 82; CHECK-NEXT: .LBB1_2: # %return 83; CHECK-NEXT: xorl %eax, %eax 84; CHECK-NEXT: popq %rbx 85; CHECK-NEXT: .cfi_def_cfa_offset 8 86; CHECK-NEXT: retq 87; CHECK-NEXT: .LBB1_3: # %if.then2 88; CHECK-NEXT: .cfi_def_cfa_offset 16 89; CHECK-NEXT: callq callVoid@PLT 90; CHECK-NEXT: movq %rbx, %rdi 91; CHECK-NEXT: popq %rbx 92; CHECK-NEXT: .cfi_def_cfa_offset 8 93; CHECK-NEXT: jmp callNonVoid@PLT # TAILCALL 94; 95; CHECK-32BIT-LABEL: test2: 96; CHECK-32BIT: # %bb.0: # %entry 97; CHECK-32BIT-NEXT: subl $12, %esp 98; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16 99; CHECK-32BIT-NEXT: movl {{[0-9]+}}(%esp), %eax 100; CHECK-32BIT-NEXT: testl %eax, %eax 101; CHECK-32BIT-NEXT: je .LBB1_2 102; CHECK-32BIT-NEXT: # %bb.1: # %if.end 103; CHECK-32BIT-NEXT: cmpl %eax, a 104; CHECK-32BIT-NEXT: je .LBB1_3 105; CHECK-32BIT-NEXT: .LBB1_2: # %return 106; CHECK-32BIT-NEXT: xorl %eax, %eax 107; CHECK-32BIT-NEXT: addl $12, %esp 108; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4 109; CHECK-32BIT-NEXT: retl 110; CHECK-32BIT-NEXT: .LBB1_3: # %if.then2 111; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16 112; CHECK-32BIT-NEXT: calll callVoid@PLT 113; CHECK-32BIT-NEXT: addl $12, %esp 114; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4 115; CHECK-32BIT-NEXT: jmp callNonVoid@PLT # TAILCALL 116entry: 117 %tobool = icmp eq i32* %p1, null 118 br i1 %tobool, label %return, label %if.end 119 120if.end: ; preds = %entry 121 %0 = load i32, i32* @a, align 4, !tbaa !2 122 %conv = sext i32 %0 to i64 123 %1 = inttoptr i64 %conv to i32* 124 %cmp = icmp eq i32* %1, %p1 125 br i1 %cmp, label %if.then2, label %return 126 127if.then2: ; preds = %if.end 128 %call = tail call signext i32 bitcast (i32 (...)* @callVoid to i32 ()*)() 129 %call3 = tail call signext i32 @callNonVoid(i32* nonnull %p1) 130 br label %return 131 132return: ; preds = %if.end, %entry, %if.then2 133 %retval.0 = phi i32 [ %call3, %if.then2 ], [ 0, %entry ], [ 0, %if.end ] 134 ret i32 %retval.0 135} 136 137 138define dso_local i8* @test3(i8** nocapture %p1, i8 zeroext %p2) local_unnamed_addr { 139; CHECK-LABEL: test3: 140; CHECK: # %bb.0: # %entry 141; CHECK-NEXT: pushq %r14 142; CHECK-NEXT: .cfi_def_cfa_offset 16 143; CHECK-NEXT: pushq %rbx 144; CHECK-NEXT: .cfi_def_cfa_offset 24 145; CHECK-NEXT: pushq %rax 146; CHECK-NEXT: .cfi_def_cfa_offset 32 147; CHECK-NEXT: .cfi_offset %rbx, -24 148; CHECK-NEXT: .cfi_offset %r14, -16 149; CHECK-NEXT: movq (%rdi), %rbx 150; CHECK-NEXT: testq %rbx, %rbx 151; CHECK-NEXT: je .LBB2_2 152; CHECK-NEXT: # %bb.1: # %land.rhs 153; CHECK-NEXT: movq %rdi, %r14 154; CHECK-NEXT: movzbl %sil, %esi 155; CHECK-NEXT: movq %rbx, %rdi 156; CHECK-NEXT: callq bar@PLT 157; CHECK-NEXT: movq %rax, (%r14) 158; CHECK-NEXT: .LBB2_2: # %land.end 159; CHECK-NEXT: movq %rbx, %rax 160; CHECK-NEXT: addq $8, %rsp 161; CHECK-NEXT: .cfi_def_cfa_offset 24 162; CHECK-NEXT: popq %rbx 163; CHECK-NEXT: .cfi_def_cfa_offset 16 164; CHECK-NEXT: popq %r14 165; CHECK-NEXT: .cfi_def_cfa_offset 8 166; CHECK-NEXT: retq 167; 168; CHECK-32BIT-LABEL: test3: 169; CHECK-32BIT: # %bb.0: # %entry 170; CHECK-32BIT-NEXT: pushl %edi 171; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 8 172; CHECK-32BIT-NEXT: pushl %esi 173; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 12 174; CHECK-32BIT-NEXT: pushl %eax 175; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16 176; CHECK-32BIT-NEXT: .cfi_offset %esi, -12 177; CHECK-32BIT-NEXT: .cfi_offset %edi, -8 178; CHECK-32BIT-NEXT: movl {{[0-9]+}}(%esp), %edi 179; CHECK-32BIT-NEXT: movl (%edi), %esi 180; CHECK-32BIT-NEXT: testl %esi, %esi 181; CHECK-32BIT-NEXT: je .LBB2_2 182; CHECK-32BIT-NEXT: # %bb.1: # %land.rhs 183; CHECK-32BIT-NEXT: subl $8, %esp 184; CHECK-32BIT-NEXT: .cfi_adjust_cfa_offset 8 185; CHECK-32BIT-NEXT: movzbl {{[0-9]+}}(%esp), %eax 186; CHECK-32BIT-NEXT: pushl %eax 187; CHECK-32BIT-NEXT: .cfi_adjust_cfa_offset 4 188; CHECK-32BIT-NEXT: pushl %esi 189; CHECK-32BIT-NEXT: .cfi_adjust_cfa_offset 4 190; CHECK-32BIT-NEXT: calll bar@PLT 191; CHECK-32BIT-NEXT: addl $16, %esp 192; CHECK-32BIT-NEXT: .cfi_adjust_cfa_offset -16 193; CHECK-32BIT-NEXT: movl %eax, (%edi) 194; CHECK-32BIT-NEXT: .LBB2_2: # %land.end 195; CHECK-32BIT-NEXT: movl %esi, %eax 196; CHECK-32BIT-NEXT: addl $4, %esp 197; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 12 198; CHECK-32BIT-NEXT: popl %esi 199; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 8 200; CHECK-32BIT-NEXT: popl %edi 201; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4 202; CHECK-32BIT-NEXT: retl 203entry: 204 %0 = load i8*, i8** %p1, align 8, !tbaa !6 205 %tobool = icmp eq i8* %0, null 206 br i1 %tobool, label %land.end, label %land.rhs 207 208land.rhs: ; preds = %entry 209 %call = tail call i8* @bar(i8* nonnull %0, i8 zeroext %p2) 210 store i8* %call, i8** %p1, align 8, !tbaa !6 211 br label %land.end 212 213land.end: ; preds = %entry, %land.rhs 214 ret i8* %0 215} 216 217declare i8* @bar(i8*, i8 zeroext) local_unnamed_addr 218 219 220!llvm.module.flags = !{!0} 221!llvm.ident = !{!1} 222 223!0 = !{i32 1, !"wchar_size", i32 4} 224!1 = !{!"clang version 10.0.0 (trunk 367381) (llvm/trunk 367388)"} 225!2 = !{!3, !3, i64 0} 226!3 = !{!"int", !4, i64 0} 227!4 = !{!"omnipotent char", !5, i64 0} 228!5 = !{!"Simple C/C++ TBAA"} 229!6 = !{!7, !7, i64 0} 230!7 = !{!"any pointer", !4, i64 0} 231