From patchwork Mon Aug 29 02:36:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1232154wro; Sun, 28 Aug 2022 19:36:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR4cLtPDs6R0aFC83fDPJQihnKkrRsJmB/fFlVF0tpE+VKV/mexgzphjawL/6WZZLmcXqZMj X-Received: by 2002:a17:906:794c:b0:73d:b881:e3fe with SMTP id l12-20020a170906794c00b0073db881e3femr11463926ejo.570.1661740615835; Sun, 28 Aug 2022 19:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661740615; cv=none; d=google.com; s=arc-20160816; b=DDLC+gQqXgBBwDT6Im4ksUaqX8jQKync7x07uicjoK6O4FjVWVHA0/YiGU1lAyFOBF Is56DJlqJ90ZlTaUcahuTvI20wBSNmooBG3L9PxxRJpchMBZ4GLRtuN3etxx/kp8Bozq kRdHeHKpW9ZxYTCIyCYdrATfrK9Zq/b990+hu4L8ENqS3xR211XRVDGwnHFpq93M6s6c C1BphM5ToUokV2cmQQobXpUs83J9aj2639+55wpkP6jNbcyYgXOCJLVZelWZtn0L1FEC tI4TaYl1Jeu1sjSbk7OCy4gpkCi6yYrMB7hTcSGyvtcwVv3TkSny0QtDz1AiX3O7xyYm VlgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=mVOy6R+xlKVWsBHbuclRWerhOrqPKEbDiHns12HbdI0=; b=SkogmkNGGRhIWQj8CcRO7c/k5cFFkDexwxxCL/deg15EcApg1le5uyI0C1pIUfrdop p915qHGk3xlvMmIGZhBPPU7gFMJ/cmWUJgd+RSfwaR87IHkAt7l4ahpAesNsKvsoDxHl Jr8fFv/MQ3EKT/fTHetgEiGpDbu/WEKn01DKTWjuuI4kPinmfaeltQvPwiBoOV6gUonc 3X2/A3FsePe4Doc9qk0/sI0LuoqYriBQJaUBJhYt7iTefhdEoaD3j732zPNXycFtYobd lInrPCxNpxzq9d9MYwrVsOgMcyDtRBNL2AMXcbMlq5et7+G8Or09GMD09CvThIZqqNlT 6lXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="Ffi/yKbN"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id js22-20020a17090797d600b0073101e55d9fsi6457386ejc.797.2022.08.28.19.36.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 19:36:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="Ffi/yKbN"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 133D6385782D for ; Mon, 29 Aug 2022 02:36:43 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 4F1D63858D1E for ; Mon, 29 Aug 2022 02:36:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4F1D63858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pj1-x1035.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so2829817pjq.3 for ; Sun, 28 Aug 2022 19:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=mVOy6R+xlKVWsBHbuclRWerhOrqPKEbDiHns12HbdI0=; b=Ffi/yKbNG5VfTfC/fofTvcWP128UX7T5EaEy4guGI34WEHHmrGLg6OVGveeWQCc6ML +xf9mgVT7+1FGZFcoyeVnBjOUIaMmODYpzlauqe10WCiUrm8oLAJVBiNRg9KX//r9Rb5 XqmYzav/6ovu5PU81QaCG+u+kjljihwh1i0fdHfzIwTqDWbgETwPMyDiwkGb7hxZfvRN if/f8zVKQ84WRRB7f+PcTIhMHtlqzHNlwNifzcopkyypdrcv8ilWaKHeUtsKBqHx/QiO aOZ1tKo/1fzfzBVAVLQc07u21GsUvm/ukergq18x6SiIrC+KtbAN4qi5LEdApDmUZOUW Ki+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=mVOy6R+xlKVWsBHbuclRWerhOrqPKEbDiHns12HbdI0=; b=hpxTWOUP2s7eTIwU3mgLOHpFReAdweGExoNdT+bs3UJTQcISQn3+wXdN/ZT6Cvmkhp AAIiA3i+KCPpI1BZXt/dVeXbqd1rvJ0by+EG3lwSZ4vv4D3m5x1VwOczy0iKvFu3R0ku s8IgRJtMHwcdem/WX5EKpcyMDzXbr1v4u4CHfwck+v84sBWFq+OeOmVZCGwJJktfPVmQ 21yHmWvmRCo3ZpDNGAdohFeahk5esdwMGyhTHX1v+gEpbqEw9caegNSYs5MG4vTZpVJ9 Fx5NRdcNJ28qZJ/bbZ3MjdL55TWvBibXeHhkQaEK4mpbXxKLrzEm13Z52gXpcY0X37vB Jywg== X-Gm-Message-State: ACgBeo0aMDfsq5VUqdheIKrR7TrWinDKUKnow8GxjoWEY7Y2zdUZQ0bO sB56HOITZLmjVLwXSailgpMeKJibv5SsAg== X-Received: by 2002:a17:90b:224c:b0:1fb:4df6:8b5f with SMTP id hk12-20020a17090b224c00b001fb4df68b5fmr16406198pjb.167.1661740577530; Sun, 28 Aug 2022 19:36:17 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id z16-20020aa79490000000b00538147b1a38sm2135856pfk.160.2022.08.28.19.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 19:36:16 -0700 (PDT) From: Kito Cheng 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 Subject: [committed] RISC-V: Suppress -Wclass-memaccess warning Date: Mon, 29 Aug 2022 10:36:13 +0800 Message-Id: <20220829023613.30217-1-kito.cheng@sifive.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kito Cheng Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742461328090303771?= X-GMAIL-MSGID: =?utf-8?q?1742461328090303771?= 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) {