From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1259B3865C2B; Wed, 20 Dec 2023 15:58:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1259B3865C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1703087900; bh=PCEvOjQXVpCRiGLevtkywidRA5erV4M65sED2kyALYs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=e0szQF5b7cc+Xy2J+fZuf9ZpV99ODN7T/qMB13Ys32ZszHvrSOXh4vkMZyYFa4iME G8phpQsS5yr34SNCO78hI7a3c4RxSLuWkZF7dphOfqnwx4G68FiewO8rCF0cuTOdID uAGIwWNE3vxh2gBov6xQarRA0Z9cdw6G46YXJ+6E= From: "hp at sourceware dot org" To: gdb-prs@sourceware.org Subject: [Bug sim/31181] sim: cris: decode unused base_insn variable warnings Date: Wed, 20 Dec 2023 15:58:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: sim X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hp at sourceware dot org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31181 --- Comment #5 from Hans-Peter Nilsson --- (In reply to Mike Frysinger from comment #4) > (In reply to Hans-Peter Nilsson from comment #3) > > My point is that *these two files* would be the only files that got > > -Wno-error=3Dunused-variable. >=20 > i understand what you're suggesting. my point still stands. this assumes > that the toolchain used to compile the sim recognizes & accepts (or silen= tly > ignores) "-Wno-error=3Dunused-variable".=20 I don't think that's necessary: warnings are only enabled for gcc, and for developer mode. Developers can be expected to have a sufficiently modern g= cc.=20 I see it works for gcc-10 (Debian 11). > the sim, like all binutils+gdb > projects, test the toolchain and whether it supports -W flags before using > them. we have to add a test for -Wno-error=3Dunused-variable, a variable= for > it, and then expand that for these 2 files. Nah, that seems a bit overthinking it. Adding it when warnings are enabled should be sufficient. Alternatively, we can just add a "-Wno-error" like t= he extant cases. > seems a lot easier to fix the > origin, especially when enabling warnings has a proven history of uncover= ing > real bugs. >=20 > > You say, you've looked for, but not found, a > > bug-reason why the warnings appear, in this generated code, presumably > > including looking at the generator. >=20 > the generator appears to be cgen lisp which uses the lisp cpu definitions= .=20 > the cgen code is not easy to follow at all, or trace back which funcs > generate which lines. i was hoping you, as author of much of this code, > would be able to pick out & fix things much quicker than i. Fair enough. I had a quick look. First a look at the apparent sites of the warnings (N.B.: only the ones quo= ted in this PR, I don't have a new enough gcc to emit those particular ones). = The *immediate* causes for each and every one of those, i.e. why "insn" isn't u= sed, is that the insn in the self-named variable is fully decoded for the cases corresponding to the warnings, and no sub-fields need to be inspected. Any operand is in the next 16- or 32-bit word. The *immediate* cause is hereby analyzed as innocuous and AFAIU typical for auto-generated code. ;) CGEN apparently emits a generic template containing "CGEN_INSN_WORD insn =3D base_insn;". That template can be improved with a "generic" use of the variable insn, like appending a "(void) insn;" in the generated code, with a suitable comment nearby in the generator, like 'The insn may be fully decod= ed at this point. Add an artificial use to avoid compiler warnings about insn= not being used.'. But, for that kind of change, this PR should be redirected to that project,= as the template is there, in cgen/sim-decode.scm according to git grep. (FAOD: the above is merely a suggestion; not volunteering myself. I'd go w= ith the -Wno-error.) --=20 You are receiving this mail because: You are on the CC list for the bug.=