Skip to content

Commit 5d35f53

Browse files
committed
8270083: -Wnonnull errors happen with GCC 11.1.1
Reviewed-by: shade Backport-of: 68b6e11e481349e40014aa4593a53ae2ea74aedc
1 parent f796f9e commit 5d35f53

File tree

9 files changed

+40
-2
lines changed

9 files changed

+40
-2
lines changed

make/hotspot/lib/JvmOverrideFiles.gmk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@ ifeq ($(TOOLCHAIN_TYPE), gcc)
3636
BUILD_LIBJVM_assembler_x86.cpp_CXXFLAGS := -Wno-maybe-uninitialized
3737
BUILD_LIBJVM_cardTableBarrierSetAssembler_x86.cpp_CXXFLAGS := -Wno-maybe-uninitialized
3838
BUILD_LIBJVM_interp_masm_x86.cpp_CXXFLAGS := -Wno-uninitialized
39+
BUILD_LIBJVM_ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp_CXXFLAGS := -Wno-nonnull
3940
ifeq ($(DEBUG_LEVEL), release)
4041
# Need extra inlining to collapse shared marking code into the hot marking loop
4142
BUILD_LIBJVM_shenandoahMark.cpp_CXXFLAGS := --param inline-unit-growth=1000

src/hotspot/cpu/x86/assembler_x86.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7546,6 +7546,10 @@ void Assembler::evprolq(XMMRegister dst, XMMRegister src, int shift, int vector_
75467546
emit_int24(0x72, (0xC0 | encode), shift & 0xFF);
75477547
}
75487548

7549+
// Register is a class, but it would be assigned numerical value.
7550+
// "0" is assigned for xmm0. Thus we need to ignore -Wnonnull.
7551+
PRAGMA_DIAG_PUSH
7552+
PRAGMA_NONNULL_IGNORED
75497553
void Assembler::evprord(XMMRegister dst, XMMRegister src, int shift, int vector_len) {
75507554
assert(VM_Version::supports_evex(), "requires EVEX support");
75517555
assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), "requires VL support");
@@ -7563,6 +7567,7 @@ void Assembler::evprorq(XMMRegister dst, XMMRegister src, int shift, int vector_
75637567
int encode = vex_prefix_and_encode(xmm0->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
75647568
emit_int24(0x72, (0xC0 | encode), shift & 0xFF);
75657569
}
7570+
PRAGMA_DIAG_POP
75667571

75677572
void Assembler::evprolvd(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) {
75687573
assert(VM_Version::supports_evex(), "requires EVEX support");

src/hotspot/cpu/x86/c1_Runtime1_x86.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,11 @@ enum reg_save_layout {
318318
// expensive. The deopt blob is the only thing which needs to
319319
// describe FPU registers. In all other cases it should be sufficient
320320
// to simply save their current value.
321-
321+
//
322+
// Register is a class, but it would be assigned numerical value.
323+
// "0" is assigned for rax. Thus we need to ignore -Wnonnull.
324+
PRAGMA_DIAG_PUSH
325+
PRAGMA_NONNULL_IGNORED
322326
static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args,
323327
bool save_fpu_registers = true) {
324328

@@ -418,6 +422,7 @@ static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args,
418422

419423
return map;
420424
}
425+
PRAGMA_DIAG_POP
421426

422427
#define __ this->
423428

src/hotspot/cpu/x86/frame_x86.inline.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {
230230

231231
// Compiled frames
232232

233+
// Register is a class, but it would be assigned numerical value.
234+
// "0" is assigned for rax. Thus we need to ignore -Wnonnull.
235+
PRAGMA_DIAG_PUSH
236+
PRAGMA_NONNULL_IGNORED
233237
inline oop frame::saved_oop_result(RegisterMap* map) const {
234238
oop* result_adr = (oop *)map->location(rax->as_VMReg());
235239
guarantee(result_adr != NULL, "bad register save location");
@@ -243,5 +247,6 @@ inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
243247

244248
*result_adr = obj;
245249
}
250+
PRAGMA_DIAG_POP
246251

247252
#endif // CPU_X86_FRAME_X86_INLINE_HPP

src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@ class ZSaveLiveRegisters {
465465
_spill_offset += 8;
466466
}
467467

468+
// Register is a class, but it would be assigned numerical value.
469+
// "0" is assigned for rax. Thus we need to ignore -Wnonnull.
470+
PRAGMA_DIAG_PUSH
471+
PRAGMA_NONNULL_IGNORED
468472
void initialize(ZLoadBarrierStubC2* stub) {
469473
// Create mask of caller saved registers that need to
470474
// be saved/restored if live
@@ -540,6 +544,7 @@ class ZSaveLiveRegisters {
540544
// Stack pointer must be 16 bytes aligned for the call
541545
_spill_offset = _spill_size = align_up(xmm_spill_size + gp_spill_size + opmask_spill_size + arg_spill_size, 16);
542546
}
547+
PRAGMA_DIAG_POP
543548

544549
public:
545550
ZSaveLiveRegisters(MacroAssembler* masm, ZLoadBarrierStubC2* stub) :

src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ class RegisterSaver {
168168
static void restore_result_registers(MacroAssembler* masm);
169169
};
170170

171+
// Register is a class, but it would be assigned numerical value.
172+
// "0" is assigned for rax. Thus we need to ignore -Wnonnull.
173+
PRAGMA_DIAG_PUSH
174+
PRAGMA_NONNULL_IGNORED
171175
OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words, bool save_wide_vectors) {
172176
int off = 0;
173177
int num_xmm_regs = XMMRegisterImpl::number_of_registers;
@@ -361,6 +365,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_
361365

362366
return map;
363367
}
368+
PRAGMA_DIAG_POP
364369

365370
void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_wide_vectors) {
366371
int num_xmm_regs = XMMRegisterImpl::number_of_registers;

src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,10 @@ static void shuffle_arguments(MacroAssembler* _masm, const GrowableArray<ArgMove
587587
}
588588
}
589589

590+
// Register is a class, but it would be assigned numerical value.
591+
// "0" is assigned for rax and for xmm0. Thus we need to ignore -Wnonnull.
592+
PRAGMA_DIAG_PUSH
593+
PRAGMA_NONNULL_IGNORED
590594
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry, jobject jabi, jobject jconv) {
591595
ResourceMark rm;
592596
const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi);
@@ -779,6 +783,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
779783

780784
return blob->code_begin();
781785
}
786+
PRAGMA_DIAG_POP
782787

783788
bool ProgrammableUpcallHandler::supports_optimized_upcalls() {
784789
return true;

src/hotspot/share/utilities/compilerWarnings.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@
7474
#define PRAGMA_INFINITE_RECURSION_IGNORED
7575
#endif
7676

77+
#ifndef PRAGMA_NONNULL_IGNORED
78+
#define PRAGMA_NONNULL_IGNORED
79+
#endif
80+
7781
#endif // SHARE_UTILITIES_COMPILERWARNINGS_HPP

src/hotspot/share/utilities/compilerWarnings_gcc.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
#define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation")
5959
#endif
6060

61+
#define PRAGMA_NONNULL_IGNORED \
62+
PRAGMA_DISABLE_GCC_WARNING("-Wnonnull")
63+
6164
#if defined(__clang_major__) && \
6265
(__clang_major__ >= 4 || \
6366
(__clang_major__ >= 3 && __clang_minor__ >= 1)) || \

0 commit comments

Comments
 (0)