RFR: 8263718: unused-result warning happens at os_linux.cpp
Yasumasa Suenaga
ysuenaga at openjdk.java.net
Fri Mar 19 06:11:38 UTC 2021
On Fri, 19 Mar 2021 04:44:55 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>>> BTW this is not the first time we have had this issue with gcc making a
>>> function deprecated and casting to void not fixing it. Unfortunately I
>>> can't remember enough of the previous case's details to actually look it
>>> up and see what we resolved to do. :(
>>
>> I found [JDK-6879689](https://bugs.openjdk.java.net/browse/JDK-6879689), and it fixed unused-return as following:
>>
>> https://github.com/openjdk/jdk/blob/9b5a9b61899cf649104c0ff70e14549f64a89561/src/hotspot/share/adlc/archDesc.cpp#L1082-L1083
>>
>> I prefer it rather than `(void)!`.
>
>> > BTW this is not the first time we have had this issue with gcc making a
>> > function deprecated and casting to void not fixing it. Unfortunately I
>> > can't remember enough of the previous case's details to actually look it
>> > up and see what we resolved to do. :(
>>
>> I found [JDK-6879689](https://bugs.openjdk.java.net/browse/JDK-6879689), and it fixed unused-return as following:
>>
>> https://github.com/openjdk/jdk/blob/9b5a9b61899cf649104c0ff70e14549f64a89561/src/hotspot/share/adlc/archDesc.cpp#L1082-L1083
>>
>> I prefer it rather than `(void)!`.
>
> Does that work in release builds too?
I checked `alloca()` call on Fedora 33 x86_64 and Alpine 3.13 x86_64. Both of them seem to elide `alloca()`.
(It is fastdebug build - slow debug might be different, but production build might be same)
659 thread->record_stack_base_and_size();
0x00007ffff7154d44 <+20>: call 0x7ffff75b3a20 <_ZN6Thread26record_stack_base_and_sizeEv>
660
661 // Try to randomize the cache line index of hot stack frames.
662 // This helps when threads of the same stack traces evict each other's
663 // cache lines. The threads can be either from the same JVM instance, or
664 // from different JVM instances. The benefit is especially true for
665 // processors with hyperthreading technology.
666 static int counter = 0;
667 int pid = os::current_process_id();
668 alloca(((pid ^ counter++) & 7) * 128);
0x00007ffff7154d51 <+33>: addl $0x1,0xc1db10(%rip) # 0x7ffff7d72868 <_ZZL19thread_native_entryP6ThreadE7counter>
669
670 thread->initialize_thread_current();
=> 0x00007ffff7154d4e <+30>: mov %r13,%rdi
0x00007ffff7154d58 <+40>: call 0x7ffff75b3800 <_ZN6Thread25initialize_thread_currentEv>
> I prefer it rather than (void)!.
>
> Does that work in release builds too?
It will not work as David said :) we need to use `(void)!` if we should left it.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3042
More information about the hotspot-dev
mailing list