llvm/llvm/test/Transforms/IROutliner/outlining-swift-error.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s

%swift.error = type opaque

define void @outlining_swifterror1(ptr swifterror %err) {
; CHECK-LABEL: @outlining_swifterror1(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[X:%.*]] = alloca i64, align 8
; CHECK-NEXT:    call void @outlined_ir_func_0(i64 5, ptr [[X]], ptr swifterror [[ERR:%.*]])
; CHECK-NEXT:    ret void
;
entry:
  %x = alloca i64
  %0 = mul i64 5, 5
  %1 = add i64 %0, %0
  store i64 %1, ptr %x
  store ptr %x, ptr %err
  ret void
}

define void @outlining_swifterror2(ptr swifterror %err) {
; CHECK-LABEL: @outlining_swifterror2(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[X:%.*]] = alloca i64, align 8
; CHECK-NEXT:    call void @outlined_ir_func_0(i64 3, ptr [[X]], ptr swifterror [[ERR:%.*]])
; CHECK-NEXT:    ret void
;
entry:
  %x = alloca i64
  %0 = mul i64 3, 3
  %1 = add i64 %0, %0
  store i64 %1, ptr %x
  store ptr %x, ptr %err
  ret void
}

; CHECK: define internal void @outlined_ir_func_0(i64 [[ARG0:%.*]], ptr [[ARG1:%.*]], ptr swifterror [[ARG2:%.*]])
; CHECK: entry_to_outline:
; CHECK-NEXT:  [[TMP0:%.*]] = mul i64 [[ARG0]], [[ARG0]]
; CHECK-NEXT:  [[TMP1:%.*]] = add i64 [[TMP0]], [[TMP0]]
; CHECK-NEXT:  store i64 [[TMP1]], ptr [[ARG1]], align 4
; CHECK-NEXT:  store ptr [[ARG1]], ptr [[ARG2]], align 8
; CHECK-NEXT:  br label %entry_after_outline.exitStub