xref: /llvm-project/llvm/test/Transforms/RewriteStatepointsForGC/gc-relocate-creation.ll (revision f01a3a893c147c1594b9a3fbd817456b209dabbf)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
3
4; This test is to verify gc.relocate can handle pointer to vector of
5; pointers (ptr addrspace(1) in this case).
6; The old scheme to create a gc.relocate of ptr addrspace(1)
7; type will fail because llvm does not support mangling vector of pointers.
8; The new scheme will create all gc.relocate to ptr addrspace(1) type and
9; then bitcast to the correct type.
10
11declare void @foo()
12
13declare void @use(...) "gc-leaf-function"
14
15define void @test1(ptr addrspace(1) %obj) gc "statepoint-example" {
16; CHECK-LABEL: @test1(
17; CHECK-NEXT:  entry:
18; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) [[OBJ:%.*]]) ]
19; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
20; CHECK-NEXT:    call void (...) @use(ptr addrspace(1) [[OBJ_RELOCATED]])
21; CHECK-NEXT:    ret void
22;
23entry:
24
25  call void @foo() [ "deopt"() ]
26  call void (...) @use(ptr addrspace(1) %obj)
27  ret void
28}
29