llvm/llvm/test/CodeGen/ARM/machine-outliner-calls.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=arm-- -run-pass=prologepilog -run-pass=machine-outliner \
# RUN: -verify-machineinstrs %s -o - | FileCheck %s

--- |
  define void @outline_call_arm() #0 { ret void }
  define void @outline_call_thumb() #1 { ret void }
  define void @outline_call_tailcall_arm() #0 { ret void }
  define void @outline_call_tailcall_thumb() #1 { ret void }
  define void @outline_call_KO_mcount() #0 { ret void }
  define void @bar() #0 { ret void }
  declare void @"\01mcount"()

  attributes #0 = { minsize optsize }
  attributes #1 = { minsize optsize "target-features"="+armv7-a,+thumb-mode" }
...
---

name:           outline_call_arm
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: outline_call_arm
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r4, $lr
  ; CHECK:   $sp = frame-setup STMDB_UPD $sp, 14 /* CC::al */, $noreg, killed $r4, killed $lr
  ; CHECK:   frame-setup CFI_INSTRUCTION def_cfa_offset 8
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $lr, -4
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $r4, -8
  ; CHECK:   BL @OUTLINED_FUNCTION_2
  ; CHECK: bb.1:
  ; CHECK:   BL @OUTLINED_FUNCTION_2
  ; CHECK: bb.2:
  ; CHECK:   BL @OUTLINED_FUNCTION_2
  ; CHECK: bb.3:
  ; CHECK:   BL @OUTLINED_FUNCTION_2
  ; CHECK: bb.4:
  ; CHECK:   BL @OUTLINED_FUNCTION_2
  ; CHECK: bb.5:
  ; CHECK:   $sp = frame-destroy LDMIA_UPD $sp, 14 /* CC::al */, $noreg, def $r4, def $lr
  ; CHECK:   BX_RET 14 /* CC::al */, $noreg
  bb.0:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
  bb.1:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
  bb.2:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
  bb.3:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
  bb.4:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
  bb.5:
    BX_RET 14, $noreg
...
---

name:           outline_call_thumb
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: outline_call_thumb
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r7, $lr
  ; CHECK:   $sp = frame-setup t2STMDB_UPD $sp, 14 /* CC::al */, $noreg, killed $r7, killed $lr
  ; CHECK:   frame-setup CFI_INSTRUCTION def_cfa_offset 8
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $lr, -4
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $r7, -8
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_4
  ; CHECK: bb.1:
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_4
  ; CHECK: bb.2:
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_4
  ; CHECK: bb.3:
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_4
  ; CHECK: bb.4:
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_4
  ; CHECK: bb.5:
  ; CHECK:   $sp = frame-destroy t2LDMIA_RET $sp, 14 /* CC::al */, $noreg, def $r7, def $pc
  bb.0:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
  bb.1:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
  bb.2:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
  bb.3:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
  bb.4:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
  bb.5:
    tBX_RET 14, $noreg
...
---

