RFR: 8345159: RISCV: Fix -Wzero-as-null-pointer-constant warning in emit_static_call_stub

Fei Yang fyang at openjdk.org
Tue Dec 3 03:43:37 UTC 2024


On Tue, 3 Dec 2024 00:28:14 GMT, Dean Long <dlong at openjdk.org> wrote:

>> Please review this change to RISCV code to remove a
>> -Wzero-as-null-pointer-constant warning in MacroAssembler::emit_static_call_stub.
>> 
>> It was calling MacroAssembler::movptr with the second (address) argument being
>> a literal 0. Rather than changing it to use nullptr for that argument, I've
>> instead changed it to call the movptr2 helper function, which takes the target
>> address as a unint64_t. This eliminates the conversion of 0 to a pointer and
>> then back to an integer 0. It seemed to me more natural to use that helper
>> directly, as it was presumed that was what ended up being called anyway. But
>> the riscv porters should weigh in on whether that's a good approach to dealing
>> with this case.
>> 
>> Testing: GHA sanity tests, which includes building for linux-riscv64.  I don't
>> have the capability to run tests for this platform, so hoping someone from the
>> riscv porters can do more testing.
>
> src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 788:
> 
>> 786:   // Jump to the entry point of the c2i stub.
>> 787:   int32_t offset = 0;
>> 788:   movptr2(t1, 0, offset, t0); // lui + lui + slli + add
> 
> How about something like this?
> Suggestion:
> 
>   address placeholder = pc(); // correct value will be patched in later
>   movptr2(t1, placeholder, offset, t0); // lui + lui + slli + add

That seems OK to me. Then we can still use `movptr` here.

  address placeholder = pc(); // correct value will be patched in later
  movptr(t1, placeholder, offset, t0); // lui + lui + slli + add

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22435#discussion_r1866991376


More information about the hotspot-compiler-dev mailing list