<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 26/08/11 15:23, Semion Prihodko wrote:
<blockquote
cite="mid:CAOLuvB1wOyXe37MH+Wa-6FrDdgsMqii=d3tLYq42WmGWYerNiQ@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
Hi, guys.
<div><br>
</div>
<div>I have a beginner's question. The virtual machine I develop
have instructions to dynamically allocate variable in stack and
to free it (consistency of such instructions is checked before
the actual jitting). To allocate memory in stack we have alloca
IR instruction, but I didn't find any instruction to free it
(such variables will be freed only when an enclosing function
will return). This means that I have to create function for
every stack allocation which is not convenient. Can you suggest
me easier way to dynamically allocate and free variables in
stack? Thanks.</div>
</blockquote>
You can use the llvm.stacksave intrinsic to save the current stack
pointer, allocate some memory on the stack with variable sized
allocas and then restore the stack with the llvm.stackrestore
intrinsic which effectively frees all the allocas executed
inbetween.<br>
<br>
<pre class="moz-signature" cols="72">--
Richard Osborne | XMOS
<a class="moz-txt-link-freetext" href="http://www.xmos.com">http://www.xmos.com</a>
</pre>
</body>
</html>