From: Kito Cheng <kito.cheng@sifive.com>
To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com,
jim.wilson.gcc@gmail.com, jbglaw@lug-owl.de, andrew@sifive.com,
palmer@dabbelt.com
Cc: Kito Cheng <kito.cheng@sifive.com>
Subject: [committed] RISC-V: Suppress -Wclass-memaccess warning
Date: Mon, 29 Aug 2022 10:36:13 +0800 [thread overview]
Message-ID: <20220829023613.30217-1-kito.cheng@sifive.com> (raw)
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
reply other threads:[~2022-08-29 2:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220829023613.30217-1-kito.cheng@sifive.com \
--to=kito.cheng@sifive.com \
--cc=andrew@sifive.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jbglaw@lug-owl.de \
--cc=jim.wilson.gcc@gmail.com \
--cc=kito.cheng@gmail.com \
--cc=palmer@dabbelt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).