How to actively reclaim stack memory

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

Thanks very much for your help!

Qin