From patchwork Wed Jul 10 02:30:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1130111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-504789-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sQ/mAx5a"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45k38x2Fvfz9sN4 for ; Wed, 10 Jul 2019 12:31:20 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=C7u9f oWR3F8385cQJeG62F5Fg6nnNSM2AYSsnHreBVlCXq4UksCfNX3A4dehVkxbjwfFR 1y50KFDaTWCb1SeSMVIfA2WEwJNKlQhKWxkgEZxZ3Dh7Jjth0YjYh98aQTkVfKcw EdgjxnOEnL5O1h0Tho74dogsW4eD6DwXxfTMbI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=5cIp7Pkgm0x bQ3NL+1BvU9eBMgY=; b=sQ/mAx5aQoO5oejpNBcVfJAl+OPRqBmzHlFPlq8UmlX LaW1PyhY3jyGWDYtyCEBRMQXldoUYjUMPW8OKb5Znj2T2IOBXf2hvfvMGYX+OX51 1AQ9Yw8y2ChY/8bxSW9VxF+gY/xW+tEOOIcTb0sBrAZwX1F0w6xxjtiwUrkWC/qg = Received: (qmail 33713 invoked by alias); 10 Jul 2019 02:31:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 33705 invoked by uid 89); 10 Jul 2019 02:31:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Jul 2019 02:31:08 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6A2Qnrk110390 for ; Tue, 9 Jul 2019 22:31:06 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tn5n8b267-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Jul 2019 22:31:06 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jul 2019 03:31:04 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 10 Jul 2019 03:31:00 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6A2Uxxf49217550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jul 2019 02:30:59 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF2A852052; Wed, 10 Jul 2019 02:30:58 +0000 (GMT) Received: from kewenlins-mbp.cn.ibm.com (unknown [9.200.146.109]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id D423952051; Wed, 10 Jul 2019 02:30:57 +0000 (GMT) From: "Kewen.Lin" Subject: [PATCH] Add hints for slim dumping if fallthrough bb of jump isn't next bb To: GCC Patches Cc: Segher Boessenkool , Bill Schmidt Date: Wed, 10 Jul 2019 10:30:52 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 x-cbid: 19071002-0008-0000-0000-000002FB720B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19071002-0009-0000-0000-00002268D45B Message-Id: X-IsSubscribed: yes Hi all, 6: NOTE_INSN_BASIC_BLOCK 2 .... 12: r135:CC=cmp(r122:DI,0) 13: pc={(r135:CC!=0)?L52:pc} REG_DEAD r135:CC REG_BR_PROB 1041558836 31: L31: 17: NOTE_INSN_BASIC_BLOCK 3 The above RTL sequence is from pass doloop dumping with -fdump-rtl-all-slim, I misunderstood that: the fall through BB of BB 2 is BB 3, since BB 3 is placed just next to BB 2. Then I found the contradiction that BB 3 will have some uninitialized regs if it's true. I can get the exact information with "-blocks" dumping and even detailed one with "-details". But I'm thinking whether it's worth to giving some information on "-slim" dump (or more exactly without "-blocks") to avoid some confusion especially for new comers like me. This patch is to add one line to hint what's the fallthrough BB if it's the one closely sitting, for example: 6: NOTE_INSN_BASIC_BLOCK 2 .... 12: r135:CC=cmp(r122:DI,0) 13: pc={(r135:CC!=0)?L52:pc} REG_DEAD r135:CC REG_BR_PROB 1041558836 ;; pc falls through to BB 10 31: L31: 17: NOTE_INSN_BASIC_BLOCK 3 Bootstrapped and regression test passed on powerpc64le-unknown-linux-gnu. Is it a reasonable patch? If yes, is it ok for trunk? Thanks, Kewen --------- gcc/ChangeLog 2019-07-08 Kewen Lin * gcc/cfgrtl.c (print_rtl_with_bb): Check and call hint_if_pc_fall_through_not_next for jump insn with two successors. (hint_if_pc_fall_through_not_next): New function. diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index a1ca5992c41..928b9b0f691 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -2164,7 +2164,26 @@ rtl_dump_bb (FILE *outf, basic_block bb, int indent, dump_flags_t flags) } } - + +/* For dumping without specifying basic blocks option, when we see PC is one of + jump targets, it's easy to misunderstand the next basic block is the + fallthrough one, but it's not so true sometimes. This function is to dump + hints for the case where basic block of next insn isn't the fall through + target. */ + +static void +hint_if_pc_fall_through_not_next (FILE *outf, basic_block bb) +{ + gcc_assert (outf); + gcc_assert (EDGE_COUNT (bb->succs) >= 2); + const rtx_insn *einsn = BB_END (bb); + const rtx_insn *ninsn = NEXT_INSN (einsn); + edge e = FALLTHRU_EDGE (bb); + basic_block dest = e->dest; + if (BB_HEAD (dest) != ninsn) + fprintf (outf, ";; pc falls through to BB %d\n", dest->index); +} + /* Like dump_function_to_file, but for RTL. Print out dataflow information for the start of each basic block. FLAGS are the TDF_* masks documented in dumpfile.h. */ @@ -2255,6 +2274,14 @@ print_rtl_with_bb (FILE *outf, const rtx_insn *rtx_first, dump_flags_t flags) putc ('\n', outf); } } + else if (GET_CODE (tmp_rtx) == JUMP_INSN + && GET_CODE (PATTERN (tmp_rtx)) == SET) + { + bb = BLOCK_FOR_INSN (tmp_rtx); + const_rtx src = SET_SRC (PATTERN (tmp_rtx)); + if (bb != NULL && GET_CODE (src) == IF_THEN_ELSE) + hint_if_pc_fall_through_not_next (outf, bb); + } } free (start);