139 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 62; RUN: llc -mtriple=armv7-linux-gnueabi -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM3; RUN: llc -mtriple=armv7-linux-gnueabi -verify-machineinstrs -stop-after=finalize-isel < %s | FileCheck %s --check-prefixes=MIR,ISEL4; RUN: llc -mtriple=armv7-linux-gnueabi -verify-machineinstrs -stop-after=kcfi < %s | FileCheck %s --check-prefixes=MIR,KCFI5 6; MIR checks for all functions (grouped here to prevent update_llc_test_checks.py from removing them)7 8; MIR-LABEL: name: f19; MIR: body:10 11; ISEL: BLX %0, csr_aapcs,{{.*}} cfi-type 1234567812 13; KCFI: BUNDLE{{.*}} {14; KCFI-NEXT: KCFI_CHECK_ARM $r0, 1234567815; KCFI-NEXT: BLX killed $r0, csr_aapcs,{{.*}}16; KCFI-NEXT: }17 18; MIR-LABEL: name: f219; MIR: body:20 21; ISEL: TCRETURNri %0, 0, csr_aapcs, implicit $sp, cfi-type 1234567822 23; KCFI: BUNDLE{{.*}} {24; KCFI-NEXT: KCFI_CHECK_ARM $r0, 1234567825; KCFI-NEXT: TAILJMPr killed $r0, csr_aapcs, implicit $sp, implicit $sp26; KCFI-NEXT: }27 28; ASM: .long 1234567829define void @f1(ptr noundef %x) !kcfi_type !1 {30; ASM-LABEL: f1:31; ASM: @ %bb.0:32; ASM-NEXT: .save {r11, lr}33; ASM-NEXT: push {r11, lr}34; ASM-NEXT: bic r12, r0, #135; ASM-NEXT: ldr r12, [r12, #-4]36; ASM-NEXT: eor r12, r12, #7837; ASM-NEXT: eor r12, r12, #2483238; ASM-NEXT: eor r12, r12, #1232076839; ASM-NEXT: eors r12, r12, #040; ASM-NEXT: beq .Ltmp041; ASM-NEXT: udf #3376042; ASM-NEXT: .Ltmp0:43; ASM-NEXT: blx r044; ASM-NEXT: pop {r11, pc}45 46 call void %x() [ "kcfi"(i32 12345678) ]47 ret void48}49 50; Test with tail call51define void @f2(ptr noundef %x) !kcfi_type !1 {52; ASM-LABEL: f2:53; ASM: @ %bb.0:54; ASM-NEXT: bic r12, r0, #155; ASM-NEXT: ldr r12, [r12, #-4]56; ASM-NEXT: eor r12, r12, #7857; ASM-NEXT: eor r12, r12, #2483258; ASM-NEXT: eor r12, r12, #1232076859; ASM-NEXT: eors r12, r12, #060; ASM-NEXT: beq .Ltmp161; ASM-NEXT: udf #3376062; ASM-NEXT: .Ltmp1:63; ASM-NEXT: bx r064 65 tail call void %x() [ "kcfi"(i32 12345678) ]66 ret void67}68 69; Test r3 spill/reload when target is r12 and r3 is a call argument.70; With 5+ arguments (target + 4 args), r0-r3 are all used for arguments,71; forcing r3 to be spilled when we need it as scratch register.72define void @f3_r3_spill(ptr noundef %target, i32 %a, i32 %b, i32 %c, i32 %d) !kcfi_type !1 {73; ASM-LABEL: f3_r3_spill:74; ASM: @ %bb.0:75; ASM-NEXT: .save {r11, lr}76; ASM-NEXT: push {r11, lr}77; ASM-NEXT: mov lr, r378; ASM-NEXT: ldr r3, [sp, #8]79; ASM-NEXT: mov r12, r080; ASM-NEXT: mov r0, r181; ASM-NEXT: mov r1, r282; ASM-NEXT: mov r2, lr83; ASM-NEXT: stmdb sp!, {r3}84; ASM-NEXT: bic r3, r12, #185; ASM-NEXT: ldr r3, [r3, #-4]86; ASM-NEXT: eor r3, r3, #7887; ASM-NEXT: eor r3, r3, #2483288; ASM-NEXT: eor r3, r3, #1232076889; ASM-NEXT: eors r3, r3, #090; ASM-NEXT: ldm sp!, {r3}91; ASM-NEXT: beq .Ltmp292; ASM-NEXT: udf #3377293; ASM-NEXT: .Ltmp2:94; ASM-NEXT: blx r1295; ASM-NEXT: pop {r11, pc}96; Arguments: r0=%target, r1=%a, r2=%b, r3=%c, [sp]=%d97; Call needs: r0=%a, r1=%b, r2=%c, r3=%d, target in r1298; Compiler shuffles arguments into place, saving r3 (c) in lr, loading d from stack99; r3 is live as 4th argument, so push it before KCFI check100; Restore r3 immediately after comparison, before branch101 call void %target(i32 %a, i32 %b, i32 %c, i32 %d) [ "kcfi"(i32 12345678) ]102 ret void103}104 105; Test with 3 arguments - r3 not live, target in r12, so r3 used as scratch without spilling106define void @f4_r3_unused(ptr noundef %target, i32 %a, i32 %b) !kcfi_type !1 {107; ASM-LABEL: f4_r3_unused:108; ASM: @ %bb.0:109; ASM-NEXT: .save {r11, lr}110; ASM-NEXT: push {r11, lr}111; ASM-NEXT: mov r3, r0112; ASM-NEXT: mov r0, r1113; ASM-NEXT: mov r1, r2114; ASM-NEXT: bic r12, r3, #1115; ASM-NEXT: ldr r12, [r12, #-4]116; ASM-NEXT: eor r12, r12, #78117; ASM-NEXT: eor r12, r12, #24832118; ASM-NEXT: eor r12, r12, #12320768119; ASM-NEXT: eors r12, r12, #0120; ASM-NEXT: beq .Ltmp3121; ASM-NEXT: udf #33763122; ASM-NEXT: .Ltmp3:123; ASM-NEXT: blx r3124; ASM-NEXT: pop {r11, pc}125; Only 3 arguments total, so r3 is not used as call argument126; Compiler puts target→r3, a→r0, b→r1127; r3 is the target, so we use r12 as scratch (no spill needed)128 call void %target(i32 %a, i32 %b) [ "kcfi"(i32 12345678) ]129 ret void130}131 132!llvm.module.flags = !{!0}133!0 = !{i32 4, !"kcfi", i32 1}134!1 = !{i32 12345678}135;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:136; ISEL: {{.*}}137; KCFI: {{.*}}138; MIR: {{.*}}139