From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E0B4E3959C5F; Wed, 6 May 2020 18:44:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0B4E3959C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588790649; bh=nUtKgWSw5ACUFDD2YYsDeSywcUyQZ+Agyu0kLyKBx8M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CPn9WUG2lDu4mAeEt6su+wgObcfAUIM7faV7p3EsJGj374fjoCeN8dvGhgbIPopkn c0CmYXJUipt/iXDAOtnQAioDu3YnVH8+dbqEWdiSskI4j+KFp/+ZJEWnGGvp0m38ao ZKHm3GsP9AKV4XWAmiHnU1ldbHPi1E3uPbGNZEuo= From: "nisse at lysator dot liu.se" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/4210] should not warn in dead code Date: Wed, 06 May 2020 18:44:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 3.0.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: nisse at lysator dot liu.se X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.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://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 May 2020 18:44:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D4210 --- Comment #41 from Niels M=C3=B6ller --- (In reply to Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez from comment #39) > You can easily find which pass does something by dumping (-ftree-dump-*) > all of them and comparing them. It's -ftree-dump-all, and also -fdump-passes was useful. Thanks! I'm now compiling without optimization to (i) reduce number of passes, and (ii) bec= ause it would be nice to get it right also in absence of optimization options. It looks like the dead code is eliminated by the "cfg" (control flow graph) pass, in gcc/tree-cfg.c. In the .cfg dumpfile it says "Removing basic block= 3", and the invalid shift disappears in that dump. That's nice. Immediately aft= er this pass comes *warn_function_return, implemented in the same file. It would make sense to me to add a pass to warn about shift operations with invalid constant operands at about the same place. Is it easy to traverse a gimple function, and check all expressions? The "*warn_unused_result" pass seems to do a similar traversal (but examining statements rather than expressions, and done *before* the cfg pass).=