Re: [PATCH v2 02/50] accel/tcg: Add getpc helper

Richard Henderson <[email protected]>
Newsgroups gmane.comp.emulators.qemu
Message-ID <[email protected]>
On 7/29/26 20:09, Anton Johansson via qemu development wrote:
> Introduces a helper function to return the current pc (returnaddress of
> the helper), this allows helper-to-tcg to correctly translate nested
> helper functions that checks for faulting memory operations.
> 
> This is useful as an optimization where a helper functions has a
> commonly taken fast path that doesn't fault e.g.
> 
>    void HELPER(outer)(...)
>    {
>        ... // non faulting operations
>        if (some_uncommon_condition) {
>            helper_inner(..., GETPC())
>        }
>    }
> 
> the outer helper along with the condition can then be emitted as TCG,
> and helper_inner() will be emitted as a gen_helper_inner(, ra), where ra
> is the result of gen_helper_getpc().
> 
> NOTE: This is not ideal since we're introducing extra helper calls,
>        and the solution doesn't deal with the "inner" function not being
>        a helper.  A better solution and what we'll probably do in the
>        next version of the patchset is to instead emit a helper
>        definition for the "inner" function that uses GETPC().

This is both confusing and wrong.

If you're transforming outer to hot tcg + cold helper, the cold helper would *still* use 
GETPC(), which would still produce an address within the jit code block for the guest 
instruction.


r~
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.