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: 1671252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=Ffi/yKbN; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MGF1x6sk7z1yh9 for ; Mon, 29 Aug 2022 12:36:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A7BC3858289 for ; Mon, 29 Aug 2022 02:36:31 +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-Google-Smtp-Source: AA6agR4o239PU0VneBxvgRv1ek9fIkgx2l1crVnrv/x6Oc1gyqISX9F1inIgx31ujrVUHW9JXcXcbQ== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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) {