llvm/llvm/test/CodeGen/ARM/machine-outliner-stack-fixup-thumb.mir

# RUN: llc -mtriple=thumbv7-- -run-pass=prologepilog \
# RUN: -run-pass=machine-outliner %s -o - | FileCheck %s

--- |
  define void @CheckAddrModeT2_i12() { ret void }
  define void @CheckAddrModeT2_i8() { ret void }
  define void @CheckAddrModeT2_i8s4() { ret void }
  define void @CheckAddrModeT2_ldrex() { ret void }
  define void @CheckAddrModeT1_s() { ret void }
  define void @foo() { ret void }

...
---

name:           CheckAddrModeT2_i12
tracksRegLiveness: true

body:             |
  bb.0:
    liveins: $r1
    ;CHECK-LABEL: name:           CheckAddrModeT2_i12
    ;CHECK: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[SHARED:[0-9+]]]
    ;CHECK-NEXT: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[I12:[0-9]+]]
    ;CHECK-NEXT: $r0 = t2LDRi12 $sp, 4088, 14 /* CC::al */, $noreg
    $r0 = tMOVr killed $r1, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    $r0 = t2LDRi12 $sp, 0, 14, $noreg
    $r0 = t2LDRi12 $sp, 4, 14, $noreg
    $r0 = t2LDRi12 $sp, 4086, 14, $noreg
    $r0 = t2LDRi12 $sp, 4088, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    $r0 = t2LDRi12 $sp, 0, 14, $noreg
    $r0 = t2LDRi12 $sp, 4, 14, $noreg
    $r0 = t2LDRi12 $sp, 4086, 14, $noreg
    $r0 = t2LDRi12 $sp, 4088, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    $r0 = t2LDRi12 $sp, 0, 14, $noreg
    $r0 = t2LDRi12 $sp, 4, 14, $noreg
    $r0 = t2LDRi12 $sp, 4086, 14, $noreg
    $r0 = t2LDRi12 $sp, 4088, 14, $noreg
    BX_RET 14, $noreg
...
---

name:           CheckAddrModeT2_i8
tracksRegLiveness: true

body:             |
  bb.0:
    liveins: $r1
    ;CHECK-LABEL: name:           CheckAddrModeT2_i8
    ;CHECK: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[SHARED:[0-9+]]]
    ;CHECK-NEXT: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[I8:[0-9]+]]
    ;CHECK-NEXT: t2STRHT $r0, $sp, 248, 14 /* CC::al */, $noreg
    $r0 = tMOVr $r1, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    t2STRHT $r0, $sp, 0, 14, $noreg
    t2STRHT $r0, $sp, 4, 14, $noreg
    t2STRHT $r0, $sp, 247, 14, $noreg
    t2STRHT $r0, $sp, 248, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    t2STRHT $r0, $sp, 0, 14, $noreg
    t2STRHT $r0, $sp, 4, 14, $noreg
    t2STRHT $r0, $sp, 247, 14, $noreg
    t2STRHT $r0, $sp, 248, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    t2STRHT $r0, $sp, 0, 14, $noreg
    t2STRHT $r0, $sp, 4, 14, $noreg
    t2STRHT $r0, $sp, 247, 14, $noreg
    t2STRHT $r0, $sp, 248, 14, $noreg
    BX_RET 14, $noreg
...
---

name:           CheckAddrModeT2_i8s4
tracksRegLiveness: true

body:             |
  bb.0:
    liveins: $r1
    ;CHECK-LABEL: name:           CheckAddrModeT2_i8s4
    ;CHECK: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[SHARED:[0-9+]]]
    ;CHECK-NEXT: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[I8S4:[0-9]+]]
    ;CHECK-NEXT: t2STRDi8 $r0, $r1, $sp, 1020, 14 /* CC::al */, $noreg
    $r0 = tMOVr $r1, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    t2STRDi8 $r0, $r1, $sp, 0, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 8, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 1012, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 1020, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    t2STRDi8 $r0, $r1, $sp, 0, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 8, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 1012, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 1020, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    t2STRDi8 $r0, $r1, $sp, 0, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 8, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 1012, 14, $noreg
    t2STRDi8 $r0, $r1, $sp, 1020, 14, $noreg
    BX_RET 14, $noreg
...
---

name:           CheckAddrModeT2_ldrex
tracksRegLiveness: true

