Stack layout in the x86 back-end

Hi all,

I've been quiet for a while, but work on the new model checker has been going pretty well of late. I do have a question for the team, however.

I've implemented code that manages multiple stacks, with an ability to version them and roll back and forward between versions so I can implement backtracking and nontrivial search strategies -- this all works. However, I'm currently dumbly checking the entire stack (not just the currently relevant stack frame(s)) for changes, but I'd rather just be able to check a minimal area. Whenever I context switch, the code under test calls a function in my run-time-system (mcp_yield(), not that the details matter much). What I'd like to be able to do is pick up the address range of the stack frame of the function that called it -- ideally, I'd like a block that encompasses everything from the function parameters up to the current top-of-stack including spilled registers. Is this feasible?

Thank you in advance,

Hi Sarah,

I'm not sure how much of this is possible. You're guaranteed that each function stack frame is itself contiguous (including spilled regs), but there isn't really a notion of "top of stack" in the compiler. To get this information, you'll need information from the runtime or OS.



what about the llvm.frameaddress, llvm.stacksave, and llvm.stackrestore
intrinsics? According to the documentation, they give you the current stack
frame, including the current top of the frame.
I currently use these to do a simple stack-rollback in our STM, and they seem
to work okay (I haven't looked at the stack contents in example programs to
validate this, though). Is this a valid approach for stack rollback (paired
with a setjmp?