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