name:           outline_call_tailcall_arm
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: outline_call_tailcall_arm
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r4, $lr
  ; CHECK:   $sp = frame-setup STMDB_UPD $sp, 14 /* CC::al */, $noreg, killed $r4, killed $lr
  ; CHECK:   frame-setup CFI_INSTRUCTION def_cfa_offset 8
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $lr, -4
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $r4, -8
  ; CHECK:   BL @OUTLINED_FUNCTION_0
  ; CHECK: bb.1:
  ; CHECK:   BL @OUTLINED_FUNCTION_0
  ; CHECK: bb.2:
  ; CHECK:   BL @OUTLINED_FUNCTION_0
  ; CHECK: bb.3:
  ; CHECK:   BL @OUTLINED_FUNCTION_0
  ; CHECK: bb.4:
  ; CHECK:   $sp = frame-destroy LDMIA_UPD $sp, 14 /* CC::al */, $noreg, def $r4, def $lr
  ; CHECK:   BX_RET 14 /* CC::al */, $noreg
  bb.0:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 2, 14, $noreg, $noreg
    $r1 = MOVi 2, 14, $noreg, $noreg
    $r2 = MOVi 2, 14, $noreg, $noreg
    $r3 = MOVi 2, 14, $noreg, $noreg
    $r4 = MOVi 2, 14, $noreg, $noreg
    BL @bar, implicit-def dead $lr, implicit $sp
  bb.1:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 2, 14, $noreg, $noreg
    $r1 = MOVi 2, 14, $noreg, $noreg
    $r2 = MOVi 2, 14, $noreg, $noreg
    $r3 = MOVi 2, 14, $noreg, $noreg
    $r4 = MOVi 2, 14, $noreg, $noreg
    BL @bar, implicit-def dead $lr, implicit $sp
  bb.2:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 2, 14, $noreg, $noreg
    $r1 = MOVi 2, 14, $noreg, $noreg
    $r2 = MOVi 2, 14, $noreg, $noreg
    $r3 = MOVi 2, 14, $noreg, $noreg
    $r4 = MOVi 2, 14, $noreg, $noreg
    BL @bar, implicit-def dead $lr, implicit $sp
  bb.3:
    BL @bar, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 2, 14, $noreg, $noreg
    $r1 = MOVi 2, 14, $noreg, $noreg
    $r2 = MOVi 2, 14, $noreg, $noreg
    $r3 = MOVi 2, 14, $noreg, $noreg
    $r4 = MOVi 2, 14, $noreg, $noreg
    BL @bar, implicit-def dead $lr, implicit $sp
  bb.4:
    BX_RET 14, $noreg
...
---

name:           outline_call_tailcall_thumb
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: outline_call_tailcall_thumb
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r7, $lr
  ; CHECK:   $sp = frame-setup t2STMDB_UPD $sp, 14 /* CC::al */, $noreg, killed $r7, killed $lr
  ; CHECK:   frame-setup CFI_INSTRUCTION def_cfa_offset 8
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $lr, -4
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $r7, -8
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_3
  ; CHECK: bb.1:
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_3
  ; CHECK: bb.2:
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_3
  ; CHECK: bb.3:
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_3
  ; CHECK: bb.4:
  ; CHECK:   $sp = frame-destroy t2LDMIA_RET $sp, 14 /* CC::al */, $noreg, def $r7, def $pc
  bb.0:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 2, 14, $noreg, $noreg
    $r1 = t2MOVi 2, 14, $noreg, $noreg
    $r2 = t2MOVi 2, 14, $noreg, $noreg
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
  bb.1:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 2, 14, $noreg, $noreg
    $r1 = t2MOVi 2, 14, $noreg, $noreg
    $r2 = t2MOVi 2, 14, $noreg, $noreg
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
  bb.2:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 2, 14, $noreg, $noreg
    $r1 = t2MOVi 2, 14, $noreg, $noreg
    $r2 = t2MOVi 2, 14, $noreg, $noreg
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
  bb.3:
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
    $r0 = t2MOVi 2, 14, $noreg, $noreg
    $r1 = t2MOVi 2, 14, $noreg, $noreg
    $r2 = t2MOVi 2, 14, $noreg, $noreg
    tBL 14, $noreg, @bar, implicit-def dead $lr, implicit $sp
  bb.4:
    tBX_RET 14, $noreg
...
---

