[committed] RISC-V: Suppress -Wclass-memaccess warning
Commit Message
poly_int64 is non-trivial type, we need to clean up manully instead
of memset to prevent this warning.
../../gcc/gcc/config/riscv/riscv.cc: In function 'void riscv_compute_frame_info()':
../../gcc/gcc/config/riscv/riscv.cc:4113:10: error: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct riscv_frame_info'; use assignment or value-initialization instead [-Werror=class-memaccess]
4113 | memset (frame, 0, sizeof (*frame));
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/riscv/riscv.cc:101:17: note: 'struct riscv_frame_info' declared here
101 | struct GTY(()) riscv_frame_info {
| ^~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_frame_info): Introduce `reset(void)`;
(riscv_frame_info::reset(void)): New.
(riscv_compute_frame_info): Use riscv_frame_info::reset instead
of memset when clean frame.
---
gcc/config/riscv/riscv.cc | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
@@ -123,6 +123,9 @@ struct GTY(()) riscv_frame_info {
/* The offset of arg_pointer_rtx from the bottom of the frame. */
poly_int64 arg_pointer_offset;
+
+ /* Reset this struct, clean all field to zero. */
+ void reset(void);
};
enum riscv_privilege_levels {
@@ -392,6 +395,23 @@ static const struct riscv_tune_info riscv_tune_info_table[] = {
{ "size", generic, &optimize_size_tune_info },
};
+void riscv_frame_info::reset(void)
+{
+ total_size = 0;
+ mask = 0;
+ fmask = 0;
+ save_libcall_adjustment = 0;
+
+ gp_sp_offset = 0;
+ fp_sp_offset = 0;
+
+ frame_pointer_offset = 0;
+
+ hard_frame_pointer_offset = 0;
+
+ arg_pointer_offset = 0;
+}
+
/* Implement TARGET_MIN_ARITHMETIC_PRECISION. */
static unsigned int
@@ -4179,7 +4199,7 @@ riscv_compute_frame_info (void)
interrupt_save_prologue_temp = true;
}
- memset (frame, 0, sizeof (*frame));
+ frame->reset();
if (!cfun->machine->naked_p)
{