llvm/llvm/test/Transforms/RewriteStatepointsForGC/deopt-intrinsic.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s

target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"

declare i32 @llvm.experimental.deoptimize.i32(...)
declare void @llvm.experimental.deoptimize.isVoid(...)

define i32 @caller_0(ptr addrspace(1) %ptr) gc "statepoint-example" {
; CHECK-LABEL: @caller_0(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @__llvm_deoptimize, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, ptr addrspace(1) [[PTR:%.*]]), "gc-live"(ptr addrspace(1) [[PTR]]) ]
; CHECK-NEXT:    [[PTR_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT:    unreachable
;
entry:
  %v = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"(i32 0, ptr addrspace(1) %ptr) ]
  ret i32 %v
}


define i32 @caller_1(ptr addrspace(1) %ptr) gc "statepoint-example" {
; CHECK-LABEL: @caller_1(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void (i32, ptr addrspace(1))) @__llvm_deoptimize, i32 2, i32 0, i32 50, ptr addrspace(1) [[PTR:%.*]], i32 0, i32 0) [ "deopt"(i32 0), "gc-live"(ptr addrspace(1) [[PTR]]) ]
; CHECK-NEXT:    [[PTR_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT:    unreachable
;
entry:
  %v = call i32(...) @llvm.experimental.deoptimize.i32(i32 50, ptr addrspace(1) %ptr) [ "deopt"(i32 0) ]
  ret i32 %v
}

define void @caller_2(ptr addrspace(1) %ptr) gc "statepoint-example" {
; CHECK-LABEL: @caller_2(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @__llvm_deoptimize, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, ptr addrspace(1) [[PTR:%.*]]), "gc-live"(ptr addrspace(1) [[PTR]]) ]
; CHECK-NEXT:    [[PTR_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT:    unreachable
;
entry:
  call void(...) @llvm.experimental.deoptimize.isVoid() [ "deopt"(i32 0, ptr addrspace(1) %ptr) ]
  ret void
}