xref: /llvm-project/llvm/test/Transforms/RewriteStatepointsForGC/relocate-invoke-result.ll (revision 6f7c9d1e176362d4e9af46b808c36d786d1fc96c)
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
5declare ptr addrspace(1) @non_gc_call() "gc-leaf-function"
6
7declare void @gc_call()
8
9declare ptr @fake_personality_function()
10
11define ptr addrspace(1) @test() gc "statepoint-example" personality ptr @fake_personality_function {
12; CHECK-LABEL: @test(
13
14entry:
15  %obj = invoke ptr addrspace(1) @non_gc_call()
16          to label %normal_dest unwind label %unwind_dest
17
18unwind_dest:                                      ; preds = %entry
19  %lpad = landingpad { ptr, i32 }
20          cleanup
21  resume { ptr, i32 } undef
22
23normal_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}
31