[RS4GC] Are derived pointers caught by RS4GC?

Hi all,

I have tried to lower the following LLVM IR using the RS4GC pass. Since there is a derived pointer, I expect that the derived pointer should be available as a gc root in gc.statepoint intrinsic. But it is not available. Can you please explain this scenario?

Before run RS4GC pass :

define void @dummy_func() {
ret void
}

define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc “statepoint-example” {
%gep = getelementptr i8, i8 addrspace(1)* %obj, i64 20000
call void @dummy_func()
%p = getelementptr i8, i8 addrspace(1)* %gep, i64 -20000
store i8 2, i8 addrspace(1)* %gep
ret i8 addrspace(1)* %p
}

define dso_local void @main() #0 {
%1 = alloca i8*, align 8
%2 = call noalias i8 addrspace(1)* @malloc(i64 8) #3
%3 = call i8 addrspace(1)* @test1(i8 addrspace(1)* %2)
ret void
}

declare dso_local noalias i8 addrspace(1)* @malloc(i64) #1

After RS4GC pass:

define void @dummy_func() {
ret void
}

define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc “statepoint-example” {
%gep = getelementptr i8, i8 addrspace(1)* %obj, i64 20000
%statepoint_token = call token (i64, i32, void (), i32, i32, …) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void () @dummy_func, i32 0, i32 0, i32 0, i32 0) [ “gc-live”(i8 addrspace(1)* %obj) ]
%obj.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 0, i32 0) ; (%obj, %obj)
%gep.remat = getelementptr i8, i8 addrspace(1)* %obj.relocated, i64 20000
%p = getelementptr i8, i8 addrspace(1)* %gep.remat, i64 -20000
store i8 2, i8 addrspace(1)* %gep.remat, align 1
ret i8 addrspace(1)* %p
}

define dso_local void @main() {
%1 = alloca i8*, align 8
%2 = call i8 addrspace(1)* @malloc(i64 8)
%3 = call i8 addrspace(1)* @test1(i8 addrspace(1)* %2)
ret void
}

declare dso_local i8 addrspace(1)* @malloc(i64)