Compiler projects using llvm
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -enable-machine-outliner -mtriple=wasm32-unknown-linux < %s | FileCheck %s

; NOTE: Machine outliner doesn't run.
@x = global i32 0, align 4

define dso_local i32 @check_boundaries() #0 {
; CHECK-LABEL: check_boundaries:
; CHECK:         .functype check_boundaries () -> (i32)
; CHECK-NEXT:    .local i32
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get __stack_pointer
; CHECK-NEXT:    i32.const 32
; CHECK-NEXT:    i32.sub
; CHECK-NEXT:    local.tee 0
; CHECK-NEXT:    global.set __stack_pointer
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 0
; CHECK-NEXT:    i32.store 24
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 0
; CHECK-NEXT:    i32.store 28
; CHECK-NEXT:    block
; CHECK-NEXT:    block
; CHECK-NEXT:    i32.const 0
; CHECK-NEXT:    br_if 0 # 0: down to label1
; CHECK-NEXT:  # %bb.1:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 2
; CHECK-NEXT:    i32.store 20
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 1
; CHECK-NEXT:    i32.store 24
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 3
; CHECK-NEXT:    i32.store 16
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 4
; CHECK-NEXT:    i32.store 12
; CHECK-NEXT:    br 1 # 1: down to label0
; CHECK-NEXT:  .LBB0_2:
; CHECK-NEXT:    end_block # label1:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 1
; CHECK-NEXT:    i32.store 16
; CHECK-NEXT:  .LBB0_3:
; CHECK-NEXT:    end_block # label0:
; CHECK-NEXT:    block
; CHECK-NEXT:    block
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.load 24
; CHECK-NEXT:    br_if 0 # 0: down to label3
; CHECK-NEXT:  # %bb.4:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 2
; CHECK-NEXT:    i32.store 20
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 1
; CHECK-NEXT:    i32.store 24
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 3
; CHECK-NEXT:    i32.store 16
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 4
; CHECK-NEXT:    i32.store 12
; CHECK-NEXT:    br 1 # 1: down to label2
; CHECK-NEXT:  .LBB0_5:
; CHECK-NEXT:    end_block # label3:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 1
; CHECK-NEXT:    i32.store 16
; CHECK-NEXT:  .LBB0_6:
; CHECK-NEXT:    end_block # label2:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32.const 32
; CHECK-NEXT:    i32.add
; CHECK-NEXT:    global.set __stack_pointer
; CHECK-NEXT:    i32.const 0
; CHECK-NEXT:    # fallthrough-return
  %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 {
; CHECK-LABEL: main:
; CHECK:         .functype main (i32, i32) -> (i32)
; CHECK-NEXT:  # %bb.0: # %body
; CHECK-NEXT:    call __original_main
; CHECK-NEXT:    # fallthrough-return
  %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" }