<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>$ ./opt -S llvm-dev.ll -rewrite-statepoints-for-gc<br>
; ModuleID = 'llvm-dev.ll'<br>
source_filename = "llvm-dev.ll"<br>
<br>
define void @dummy_func() {<br>
ret void<br>
}<br>
<br>
define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc
"statepoint-example" {<br>
%gep = getelementptr i8, i8 addrspace(1)* %obj, i64 20000<br>
%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) ]<br>
<b>%obj.relocated = call coldcc i8 addrspace(1)*
@llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32
0, i32 0) ; (%obj, %obj)</b><br>
<b>%gep.remat = getelementptr i8, i8 addrspace(1)*
%obj.relocated, i64 20000</b><br>
%p = getelementptr i8, i8 addrspace(1)* %gep.remat, i64 -20000<br>
store i8 2, i8 addrspace(1)* %gep.remat, align 1<br>
ret i8 addrspace(1)* %p<br>
}<br>
</p>
<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.</p>
<p>Philip<br>
</p>
<div class="moz-cite-prefix">On 7/20/21 7:45 AM, Kavindu Gimhan
Zoysa via llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CALoJghWiEbxh1f1Hx8wT3TPJM3LAL25KWMDMhoKrA-U42EGT1g@mail.gmail.com">
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">define
void @dummy_func() {<br>
ret void<br>
}<br>
define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc
"statepoint-example" {<br>
%gep = getelementptr i8, i8 addrspace(1)* %obj, i64 20000<br>
call void @dummy_func()<br>
%p = getelementptr i8, i8 addrspace(1)* %gep, i64 -20000<br>
store i8 2, i8 addrspace(1)* %gep<br>
ret i8 addrspace(1)* %p<br>
}</blockquote>
</blockquote>
</body>
</html>