<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>This is out of scope for LLVM, but let me give you a high level
summary.</p>
<p>Your GC needs to be able to walk all stack frames on the stack at
point of suspension. This can be done by using libunwind,
manually writing your own stack crawler, etc..</p>
<p>Once you have the ability to walk the stack, each return PC on
the stack will correspond to a stack map entry in the stack map
section. In this case, the return PC for the foo call will
correspond to an entry in that section. All of the offsets in
that entry refer to the frame corresponding to main. Your stack
walker must be able to turn those into actual addresses.</p>
<p>For callee saved registers - which I *think* is the case you're
actually asking about - , you can either a) disable that by
tweaking your copy of LLVM, or b) use the callee saved register
information generated for eh_frame to translate CSRs into their
spill locations. If you want to avoid dealing with this, look at
the "no_callee_saved_registers" function attribute. It's a very
blunt hammer, but you can come back later and refine. <br>
</p>
<p>This is a pretty standard GC implementation technique. Any off
the shelf GC you use should already be able to do this.</p>
<p>Philip<br>
</p>
<div class="moz-cite-prefix">On 5/20/21 7:50 AM, Kavindu Gimhan
Zoysa via llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CALoJghUAE=so6ibH+WBVeU9XZb2em_CfVZVsn_Knhoi-Pgiqcw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hi all,</div>
<div><br>
</div>
<div>Let's say I have an example like this</div>
<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"><i>fn
foo() {<br>
heapRef2 = getHeapRef()<br>
readStackMap()<br>
}<br>
fn main() {<br>
heapRef1 = getHeapRef()<br>
foo();<br>
}</i></blockquote>
<div><br>
</div>
<div>When we start to read stack map in foo(), our stack has two
heap references (heapRef1 and heapRef2). From the LLVM stack
map we can get the location of <b>heapRef2</b>, using let's
say rsp + offset. </div>
<div><br>
</div>
<div>But, When we consider about <b>heapRef1, </b>its' offset
is given with respect to its' function(main) rsp or rbp.<b> </b>But
at this moment those registers are pointed to foo()'s stack
frame locations. There fore how do we get the location of <b>heapRef1?</b></div>
<div><br>
</div>
<div>Highly appreciate your input on this.</div>
<div><br>
</div>
<div>Thank you,</div>
<div>Kavindu</div>
<br clear="all">
<div>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div>Kavindu Gimhan Zoysa,</div>
<div>BSc(Hons) | ENTC | UoM,<br>
</div>
<div dir="ltr">SSE | WSO2
<div><br>
</div>
<div><a href="https://github.com/KavinduZoysa"
target="_blank" moz-do-not-send="true">GitHub</a> <a
href="https://www.linkedin.com/in/kavindu-gimhan-zoysa-85939a122/"
target="_blank" moz-do-not-send="true">LinkedIn</a> <a
href="https://medium.com/@kavindugimhanzoysa"
target="_blank" moz-do-not-send="true">Medium</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
</body>
</html>