Compiler projects using llvm
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --include-generated-funcs
; RUN: llc -enable-machine-outliner -mtriple=aarch64-unknown-linux < %s | FileCheck %s
@x = dso_local global i32 0, align 4

define dso_local i32 @check_boundaries() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, i32* %1, align 4
  store i32 0, i32* %2, align 4
  %6 = load i32, i32* %2, align 4
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %9, label %8

  store i32 1, i32* %2, align 4
  store i32 2, i32* %3, align 4
  store i32 3, i32* %4, align 4
  store i32 4, i32* %5, align 4
  br label %10

  store i32 1, i32* %4, align 4
  br label %10

  %11 = load i32, i32* %2, align 4
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %14, label %13

  store i32 1, i32* %2, align 4
  store i32 2, i32* %3, align 4
  store i32 3, i32* %4, align 4
  store i32 4, i32* %5, align 4
  br label %15

  store i32 1, i32* %4, align 4
  br label %15

  ret i32 0
}

define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4

  store i32 0, i32* %1, align 4
  store i32 0, i32* @x, align 4
  store i32 1, i32* %2, align 4
  store i32 2, i32* %3, align 4
  store i32 3, i32* %4, align 4
  store i32 4, i32* %5, align 4
  store i32 1, i32* @x, align 4
  call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
  store i32 1, i32* %2, align 4
  store i32 2, i32* %3, align 4
  store i32 3, i32* %4, align 4
  store i32 4, i32* %5, align 4
  ret i32 0
}

attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
; CHECK-LABEL: check_boundaries:
; CHECK:       // %bb.0:
; CHECK-NEXT:    sub sp, sp, #48
; CHECK-NEXT:    .cfi_def_cfa_offset 48
; CHECK-NEXT:    stp x29, x30, [sp, #32] // 16-byte Folded Spill
; CHECK-NEXT:    add x29, sp, #32
; CHECK-NEXT:    .cfi_def_cfa w29, 16
; CHECK-NEXT:    .cfi_offset w30, -8
; CHECK-NEXT:    .cfi_offset w29, -16
; CHECK-NEXT:    mov w8, #1
; CHECK-NEXT:    stur xzr, [x29, #-8]
; CHECK-NEXT:    cbz wzr, .LBB0_3
; CHECK-NEXT:  // %bb.1:
; CHECK-NEXT:    str w8, [sp, #16]
; CHECK-NEXT:    ldur w8, [x29, #-8]
; CHECK-NEXT:    cbz w8, .LBB0_4
; CHECK-NEXT:  .LBB0_2:
; CHECK-NEXT:    mov w8, #1
; CHECK-NEXT:    str w8, [sp, #16]
; CHECK-NEXT:    b .LBB0_5
; CHECK-NEXT:  .LBB0_3:
; CHECK-NEXT:    bl OUTLINED_FUNCTION_0
; CHECK-NEXT:    ldur w8, [x29, #-8]
; CHECK-NEXT:    cbnz w8, .LBB0_2
; CHECK-NEXT:  .LBB0_4:
; CHECK-NEXT:    mov w8, #1
; CHECK-NEXT:    bl OUTLINED_FUNCTION_0
; CHECK-NEXT:  .LBB0_5:
; CHECK-NEXT:    mov w0, wzr
; CHECK-NEXT:    .cfi_def_cfa wsp, 48
; CHECK-NEXT:    ldp x29, x30, [sp, #32] // 16-byte Folded Reload
; CHECK-NEXT:    add sp, sp, #48
; CHECK-NEXT:    .cfi_def_cfa_offset 0
; CHECK-NEXT:    .cfi_restore w30
; CHECK-NEXT:    .cfi_restore w29
; CHECK-NEXT:    ret
;
; CHECK-LABEL: main:
; CHECK:       // %bb.0:
; CHECK-NEXT:    sub sp, sp, #48
; CHECK-NEXT:    .cfi_def_cfa_offset 48
; CHECK-NEXT:    stp x29, x30, [sp, #32] // 16-byte Folded Spill
; CHECK-NEXT:    add x29, sp, #32
; CHECK-NEXT:    .cfi_def_cfa w29, 16
; CHECK-NEXT:    .cfi_offset w30, -8
; CHECK-NEXT:    .cfi_offset w29, -16
; CHECK-NEXT:    mov w8, #1
; CHECK-NEXT:    adrp x9, x
; CHECK-NEXT:    mov w10, #2
; CHECK-NEXT:    mov w11, #3
; CHECK-NEXT:    mov w0, wzr
; CHECK-NEXT:    str w8, [x9, :lo12:x]
; CHECK-NEXT:    mov w9, #4
; CHECK-NEXT:    stp w8, wzr, [x29, #-8]
; CHECK-NEXT:    stur w10, [x29, #-12]
; CHECK-NEXT:    stp w9, w11, [sp, #12]
; CHECK-NEXT:    //APP
; CHECK-NEXT:    //NO_APP
; CHECK-NEXT:    stp w10, w8, [x29, #-12]
; CHECK-NEXT:    stp w9, w11, [sp, #12]
; CHECK-NEXT:    .cfi_def_cfa wsp, 48
; CHECK-NEXT:    ldp x29, x30, [sp, #32] // 16-byte Folded Reload
; CHECK-NEXT:    add sp, sp, #48
; CHECK-NEXT:    .cfi_def_cfa_offset 0
; CHECK-NEXT:    .cfi_restore w30
; CHECK-NEXT:    .cfi_restore w29
; CHECK-NEXT:    ret
;
; CHECK-LABEL: OUTLINED_FUNCTION_0:
; CHECK:       // %bb.0:
; CHECK-NEXT:    mov w9, #2
; CHECK-NEXT:    mov w10, #3
; CHECK-NEXT:    mov w11, #4
; CHECK-NEXT:    stp w9, w8, [x29, #-12]
; CHECK-NEXT:    stp w11, w10, [sp, #12]
; CHECK-NEXT:    ret