Compiler projects using llvm
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=x86_64-apple-unknown -run-pass=machine-outliner -verify-machineinstrs %s -o - | FileCheck %s

# Outlining CFI instructions is unsafe if we cannot outline all of the CFI
# instructions from a function.  This shows that we choose to outline the
# CFI instructions if they can be included in a tail call.

--- |
  define void @foo() #0 { ret void }
  define void @bar() #0 { ret void }
  define void @baz() #0 { ret void }
  attributes #0 = { noredzone }
...
---
name:            foo
tracksRegLiveness: true
body:             |
  bb.0:
    ; CHECK-LABEL: name: foo
    ; CHECK: $ecx = MOV32ri 3
    ; CHECK: CFI_INSTRUCTION def_cfa_offset 16
    ; CHECK: CFI_INSTRUCTION offset $rbp, -16
    ; CHECK: CFI_INSTRUCTION def_cfa_register $rsp
    ; CHECK: TAILJMPd64 @OUTLINED_FUNCTION_0, implicit $rsp, implicit $ssp, implicit-def $eax, implicit-def $edi, implicit-def $edx, implicit-def $esi, implicit $rsp, implicit $ssp
    $ecx =  MOV32ri 3
    CFI_INSTRUCTION def_cfa_offset 16
    CFI_INSTRUCTION offset $rbp, -16
    CFI_INSTRUCTION def_cfa_register $rsp
    $esi = MOV32ri 1
    $edx = MOV32ri 2
    $edi = MOV32ri 3
    $eax = MOV32ri 4
    RET64
...
---
name:            bar
tracksRegLiveness: true
body:             |
  bb.0:
  ;liveins: $lr
    ; CHECK-LABEL: name: bar
    ; CHECK: $ecx = MOV32ri 3
    ; CHECK: CFI_INSTRUCTION def_cfa_offset 16
    ; CHECK: CFI_INSTRUCTION offset $rbp, -16
    ; CHECK: CFI_INSTRUCTION def_cfa_register $rsp
    ; CHECK: TAILJMPd64 @OUTLINED_FUNCTION_0, implicit $rsp, implicit $ssp, implicit-def $eax, implicit-def $edi, implicit-def $edx, implicit-def $esi, implicit $rsp, implicit $ssp
    $ecx =  MOV32ri 3
    CFI_INSTRUCTION def_cfa_offset 16
    CFI_INSTRUCTION offset $rbp, -16
    CFI_INSTRUCTION def_cfa_register $rsp
    $esi = MOV32ri 1
    $edx = MOV32ri 2
    $edi = MOV32ri 3
    $eax = MOV32ri 4
    RET64
...
---
name:            baz
tracksRegLiveness: true
body:             |
  bb.0:
  ;liveins: $lr
    ; CHECK-LABEL: name: baz
    ; CHECK: $ecx = MOV32ri 3
    ; CHECK: CFI_INSTRUCTION def_cfa_offset 16
    ; CHECK: CFI_INSTRUCTION offset $rbp, -16
    ; CHECK: CFI_INSTRUCTION def_cfa_register $rsp
    ; CHECK: TAILJMPd64 @OUTLINED_FUNCTION_0, implicit $rsp, implicit $ssp, implicit-def $eax, implicit-def $edi, implicit-def $edx, implicit-def $esi, implicit $rsp, implicit $ssp
    $ecx =  MOV32ri 3
    CFI_INSTRUCTION def_cfa_offset 16
    CFI_INSTRUCTION offset $rbp, -16
    CFI_INSTRUCTION def_cfa_register $rsp
    $esi = MOV32ri 1
    $edx = MOV32ri 2
    $edi = MOV32ri 3
    $eax = MOV32ri 4
    RET64