brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.6 KiB · 5a19bcd Raw
232 lines · plain
1; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM2; RUN: llc -mtriple=x86_64-unknown-none -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM3; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs -stop-after=finalize-isel < %s | FileCheck %s --check-prefixes=MIR,ISEL4; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs -stop-after=kcfi < %s | FileCheck %s --check-prefixes=MIR,KCFI5 6; ASM:       .p2align 47; ASM:       .type __cfi_f1,@function8; ASM-LABEL: __cfi_f1:9; ASM-NEXT:    nop10; ASM-NEXT:    nop11; ASM-NEXT:    nop12; ASM-NEXT:    nop13; ASM-NEXT:    nop14; ASM-NEXT:    nop15; ASM-NEXT:    nop16; ASM-NEXT:    nop17; ASM-NEXT:    nop18; ASM-NEXT:    nop19; ASM-NEXT:    nop20; ASM-NEXT:    movl $12345678, %ecx21; ASM-LABEL: .Lcfi_func_end0:22; ASM-NEXT:  .size   __cfi_f1, .Lcfi_func_end0-__cfi_f123define void @f1(ptr noundef %x) !kcfi_type !1 {24; ASM-LABEL: f1:25; ASM:       # %bb.0:26; ASM:         movl $4282621618, %r10d # imm = 0xFF439EB227; ASM-NEXT:    addl -4(%rdi), %r10d28; ASM-NEXT:    je .Ltmp029; ASM-NEXT:  .Ltmp1:30; ASM-NEXT:    ud231; ASM-NEXT:    .section .kcfi_traps,"ao",@progbits,.text32; ASM-NEXT:  .Ltmp2:33; ASM-NEXT:    .long .Ltmp1-.Ltmp234; ASM-NEXT:    .text35; ASM-NEXT:  .Ltmp0:36; ASM-NEXT:    callq *%rdi37 38; MIR-LABEL: name: f139; MIR: body:40; ISEL: CALL64r %0, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, cfi-type 1234567841; KCFI:       BUNDLE{{.*}} {42; KCFI-NEXT:    KCFI_CHECK $rdi, 12345678, implicit-def $r10, implicit-def $r11, implicit-def $eflags43; KCFI-NEXT:    CALL64r killed $rdi, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp44; KCFI-NEXT:  }45  call void %x() [ "kcfi"(i32 12345678) ]46  ret void47}48 49; ASM-NOT: __cfi_f2:50define void @f2(ptr noundef %x) {51; ASM-LABEL: f2:52 53; MIR-LABEL: name: f254; MIR: body:55; ISEL: TCRETURNri64 %0, 0, csr_64, implicit $rsp, implicit $ssp, cfi-type 1234567856; KCFI:       BUNDLE{{.*}} {57; KCFI-NEXT:    KCFI_CHECK $rdi, 12345678, implicit-def $r10, implicit-def $r11, implicit-def $eflags58; KCFI-NEXT:    TAILJMPr64 killed $rdi, csr_64, implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp59; KCFI-NEXT:  }60  tail call void %x() [ "kcfi"(i32 12345678) ]61  ret void62}63 64; ASM-NOT: __cfi_f3:65define void @f3(ptr noundef %x) #0 {66; ASM-LABEL: f3:67; MIR-LABEL: name: f368; MIR: body:69; ISEL: CALL64pcrel32 &__llvm_retpoline_r11, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit killed $r11, cfi-type 1234567870; KCFI:       BUNDLE{{.*}} {71; KCFI-NEXT:    KCFI_CHECK $r11, 12345678, implicit-def $r10, implicit-def $r11, implicit-def $eflags72; KCFI-NEXT:    CALL64pcrel32 &__llvm_retpoline_r11, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit internal killed $r1173; KCFI-NEXT:  }74  call void %x() [ "kcfi"(i32 12345678) ]75  ret void76}77 78; ASM-NOT: __cfi_f4:79define void @f4(ptr noundef %x) #0 {80; ASM-LABEL: f4:81; MIR-LABEL: name: f482; MIR: body:83; ISEL: TCRETURNdi64 &__llvm_retpoline_r11, 0, csr_64, implicit $rsp, implicit $ssp, implicit killed $r11, cfi-type 1234567884; KCFI:       BUNDLE{{.*}} {85; KCFI-NEXT:    KCFI_CHECK $r11, 12345678, implicit-def $r10, implicit-def $r11, implicit-def $eflags86; KCFI-NEXT:    TAILJMPd64 &__llvm_retpoline_r11, csr_64, implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp, implicit internal killed $r1187; KCFI-NEXT:  }88  tail call void %x() [ "kcfi"(i32 12345678) ]89  ret void90}91 92;; Ensure we emit Value + 1 for unwanted values (e.g. endbr64 == 4196274163).93; ASM-LABEL: __cfi_f5:94; ASM: movl $4196274164, %ecx # imm = 0xFA1E0FF495define void @f5(ptr noundef %x) !kcfi_type !2 {96; ASM-LABEL: f5:97; ASM: movl $98693132, %r10d # imm = 0x5E1F00C98  tail call void %x() [ "kcfi"(i32 4196274163) ]99  ret void100}101 102;; Ensure we emit Value + 1 for unwanted values (e.g. -endbr64 == 98693133).103; ASM-LABEL: __cfi_f6:104; ASM: movl $98693134, %ecx # imm = 0x5E1F00E105define void @f6(ptr noundef %x) !kcfi_type !3 {106; ASM-LABEL: f6:107; ASM: movl $4196274162, %r10d # imm = 0xFA1E0FF2108  tail call void %x() [ "kcfi"(i32 98693133) ]109  ret void110}111 112@g = external local_unnamed_addr global ptr, align 8113 114define void @f7() {115; MIR-LABEL: name: f7116; MIR: body:117; ISEL: TCRETURNmi64 killed %0, 1, $noreg, 0, $noreg, 0, csr_64, implicit $rsp, implicit $ssp, cfi-type 12345678118; KCFI: $r11 = MOV64rm killed renamable $rax, 1, $noreg, 0, $noreg119; KCFI-NEXT:  BUNDLE{{.*}} {120; KCFI-NEXT:    KCFI_CHECK $r11, 12345678, implicit-def $r10, implicit-def $r11, implicit-def $eflags121; KCFI-NEXT:    TAILJMPr64 internal $r11, csr_64, implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp122; KCFI-NEXT:  }123  %1 = load ptr, ptr @g, align 8124  tail call void %1() [ "kcfi"(i32 12345678) ]125  ret void126}127 128define void @f8() {129; MIR-LABEL: name: f8130; MIR: body:131; ISEL: CALL64m killed %0, 1, $noreg, 0, $noreg, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, cfi-type 12345678132; KCFI: $r11 = MOV64rm killed renamable $rax, 1, $noreg, 0, $noreg133; KCFI-NEXT:  BUNDLE{{.*}} {134; KCFI-NEXT:    KCFI_CHECK $r11, 12345678, implicit-def $r10, implicit-def $r11, implicit-def $eflags135; KCFI-NEXT:    CALL64r internal $r11, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp136; KCFI-NEXT:  }137  %1 = load ptr, ptr @g, align 8138  call void %1() [ "kcfi"(i32 12345678) ]139  ret void140}141 142%struct.S9 = type { [10 x i64] }143 144;; Ensure that functions with large (e.g., greater than 8 bytes) arguments passed on the stack are assigned arity=7145; ASM-LABEL: __cfi_f9:146; ASM: movl	$199571451, %edi                # imm = 0xBE537FB147define dso_local void @f9(ptr noundef byval(%struct.S9) align 8 %s) !kcfi_type !4  {148entry:149  ret void150}151 152;; Ensure that functions with fewer than 7 register arguments and no stack arguments are assigned arity<7153; ASM-LABEL: __cfi_f10:154; ASM: movl	$1046421190, %esi               # imm = 0x3E5F1EC6155define dso_local void @f10(i32 noundef %v1, i32 noundef %v2, i32 noundef %v3, i32 noundef %v4, i32 noundef %v5, i32 noundef %v6) #0 !kcfi_type !5 {156entry:157  %v1.addr = alloca i32, align 4158  %v2.addr = alloca i32, align 4159  %v3.addr = alloca i32, align 4160  %v4.addr = alloca i32, align 4161  %v5.addr = alloca i32, align 4162  %v6.addr = alloca i32, align 4163  store i32 %v1, ptr %v1.addr, align 4164  store i32 %v2, ptr %v2.addr, align 4165  store i32 %v3, ptr %v3.addr, align 4166  store i32 %v4, ptr %v4.addr, align 4167  store i32 %v5, ptr %v5.addr, align 4168  store i32 %v6, ptr %v6.addr, align 4169  ret void170}171 172;; Ensure that functions with greater than 7 register arguments and no stack arguments are assigned arity=7173; ASM-LABEL: __cfi_f11:174; ASM: movl	$1342488295, %edi               # imm = 0x5004BEE7175define dso_local void @f11(i32 noundef %v1, i32 noundef %v2, i32 noundef %v3, i32 noundef %v4, i32 noundef %v5, i32 noundef %v6, i32 noundef %v7, i32 noundef %v8) #0 !kcfi_type !6 {176entry:177  %v1.addr = alloca i32, align 4178  %v2.addr = alloca i32, align 4179  %v3.addr = alloca i32, align 4180  %v4.addr = alloca i32, align 4181  %v5.addr = alloca i32, align 4182  %v6.addr = alloca i32, align 4183  %v7.addr = alloca i32, align 4184  %v8.addr = alloca i32, align 4185  store i32 %v1, ptr %v1.addr, align 4186  store i32 %v2, ptr %v2.addr, align 4187  store i32 %v3, ptr %v3.addr, align 4188  store i32 %v4, ptr %v4.addr, align 4189  store i32 %v5, ptr %v5.addr, align 4190  store i32 %v6, ptr %v6.addr, align 4191  store i32 %v7, ptr %v7.addr, align 4192  store i32 %v8, ptr %v8.addr, align 4193  ret void194}195 196;; Ensure that floating-point values are not counted toward the arity197; ASM-LABEL: __cfi_f12:198; ASM: movl $2253188362, %ebp199define dso_local void @f12(i32 noundef %v1, i32 noundef %v2, float noundef %v3, double noundef %v4, float noundef %v5, i32 noundef %v6, i32 noundef %v7, i32 noundef %v8) #0 !kcfi_type !7 {200entry:201  %v1.addr = alloca i32, align 4202  %v2.addr = alloca i32, align 4203  %v3.addr = alloca float, align 4204  %v4.addr = alloca double, align 4205  %v5.addr = alloca float, align 4206  %v6.addr = alloca i32, align 4207  %v7.addr = alloca i32, align 4208  %v8.addr = alloca i32, align 4209  store i32 %v1, ptr %v1.addr, align 4210  store i32 %v2, ptr %v2.addr, align 4211  store float %v3, ptr %v3.addr, align 4212  store double %v4, ptr %v4.addr, align 4213  store float %v5, ptr %v5.addr, align 4214  store i32 %v6, ptr %v6.addr, align 4215  store i32 %v7, ptr %v7.addr, align 4216  store i32 %v8, ptr %v8.addr, align 4217  ret void218}219 220attributes #0 = { "target-features"="+retpoline-indirect-branches,+retpoline-indirect-calls" }221 222!llvm.module.flags = !{!0, !8}223!0 = !{i32 4, !"kcfi", i32 1}224!1 = !{i32 12345678}225!2 = !{i32 4196274163}226!3 = !{i32 98693133}227!4 = !{i32 199571451}228!5 = !{i32 1046421190}229!6 = !{i32 1342488295}230!7 = !{i32 2253188362}231!8 = !{i32 4, !"kcfi-arity", i32 1}232