llvm/llvm/test/CodeGen/AArch64/machine-outliner-threshold.mir

# RUN: llc -mtriple=aarch64--- -run-pass=machine-outliner -verify-machineinstrs %s -o - | FileCheck %s
# RUN: llc -mtriple=aarch64--- -outliner-benefit-threshold=10 -run-pass=machine-outliner -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=THRESHOLD
--- |

  define void @baz() #0 {
    ret void
  }

  define void @bar(i32 %a) #0 {
    ret void
  }

  attributes #0 = { noredzone }
...
---
# Check that two we outline two different sequences, one from bb1 and one from
# bb2 when the threshold is 1.
# CHECK-LABEL: bb.1:
# CHECK: BL @OUTLINED_FUNCTION_[[F0:[0-9]+]], implicit-def $lr, implicit $sp
# CHECK-NEXT: $w11 = ORRWri $wzr, 1
# CHECK-NEXT: $w11 = ORRWri $wzr, 1
# CHECK-NEXT: $w11 = ORRWri $wzr, 2
# CHECK-NEXT: BL @baz, implicit-def dead $lr, implicit $sp
# CHECK-NEXT: BL @OUTLINED_FUNCTION_[[F0]], implicit-def $lr, implicit $sp
# CHECK-NEXT: $w11 = ORRWri $wzr, 1
# CHECK-NEXT: $w11 = ORRWri $wzr, 1
# CHECK-NEXT: $w8 = ORRWri $wzr, 0
# CHECK-NOT: $w11 = KILL renamable $w11, implicit killed $w11

# CHECK-LABEL: bb.2:
# CHECK: BL @OUTLINED_FUNCTION_[[F1:[0-9]+]], implicit-def $lr, implicit $sp
# CHECK-NEXT: $w9 = ORRWri $wzr, 0
# CHECK-NEXT: BL @OUTLINED_FUNCTION_[[F1]], implicit-def $lr, implicit $sp
# CHECK-NEXT: $w8 = ORRWri $wzr, 0
# CHECK-NOT: $w11 = KILL renamable $w11, implicit killed $w11

# Check that the sequences in bb.2 don't get outlined with a threshold of 10 but
# the sequences in bb.1 do.
# THRESHOLD-LABEL: bb.1:
# THRESHOLD: BL @OUTLINED_FUNCTION_[[F0:[0-9]+]], implicit-def $lr, implicit $sp
# THRESHOLD-NEXT: $w11 = ORRWri $wzr, 1
# THRESHOLD-NEXT: $w11 = ORRWri $wzr, 1
# THRESHOLD-NEXT: $w11 = ORRWri $wzr, 2
# THRESHOLD-NEXT: BL @baz, implicit-def dead $lr, implicit $sp
# THRESHOLD-NEXT: BL @OUTLINED_FUNCTION_[[F0]], implicit-def $lr, implicit $sp
# THRESHOLD-NEXT: $w11 = ORRWri $wzr, 1
# THRESHOLD-NEXT: $w11 = ORRWri $wzr, 1
# THRESHOLD-NEXT: $w8 = ORRWri $wzr, 0
# THRESHOLD-NOT: $w11 = KILL renamable $w11, implicit killed $w11

# THRESHOLD-LABEL: bb.2:
# THRESHOLD-NOT: BL @OUTLINED_FUNCTION
name:            bar
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $w0, $lr, $w8
    $sp = frame-setup SUBXri $sp, 32, 0
    $fp = frame-setup ADDXri $sp, 16, 0

  bb.1:
    BL @baz, implicit-def dead $lr, implicit $sp
    $w11 = ORRWri $wzr, 1
    $w11 = ORRWri $wzr, 1
    $w11 = KILL renamable $w11, implicit killed $w11
    $w11 = ORRWri $wzr, 1
    $w11 = ORRWri $wzr, 1
    BL @baz, implicit-def dead $lr, implicit $sp
    $w11 = ORRWri $wzr, 1
    $w11 = ORRWri $wzr, 1
    $w11 = ORRWri $wzr, 2
    BL @baz, implicit-def dead $lr, implicit $sp
    $w11 = ORRWri $wzr, 1
    $w11 = ORRWri $wzr, 1
    $w11 = ORRWri $wzr, 1
    $w11 = ORRWri $wzr, 1
    BL @baz, implicit-def dead $lr, implicit $sp
    $w11 = ORRWri $wzr, 1
    $w11 = ORRWri $wzr, 1
    $w8 = ORRWri $wzr, 0

  bb.2:
    $w15 = ORRWri $wzr, 1
    $w15 = ORRWri $wzr, 1
    $w15 = ORRWri $wzr, 1
    $w15 = ORRWri $wzr, 1
    $x15 = ADDXri $sp, 48, 0;
    $w9 = ORRWri $wzr, 0
    $w15 = ORRWri $wzr, 1
    $w15 = ORRWri $wzr, 1
    $w15 = ORRWri $wzr, 1
    $w15 = ORRWri $wzr, 1
    $x15 = ADDXri $sp, 48, 0;
    $w8 = ORRWri $wzr, 0

  bb.3:
    $fp, $lr = LDPXi $sp, 2
    $sp = ADDXri $sp, 32, 0
    RET undef $lr

...
---
name:            baz
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $w0, $lr, $w8
    RET undef $lr

# CHECK-LABEL: name:            OUTLINED_FUNCTION_{{[0-9]}}
# CHECK-LABEL: name:            OUTLINED_FUNCTION_{{[1-9]}}

# THRESHOLD-LABEL: name:            OUTLINED_FUNCTION_{{[0-9]}}
# THRESHOLD-NOT:   name:            OUTLINED_FUNCTION_{{[1-9]}}