* [committed] RISC-V: Suppress -Wclass-memaccess warning
@ 2022-08-29 2:36 Kito Cheng
0 siblings, 0 replies; only message in thread
From: Kito Cheng @ 2022-08-29 2:36 UTC (permalink / raw)
To: gcc-patches, kito.cheng, jim.wilson.gcc, jbglaw, andrew, palmer
Cc: Kito Cheng
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(-)
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 6341dc98daa..4d439e15392 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -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)
{
--
2.37.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-29 2:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29 2:36 [committed] RISC-V: Suppress -Wclass-memaccess warning Kito Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).