body:             |
  bb.0:
    liveins: $r1
    ;CHECK-LABEL: name:           CheckAddrModeT2_ldrex
    ;CHECK: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[SHARED:[0-9+]]]
    ;CHECK-NEXT: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[LDREX:[0-9]+]]
    ;CHECK-NEXT: $r1 = t2LDREX $sp, 254, 14 /* CC::al */, $noreg
    $r0 = tMOVr $r1, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    $r1 = t2LDREX $sp, 0, 14, $noreg
    $r1 = t2LDREX $sp, 8, 14, $noreg
    $r1 = t2LDREX $sp, 253, 14, $noreg
    $r1 = t2LDREX $sp, 254, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    $r1 = t2LDREX $sp, 0, 14, $noreg
    $r1 = t2LDREX $sp, 8, 14, $noreg
    $r1 = t2LDREX $sp, 253, 14, $noreg
    $r1 = t2LDREX $sp, 254, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    $r1 = t2LDREX $sp, 0, 14, $noreg
    $r1 = t2LDREX $sp, 8, 14, $noreg
    $r1 = t2LDREX $sp, 253, 14, $noreg
    $r1 = t2LDREX $sp, 254, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    $r1 = t2LDREX $sp, 0, 14, $noreg
    $r1 = t2LDREX $sp, 8, 14, $noreg
    $r1 = t2LDREX $sp, 253, 14, $noreg
    $r1 = t2LDREX $sp, 254, 14, $noreg
    BX_RET 14, $noreg
...
---

name:           CheckAddrModeT1_s
tracksRegLiveness: true

body:             |
  bb.0:
    liveins: $r0, $r1
    ;CHECK-LABEL: name:           CheckAddrModeT1_s
    ;CHECK: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_[[SHARED:[0-9+]]]
    ;CHECK-NEXT: tSTRspi $r0, $sp, 0, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: tSTRspi $r0, $sp, 4, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: tSTRspi $r0, $sp, 253, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: tSTRspi $r0, $sp, 254, 14 /* CC::al */, $noreg
    $r0 = tMOVr $r1, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    tSTRspi $r0, $sp, 0, 14, $noreg
    tSTRspi $r0, $sp, 4, 14, $noreg
    tSTRspi $r0, $sp, 253, 14, $noreg
    tSTRspi $r0, $sp, 254, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    tSTRspi $r0, $sp, 0, 14, $noreg
    tSTRspi $r0, $sp, 4, 14, $noreg
    tSTRspi $r0, $sp, 253, 14, $noreg
    tSTRspi $r0, $sp, 254, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    tSTRspi $r0, $sp, 0, 14, $noreg
    tSTRspi $r0, $sp, 4, 14, $noreg
    tSTRspi $r0, $sp, 253, 14, $noreg
    tSTRspi $r0, $sp, 254, 14, $noreg
    tBL 14, $noreg, @foo, implicit-def dead $lr, implicit $sp
    tSTRspi $r0, $sp, 0, 14, $noreg
    tSTRspi $r0, $sp, 4, 14, $noreg
    tSTRspi $r0, $sp, 253, 14, $noreg
    tSTRspi $r0, $sp, 254, 14, $noreg
    BX_RET 14, $noreg
...
---

name:           foo
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $lr

    BX_RET 14, $noreg

    ;CHECK: name:           OUTLINED_FUNCTION_[[LDREX]]
    ;CHECK: $r1 = t2LDREX $sp, 0, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: $r1 = t2LDREX $sp, 8, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: $r1 = t2LDREX $sp, 253, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: tBX_RET 14 /* CC::al */, $noreg

    ;CHECK: name:           OUTLINED_FUNCTION_[[I8]]
    ;CHECK: t2STRHT $r0, $sp, 0, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: t2STRHT $r0, $sp, 4, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: t2STRHT $r0, $sp, 247, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: tBX_RET 14 /* CC::al */, $noreg

    ;CHECK: name:           OUTLINED_FUNCTION_[[I8S4]]
    ;CHECK: t2STRDi8 $r0, $r1, $sp, 0, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: t2STRDi8 $r0, $r1, $sp, 8, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: t2STRDi8 $r0, $r1, $sp, 1012, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: tBX_RET 14 /* CC::al */, $nore

    ;CHECK: name:           OUTLINED_FUNCTION_[[I12]]
    ;CHECK: $r0 = t2LDRi12 $sp, 0, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: $r0 = t2LDRi12 $sp, 4, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: $r0 = t2LDRi12 $sp, 4086, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: tBX_RET 14 /* CC::al */, $noreg

    ;CHECK: name:           OUTLINED_FUNCTION_[[SHARED]]
    ;CHECK: $r0 = tMOVr killed $r1, 14 /* CC::al */, $noreg
    ;CHECK-NEXT: tTAILJMPdND @foo, 14 /* CC::al */, $noreg, implicit $sp