[llvm-dev] How to actively reclaim stack memory

haifeng.qin@wellintech.com via llvm-dev llvm-dev at lists.llvm.org
Thu Dec 15 17:19:54 PST 2016


Thanks very much for your help!

Qin



haifeng.qin at wellintech.com
 
From: David Chisnall
Date: 2016-12-15 18:01
To: haifeng.qin at wellintech.com
CC: llvm-dev
Subject: Re: [llvm-dev] How to actively reclaim stack memory
On 15 Dec 2016, at 07:26, haifeng.qin at wellintech.com via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> For help:
> 
> for loop lead to stack overflow, want to actively reclaim stack memory of alloc instruction.
> 
> How to actively reclaim stack memory ?
 
This sounds as if you’re putting the alloca inside the loop, not in the entry basic block and reusing it.  If you need the same amount of storage for each loop iteration, then you should put the alloca in the entry basic block and use the lifetime start / stop intrinsics in the loop to mark reuse of the memory.  If you need different sized allocations, then you will need to use the stack save and stack restore intrinsics inside the loop to reset the stack allocations in the loop.
 
David
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161216/e0ad6d2e/attachment.html>


More information about the llvm-dev mailing list