| 1 |
;; RUN: opt -passes=rewrite-statepoints-for-gc,verify -S < %s | FileCheck %s |
| 2 |
;; This test is to verify that RewriteStatepointsForGC correctly relocates values |
| 3 |
;; defined by invoke instruction results. |
| 4 |
|
| 5 |
declare ptr addrspace(1) @non_gc_call() "gc-leaf-function" |
| 6 |
|
| 7 |
declare void @gc_call() |
| 8 |
|
| 9 |
declare ptr @fake_personality_function() |
| 10 |
|
| 11 |
define ptr addrspace(1) @test() gc "statepoint-example" personality ptr @fake_personality_function { |
| 12 |
; CHECK-LABEL: @test( |
| 13 |
|
| 14 |
entry: |
| 15 |
%obj = invoke ptr addrspace(1) @non_gc_call() |
| 16 |
to label %normal_dest unwind label %unwind_dest |
| 17 |
|
| 18 |
unwind_dest: ; preds = %entry |
| 19 |
%lpad = landingpad { ptr, i32 } |
| 20 |
cleanup |
| 21 |
resume { ptr, i32 } undef |
| 22 |
|
| 23 |
normal_dest: ; preds = %entry |
| 24 |
; CHECK: normal_dest: |
| 25 |
; CHECK-NEXT: gc.statepoint |
| 26 |
; CHECK-NEXT: %obj.relocated = call coldcc ptr addrspace(1) |
| 27 |
|
| 28 |
call void @gc_call() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] |
| 29 |
ret ptr addrspace(1) %obj |
| 30 |
} |