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

Robbin Ehn rehn at openjdk.org
Thu Nov 28 15:39:41 UTC 2024


On Thu, 28 Nov 2024 12:05:28 GMT, Kim Barrett <kbarrett 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.

Change is okay and I sanity tested, all ok.

But I must object to keep the underlying type of address.
For all our purposes it is an integer value.
I.e.
`address dest_end = dest->_total_start + dest->_total_size;`
Furthermore address 0 is a valid _address_, changing that to nullptr make little sense.

So I believe the correct fix is to change the type of address.

Anyhow thanks for fixing the warning.

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

Marked as reviewed by rehn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/22435#pullrequestreview-2468467704


More information about the hotspot-compiler-dev mailing list