Kavindu Gimhan Zoysa via llvm-dev
2021-Jul-20 14:45 UTC
[llvm-dev] Are derived pointers caught by RS4GC?
Hi all, If I run the *--rewrite-statepoints-for-gc, *against an LLVM IR with a derived pointer, that pointer is not caught by RS4GC pass as a live pointer. Is this the expected behavior? This is the sample code I ran. 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) #1Since *%gep *is a derived pointer, I expect it should be identified as a live pointer for RS4GC as explained in https://releases.llvm.org/11.0.1/docs/Statepoints.html#base-derived-pointers . Really appreciate your input about this. Thank you, Kavindu Kavindu Gimhan Zoysa, BSc(Hons) | ENTC | UoM, ATL | WSO2 GitHub <https://github.com/KavinduZoysa> LinkedIn <https://www.linkedin.com/in/kavindu-gimhan-zoysa-85939a122/> Medium <https://medium.com/@kavindugimhanzoysa> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210720/753e0765/attachment.html>
Philip Reames via llvm-dev
2021-Jul-20 17:23 UTC
[llvm-dev] Are derived pointers caught by RS4GC?
$ ./opt -S llvm-dev.ll -rewrite-statepoints-for-gc ; ModuleID = 'llvm-dev.ll' source_filename = "llvm-dev.ll" 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 } Works for me. This output is entirely correct as we relocated the base pointer and then rematerialized the derived pointer afterwards. This is almost always profitable over directly relocating both obj and derived pointers. Philip On 7/20/21 7:45 AM, Kavindu Gimhan Zoysa via llvm-dev wrote:> > 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 > } >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210720/9fc46768/attachment.html>