Jianfei Hu
2012-Apr-21 16:18 UTC
[LLVMdev] Little Problem about Variable memory allocating way in function
As I want to generate code for the varaible declaration, at first, I thought AllocInstruction()could implement this. However, the name "alloc" seems to allocate memory from heap memory.and the local variable in function should stay at stack memory. In which way did llvm allocate memeory to AllocInstruction() ? Would the memory allocated by AllocInstruction() be recycled back? If not what is the ideal way to locate memory for local varaible in function? ps: I've tried llvm.org/demo to watch the IR code, however, it seems to optimize so much to eliminate any intermidate varaible. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120422/218e8c1f/attachment.html>
Duncan Sands
2012-Apr-21 16:39 UTC
[LLVMdev] Little Problem about Variable memory allocating way in function
Hi Jianfei Hu,> As I want to generate code for the varaible declaration, at first, I thought > AllocInstruction()AllocaInst could implement this.> However, the name "alloc" seems to allocate memory from heap memory.and the > local variable in function should stay at stack memory.AllocaInst represents stack memory, not heap memory, much like the alloca standard library function.> In which way did llvm allocate memeory to AllocInstruction() ? Would the memory > allocated by AllocInstruction() be recycled back? > If not what is the ideal way to locate memory for local varaible in function? > > ps: I've tried llvm.org/demo <http://llvm.org/demo> to watch the IR code, > however, it seems to optimize so much to eliminate any intermidate varaible.You can disable optimization by choosing "None" for "Optimization level". Ciao, Duncan.
Reasonably Related Threads
- [LLVMdev] Problem about the type of Function's arguement in llvm
- [LLVMdev] The use-define chain in LLVM
- [LLVMdev] How to Check whether BasicBlock resides in a conditional branch
- [LLVMdev] The use-define chain in LLVM
- [LLVMdev] How to Check whether BasicBlock resides in a conditional branch