Stream: git-wasmtime

Topic: wasmtime / issue #4425 Semantics of is_included_in_clobbe...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 09 2022 at 17:39):

uweigand opened issue #4425:

In implementing SIMD support for s390x, I had to support vector registers that are defined as partially callee-saved by ABI. This is the same situation that already exists on AArch64, and I used the same method: removing Call instructions from consideration when computing function-wide clobbers via the is_included_in_clobbers callback.

This works in general, but there is one unexpected issue. On s390x, calls work by loading the return address into a "link register", which the callee will use to return back to the caller. This means of course that the call instruction clobbers that link register - so if the caller later has to return to its caller, it will need the original value of the link register at function entry, and therefore has to save/restore it.

This used to work fine since the link register is marked as "defined" by the call instruction. However, once call instructions are ignored via is_included_in_clobbers, that definition of the link register is also ignored. I would have expected that only the clobbers of the call instruction would be ignored - but the current implementation ignores the instruction completely.

Now, I can work around this by implicitly considering the link register clobbered in any non-leaf routine. But this seems a bit awkward. Any thoughts?

FYI @cfallin

view this post on Zulip Wasmtime GitHub notifications bot (Jul 11 2022 at 12:50):

akirilov-arm commented on issue #4425:

Now, I can work around this by implicitly considering the link register clobbered in any non-leaf routine. But this seems a bit awkward. Any thoughts?

The 64-bit Arm architecture works in pretty much the same way with respect to the link register, and that is the solution that has been chosen.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 11 2022 at 16:25):

akirilov-arm labeled issue #4425:

In implementing SIMD support for s390x, I had to support vector registers that are defined as partially callee-saved by ABI. This is the same situation that already exists on AArch64, and I used the same method: removing Call instructions from consideration when computing function-wide clobbers via the is_included_in_clobbers callback.

This works in general, but there is one unexpected issue. On s390x, calls work by loading the return address into a "link register", which the callee will use to return back to the caller. This means of course that the call instruction clobbers that link register - so if the caller later has to return to its caller, it will need the original value of the link register at function entry, and therefore has to save/restore it.

This used to work fine since the link register is marked as "defined" by the call instruction. However, once call instructions are ignored via is_included_in_clobbers, that definition of the link register is also ignored. I would have expected that only the clobbers of the call instruction would be ignored - but the current implementation ignores the instruction completely.

Now, I can work around this by implicitly considering the link register clobbered in any non-leaf routine. But this seems a bit awkward. Any thoughts?

FYI @cfallin

view this post on Zulip Wasmtime GitHub notifications bot (Jul 11 2022 at 16:25):

akirilov-arm labeled issue #4425:

In implementing SIMD support for s390x, I had to support vector registers that are defined as partially callee-saved by ABI. This is the same situation that already exists on AArch64, and I used the same method: removing Call instructions from consideration when computing function-wide clobbers via the is_included_in_clobbers callback.

This works in general, but there is one unexpected issue. On s390x, calls work by loading the return address into a "link register", which the callee will use to return back to the caller. This means of course that the call instruction clobbers that link register - so if the caller later has to return to its caller, it will need the original value of the link register at function entry, and therefore has to save/restore it.

This used to work fine since the link register is marked as "defined" by the call instruction. However, once call instructions are ignored via is_included_in_clobbers, that definition of the link register is also ignored. I would have expected that only the clobbers of the call instruction would be ignored - but the current implementation ignores the instruction completely.

Now, I can work around this by implicitly considering the link register clobbered in any non-leaf routine. But this seems a bit awkward. Any thoughts?

FYI @cfallin

view this post on Zulip Wasmtime GitHub notifications bot (Jul 11 2022 at 16:25):

akirilov-arm labeled issue #4425:

In implementing SIMD support for s390x, I had to support vector registers that are defined as partially callee-saved by ABI. This is the same situation that already exists on AArch64, and I used the same method: removing Call instructions from consideration when computing function-wide clobbers via the is_included_in_clobbers callback.

This works in general, but there is one unexpected issue. On s390x, calls work by loading the return address into a "link register", which the callee will use to return back to the caller. This means of course that the call instruction clobbers that link register - so if the caller later has to return to its caller, it will need the original value of the link register at function entry, and therefore has to save/restore it.

This used to work fine since the link register is marked as "defined" by the call instruction. However, once call instructions are ignored via is_included_in_clobbers, that definition of the link register is also ignored. I would have expected that only the clobbers of the call instruction would be ignored - but the current implementation ignores the instruction completely.

Now, I can work around this by implicitly considering the link register clobbered in any non-leaf routine. But this seems a bit awkward. Any thoughts?

FYI @cfallin

view this post on Zulip Wasmtime GitHub notifications bot (Jul 21 2022 at 17:44):

uweigand commented on issue #4425:

OK, given we need to special-case the link register anyway to support preserve_frame_pointers (https://github.com/bytecodealliance/wasmtime/pull/4477), I think this is fine after all. Closing this issue now.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 21 2022 at 17:44):

uweigand closed issue #4425:

In implementing SIMD support for s390x, I had to support vector registers that are defined as partially callee-saved by ABI. This is the same situation that already exists on AArch64, and I used the same method: removing Call instructions from consideration when computing function-wide clobbers via the is_included_in_clobbers callback.

This works in general, but there is one unexpected issue. On s390x, calls work by loading the return address into a "link register", which the callee will use to return back to the caller. This means of course that the call instruction clobbers that link register - so if the caller later has to return to its caller, it will need the original value of the link register at function entry, and therefore has to save/restore it.

This used to work fine since the link register is marked as "defined" by the call instruction. However, once call instructions are ignored via is_included_in_clobbers, that definition of the link register is also ignored. I would have expected that only the clobbers of the call instruction would be ignored - but the current implementation ignores the instruction completely.

Now, I can work around this by implicitly considering the link register clobbered in any non-leaf routine. But this seems a bit awkward. Any thoughts?

FYI @cfallin


Last updated: Nov 22 2024 at 16:03 UTC