Skip to content

Commit 68b6e11

Browse files
committed
8270083: -Wnonnull errors happen with GCC 11.1.1
Reviewed-by: erikj, dlong, kbarrett
1 parent ec975c6 commit 68b6e11

9 files changed

Lines changed: 42 additions & 4 deletions

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
@@ -7427,6 +7427,10 @@ void Assembler::evprolq(XMMRegister dst, XMMRegister src, int shift, int vector_
74277427
emit_int24(0x72, (0xC0 | encode), shift & 0xFF);
74287428
}
74297429

7430+
// Register is a class, but it would be assigned numerical value.
7431+
// "0" is assigned for xmm0. Thus we need to ignore -Wnonnull.
7432+
PRAGMA_DIAG_PUSH
7433+
PRAGMA_NONNULL_IGNORED
74307434
void Assembler::evprord(XMMRegister dst, XMMRegister src, int shift, int vector_len) {
74317435
assert(VM_Version::supports_evex(), "requires EVEX support");
74327436
assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), "requires VL support");
@@ -7444,6 +7448,7 @@ void Assembler::evprorq(XMMRegister dst, XMMRegister src, int shift, int vector_
74447448
int encode = vex_prefix_and_encode(xmm0->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
74457449
emit_int24(0x72, (0xC0 | encode), shift & 0xFF);
74467450
}
7451+
PRAGMA_DIAG_POP
74477452

74487453
void Assembler::evprolvd(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) {
74497454
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
@@ -227,6 +227,10 @@ inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {
227227

228228
// Compiled frames
229229

230+
// Register is a class, but it would be assigned numerical value.
231+
// "0" is assigned for rax. Thus we need to ignore -Wnonnull.
232+
PRAGMA_DIAG_PUSH
233+
PRAGMA_NONNULL_IGNORED
230234
inline oop frame::saved_oop_result(RegisterMap* map) const {
231235
oop* result_adr = (oop *)map->location(rax->as_VMReg());
232236
guarantee(result_adr != NULL, "bad register save location");
@@ -240,5 +244,6 @@ inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
240244

241245
*result_adr = obj;
242246
}
247+
PRAGMA_DIAG_POP
243248

244249
#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_vectors) {
172176
int off = 0;
173177
int num_xmm_regs = XMMRegisterImpl::number_of_registers;
@@ -360,6 +364,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_
360364

361365
return map;
362366
}
367+
PRAGMA_DIAG_POP
363368

364369
void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_vectors) {
365370
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
@@ -580,6 +580,10 @@ struct AuxiliarySaves {
580580
bool should_detach;
581581
};
582582

583+
// Register is a class, but it would be assigned numerical value.
584+
// "0" is assigned for rax and for xmm0. Thus we need to ignore -Wnonnull.
585+
PRAGMA_DIAG_PUSH
586+
PRAGMA_NONNULL_IGNORED
583587
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry, jobject jabi, jobject jconv) {
584588
ResourceMark rm;
585589
const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi);
@@ -844,6 +848,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
844848

845849
return blob->code_begin();
846850
}
851+
PRAGMA_DIAG_POP
847852

848853
bool ProgrammableUpcallHandler::supports_optimized_upcalls() {
849854
return true;

src/hotspot/share/utilities/compilerWarnings.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 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
@@ -66,4 +66,8 @@
6666
#define PRAGMA_STRINGOP_TRUNCATION_IGNORED
6767
#endif
6868

69+
#ifndef PRAGMA_NONNULL_IGNORED
70+
#define PRAGMA_NONNULL_IGNORED
71+
#endif
72+
6973
#endif // SHARE_UTILITIES_COMPILERWARNINGS_HPP

src/hotspot/share/utilities/compilerWarnings_gcc.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 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
@@ -50,6 +50,9 @@
5050
#define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation")
5151
#endif
5252

53+
#define PRAGMA_NONNULL_IGNORED \
54+
PRAGMA_DISABLE_GCC_WARNING("-Wnonnull")
55+
5356
#if defined(__clang_major__) && \
5457
(__clang_major__ >= 4 || \
5558
(__clang_major__ >= 3 && __clang_minor__ >= 1)) || \

0 commit comments

Comments
 (0)