RFR: 8347901: C2 should remove unused leaf / pure runtime calls
Quan Anh Mai
qamai at openjdk.org
Tue May 13 03:14:55 UTC 2025
On Mon, 12 May 2025 21:01:34 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>> I think a very simple approach you can take is having `CallPureNode` as a pure data node. It does not have to have anything to do with `CallNode` (no lowering into a `CallNode`, no subclass from `CallNode`) and it can have its mach implementation like this:
>>
>> instruct pureCall1F(xmm0 dst, xmm0 src) %{
>> match(Set dst (CallPure src));
>> effect(CALL);
>> format %{
>> __ call(/*something*/);
>> %}
>> %}
>
>> I think a very simple approach you can take is having CallPureNode as a pure data node
>
> It's not as simple as it seems. In order to work reliably it requires full control of the code being called, so without extra work it is appropriate for generated stubs only. If you want to call some native code VM doesn't control, then either all caller-saved registers should be preserved across the call (which may be prohibitively expensive) or it should be made explicit there's a call taking place so all ABI effects are taken into account.
@iwanowww I believe `effect(CALL)` marks that a call is taking place and the register allocator will know how to save the registers accordingly. Note that on arm, long division is implemented as a call:
https://github.com/openjdk/jdk/blob/adebfa7ffda6383f5793278ced14a193066c5f6a/src/hotspot/cpu/arm/arm.ad#L5962
And `SharedRuntime::ldiv` is implemented in C++:
https://github.com/openjdk/jdk/blob/adebfa7ffda6383f5793278ced14a193066c5f6a/src/hotspot/share/runtime/sharedRuntime.cpp#L272
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24966#issuecomment-2874936879
More information about the graal-dev
mailing list