name:           outline_call_KO_mcount
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: outline_call_KO_mcount
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r4, $lr
  ; CHECK:   $sp = frame-setup STMDB_UPD $sp, 14 /* CC::al */, $noreg, killed $r4, killed $lr
  ; CHECK:   frame-setup CFI_INSTRUCTION def_cfa_offset 8
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $lr, -4
  ; CHECK:   frame-setup CFI_INSTRUCTION offset $r4, -8
  ; CHECK:   BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK: bb.1:
  ; CHECK:   BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK: bb.2:
  ; CHECK:   BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK: bb.3:
  ; CHECK:   BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK: bb.4:
  ; CHECK:   BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK: bb.5:
  ; CHECK:   $sp = frame-destroy LDMIA_UPD $sp, 14 /* CC::al */, $noreg, def $r4, def $lr
  ; CHECK:   BX_RET 14 /* CC::al */, $noreg
  bb.0:
    BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 3, 14, $noreg, $noreg
    $r1 = MOVi 3, 14, $noreg, $noreg
    $r2 = MOVi 3, 14, $noreg, $noreg
    $r3 = MOVi 3, 14, $noreg, $noreg
    $r4 = MOVi 3, 14, $noreg, $noreg
  bb.1:
    BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 3, 14, $noreg, $noreg
    $r1 = MOVi 3, 14, $noreg, $noreg
    $r2 = MOVi 3, 14, $noreg, $noreg
    $r3 = MOVi 3, 14, $noreg, $noreg
    $r4 = MOVi 3, 14, $noreg, $noreg
  bb.2:
    BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 3, 14, $noreg, $noreg
    $r1 = MOVi 3, 14, $noreg, $noreg
    $r2 = MOVi 3, 14, $noreg, $noreg
    $r3 = MOVi 3, 14, $noreg, $noreg
    $r4 = MOVi 3, 14, $noreg, $noreg
  bb.3:
    BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 3, 14, $noreg, $noreg
    $r1 = MOVi 3, 14, $noreg, $noreg
    $r2 = MOVi 3, 14, $noreg, $noreg
    $r3 = MOVi 3, 14, $noreg, $noreg
    $r4 = MOVi 3, 14, $noreg, $noreg
  bb.4:
    BL @"\01mcount", csr_aapcs, implicit-def dead $lr, implicit $sp
    $r0 = MOVi 3, 14, $noreg, $noreg
    $r1 = MOVi 3, 14, $noreg, $noreg
    $r2 = MOVi 3, 14, $noreg, $noreg
    $r3 = MOVi 3, 14, $noreg, $noreg
    $r4 = MOVi 3, 14, $noreg, $noreg
  bb.5:
    BX_RET 14, $noreg
...
---

name:           bar
tracksRegLiveness: true
body:             |
  bb.0:
    BX_RET 14, $noreg

  ; CHECK-LABEL: name: OUTLINED_FUNCTION_0
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r11, $r10, $r9, $r8, $r7, $r6, $r5, $d15, $d14, $d13, $d12, $d11, $d10, $d9, $d8
  ; CHECK:   $r0 = MOVi 2, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r1 = MOVi 2, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r2 = MOVi 2, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r3 = MOVi 2, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r4 = MOVi 2, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   TAILJMPd @bar, implicit $sp

  ; CHECK-LABEL: name: OUTLINED_FUNCTION_1
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r11, $r10, $r9, $r8, $r7, $r6, $r5, $d15, $d14, $d13, $d12, $d11, $d10, $d9, $d8
  ; CHECK:   $r0 = MOVi 3, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r1 = MOVi 3, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r2 = MOVi 3, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r3 = MOVi 3, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r4 = MOVi 3, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   MOVPCLR 14 /* CC::al */, $noreg

  ; CHECK-LABEL: name: OUTLINED_FUNCTION_2
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r11, $r10, $r9, $r8, $r7, $r6, $r5, $d15, $d14, $d13, $d12, $d11, $d10, $d9, $d8
  ; CHECK:   $r0 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r1 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r2 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r3 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r4 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   MOVPCLR 14 /* CC::al */, $noreg

  ; CHECK-LABEL: name: OUTLINED_FUNCTION_3
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r11, $r10, $r9, $r8, $r6, $r5, $r4, $d15, $d14, $d13, $d12, $d11, $d10, $d9, $d8
  ; CHECK:   $r0 = t2MOVi 2, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r1 = t2MOVi 2, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r2 = t2MOVi 2, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   tTAILJMPdND @bar, 14 /* CC::al */, $noreg, implicit $sp

  ; CHECK-LABEL: name: OUTLINED_FUNCTION_4
  ; CHECK: bb.0:
  ; CHECK:   liveins: $r11, $r10, $r9, $r8, $r6, $r5, $r4, $d15, $d14, $d13, $d12, $d11, $d10, $d9, $d8
  ; CHECK:   $r0 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r1 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r2 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg