machinst ABI: Pass fixed frame size to gen_clobber_restore#2346
machinst ABI: Pass fixed frame size to gen_clobber_restore#2346cfallin merged 1 commit intobytecodealliance:mainfrom uweigand:abi-noframepointer
Conversation
|
@cfallin And this is the other change discussed here #2128 (comment) (required for the IBM Z back-end). |
| let mut fixed_frame_storage_size = 0; | ||
| if !self.call_conv.extends_baldrdash() { | ||
| fixed_frame_storage_size += self.frame_size(); | ||
| } |
There was a problem hiding this comment.
| let mut fixed_frame_storage_size = 0; | |
| if !self.call_conv.extends_baldrdash() { | |
| fixed_frame_storage_size += self.frame_size(); | |
| } | |
| let fixed_frame_storage_size = if !self.call_conv.extends_baldrdash() { | |
| self.frame_size() | |
| } else { | |
| 0 | |
| }; |
Also why this condition?
There was a problem hiding this comment.
If you look at the code in gen_prologue above, it passes a fixed_frame_storage_size of 0 to gen_clobber_save with the baldrdash calling convention. For consistency, we need to do the same for gen_clobber_restore.
Likewise, I followed the same coding convention with the "mut fixed_frame_storage_size" as is currently in place in gen_prologue. Given that any future changes to the computation of the size will need to be kept in sync between gen_prologue and gen_epilogue, it seems preferable to me to also have the code itself as similar as possible.
There was a problem hiding this comment.
I think it would be better to simply store the fixed_frame_storage_size in self -- we get a mutable self in gen_prologue so we should be able to write it there. This avoids the duplication of logic and potential for mismatches...
There was a problem hiding this comment.
OK, updated the patch accordingly.
cfallin
left a comment
There was a problem hiding this comment.
Thanks! As noted below, I think there may be a better way to factor things, but it's a sensible change overall.
| let mut fixed_frame_storage_size = 0; | ||
| if !self.call_conv.extends_baldrdash() { | ||
| fixed_frame_storage_size += self.frame_size(); | ||
| } |
There was a problem hiding this comment.
I think it would be better to simply store the fixed_frame_storage_size in self -- we get a mutable self in gen_prologue so we should be able to write it there. This avoids the duplication of logic and potential for mismatches...
The ABI common code currently passes the fixed frame size to the gen_clobber_save back-end routine, which is required to emit code to allocate the required stack space in the prologue. Similarly, the back-end needs to emit code to de-allocate the stack in the epilogue. However, at this point the back-end does not have access to that fixed frame size value any more. With targets that use a frame pointer, this does not matter, since de-allocation can be done simply by assigning the frame pointer back to the stack pointer. However, on targets that do not use a frame pointer, the frame size is required. To allow back-ends that option, this patch changes ABI common code to pass the fixed frame size to get_clobber_restore as well (the same value as is passed to get_clobber_save).
The ABI common code currently passes the fixed frame size to
the gen_clobber_save back-end routine, which is required to
emit code to allocate the required stack space in the prologue.
Similarly, the back-end needs to emit code to de-allocate the
stack in the epilogue. However, at this point the back-end
does not have access to that fixed frame size value any more.
With targets that use a frame pointer, this does not matter,
since de-allocation can be done simply by assigning the frame
pointer back to the stack pointer. However, on targets that
do not use a frame pointer, the frame size is required.
To allow back-ends that option, this patch changes ABI common
code to pass the fixed frame size to get_clobber_restore as
well (computed identically to how it is done for get_clobber_save).