Villmow, Micah
2009-Mar-30 19:01 UTC
[LLVMdev] Determining the base offset of the stack for a function.
I am running into an issue where if I have multiple functions compiled in the same compilation unit the stack offset is not starting at zero. For example: func1(...) { ... } func2(...) { ... } Say the first function uses 64 bytes of the stack and an assumed offset of 0 and the second function uses 32 bytes of the stack but an assumed offset of 64. I've found out how to get the size of the stack via MachineFrameInfo.StackSize/getObjectSize, however I have not found out how to determine the starting offset of the stack for that specific function. I need this information so that I can offset my stack pointer correctly since all my indices into my stack need to start at 0 for each independent function call. So, what this means is that if I call func1 or func2 I need to make sure all offsets into the stack start at zero. Thanks for any tips/hints, Micah Villmow Systems Engineer Advanced Technology & Performance Advanced Micro Devices Inc. S1-609 One AMD Place Sunnyvale, CA. 94085 P: 408-749-3966 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090330/726186ed/attachment.html>
Evan Cheng
2009-Apr-01 20:10 UTC
[LLVMdev] Determining the base offset of the stack for a function.
On Mar 30, 2009, at 12:01 PM, Villmow, Micah wrote:> I am running into an issue where if I have multiple functions > compiled in the same compilation unit the stack offset is not > starting at zero. For example: > func1(…) > { > … > } > > func2(…) > { > … > } > > Say the first function uses 64 bytes of the stack and an assumed > offset of 0 and the second function uses 32 bytes of the stack but > an assumed offset of 64. I’ve found out how to get the size of the > stack via MachineFrameInfo.StackSize/getObjectSize, however I have > not found out how to determine the starting offset of the stack for > that specific function. I need this information so that I can offset > my stack pointer correctly since all my indices into my stack need > to start at 0 for each independent function call. > > So, what this means is that if I call func1 or func2 I need to make > sure all offsets into the stack start at zero.Micah, stack offset is always relative to the stack pointer which is unchanged in the function unless you have dynamic stack allocation. So from the compiler's point of view, the starting offset for a function is always zero. Evan> > Thanks for any tips/hints, > > Micah Villmow > Systems Engineer > Advanced Technology & Performance > Advanced Micro Devices Inc. > S1-609 One AMD Place > Sunnyvale, CA. 94085 > P: 408-749-3966 > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090401/58c8bed6/attachment.html>