fitzgen edited PR #4573 from clif-stack-frame-return-pointer
to main
:
This is the initial part of https://github.com/bytecodealliance/wasmtime/issues/4535
TODO: I need to implement the s390x lowering for these new instructions.
cfallin submitted PR review.
cfallin created PR review comment:
I would instead assert that the register is virtual; we should never have a preg-to-preg move inserted as that would either have undefined behavior (if allocatable register) or would break the ABI (move to SP or FP).
cfallin created PR review comment:
Can we assert that
rm
is one of a few registers on an allow-list?Ideally the property we want here is that it is not an allocatable register. Moving from a register managed by the regalloc has undefined behavior: we don't know what the value will be. But grabbing the
MachineEnv
and doing an assert on the lists of registers there is sort of cumbersome, so it's probably better if we limit it first to e.g.FP
andSP
(with a comment describing the real condition) and then add more regs to the list if we need them.
cfallin created PR review comment:
Rather than duplicate the
mov
code, could we doInst::Mov { .. }.emit(...)
, in the same way other pseudoinsts work?
cfallin submitted PR review.
cfallin created PR review comment:
a tiny bikeshed-color nit, but I think usually this intrinsic refers to the "return address" rather than "return pointer" (e.g.,
__builtin_return_address()
in GCC/Clang); perhaps we could call it that?
cfallin created PR review comment:
Ah! I see you had the same thought I did, reading a bit further :-)
I think the answer is definitely yes!
cfallin created PR review comment:
I suspect we could avoid the extra copy here by defining the return-address intrinsic to load directly from
8(%rbp)
, i.e. creating anAmode
withrbp
as a base register.
fitzgen updated PR #4573 from clif-stack-frame-return-pointer
to main
.
fitzgen updated PR #4573 from clif-stack-frame-return-pointer
to main
.
fitzgen updated PR #4573 from clif-stack-frame-return-pointer
to main
.
fitzgen has marked PR #4573 as ready for review.
fitzgen requested cfallin for a review on PR #4573.
fitzgen edited PR #4573 from clif-stack-frame-return-pointer
to main
:
This is the initial part of https://github.com/bytecodealliance/wasmtime/issues/4535
TODO: I need to implement the s390x lowering for these new instructions.
cfallin submitted PR review.
cfallin submitted PR review.
cfallin created PR review comment:
This is to avoid providing the base reg as an operand to the operand collector, I guess?
I wonder if it might be cleaner, or less error-prone at least, to handle this case in the
Amode::get_operands
andAmode::with_allocs
methods instead: skip providing rbp (or rsp) as an operand, and skip pulling an alloc from the AllocationConsumer if the original register was rbp (or rsp).(I'm actually not sure; I'm going back and forth right now.)
The general concern I had with this is that we may not handle the same lowering everywhere. But actually I think everything funnels to this one lowering helper so maybe this is sufficient.
If we do stick to this approach, let's add a comment where we define the
RbpOffset
arm that it must be used for rbp (as opposed to the generic forms) because rbp cannot be given as an arg to regalloc.
fitzgen submitted PR review.
fitzgen created PR review comment:
Yeah I actually like this better.
fitzgen updated PR #4573 from clif-stack-frame-return-pointer
to main
.
cfallin submitted PR review.
cfallin submitted PR review.
cfallin created PR review comment:
I think we need to mirror this conditional over to
with_allocs
here as well; otherwise we have a thing that consumes more allocs than the operands it reports. This will be kind-of-harmless today becauseAmode
's operands are always placed at the end of the inst by convention (because they're variable-length and that was easier wrt reuse-indices) but if a pseudoinst ever grows twoAmode
s or puts something after anAmode
that could be an issue.
cfallin created PR review comment:
We should assert here that base and index are not rbp or rsp I think, now that we're admitting we may use these registers in an
Amode
, just for consistency...
uweigand created PR review comment:
Just a suggestion to use something like
preg_stack
instead of r15, since this is actually not an ISA requirement - other ABIs use different registers as stack pointer.
uweigand submitted PR review.
uweigand created PR review comment:
I'd remove gpr(14), since this is actually allocatable. And again preferably use stack_reg instead of hardcoding 15.
uweigand submitted PR review.
fitzgen updated PR #4573 from clif-stack-frame-return-pointer
to main
.
fitzgen merged PR #4573.
Last updated: Nov 22 2024 at 16:03 UTC