From patchwork Sun Jul 9 16:07:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 9831819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C650960318 for ; Sun, 9 Jul 2017 16:07:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD0DD283C3 for ; Sun, 9 Jul 2017 16:07:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EC55283D8; Sun, 9 Jul 2017 16:07:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27D8A283C3 for ; Sun, 9 Jul 2017 16:07:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752295AbdGIQHH (ORCPT ); Sun, 9 Jul 2017 12:07:07 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:35431 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751946AbdGIQHH (ORCPT ); Sun, 9 Jul 2017 12:07:07 -0400 Received: by mail-pg0-f44.google.com with SMTP id j186so37794524pge.2 for ; Sun, 09 Jul 2017 09:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to:cc; bh=5FOjQTQ9281oeOBHI4YkrequmwdJ03uZvHdN0lIbnLo=; b=Kj2tfesHBwbNe8N0aXw10Zs+hx82DFGLWY27N6diWPo5uDzBmQkgE48V1RLKsnNKLF jqHL+CR9616LW5WNIBhWxzjmwCHNb4wif05OYLAsOzUwSOyJOdaASZ2/Z34211w5B8dT xGi90RcvBXwN7KjYx0jr9V9OfIjWbPj4jPQuqWGHyAcNOjCDcKMNKI1kldClT8ZB42Rc 9HxBEWBPw4nYvOK/opv0pm2N1s3SB4gqZRKrIGfYWmC65Fow8MpGnRV35fKg4QvY4c/7 S1eM7C1RNd8vs7QEF/Nz+q2okGfgmTALT/6UM47qbULkTkbTjdycMyW+VV+/gvB+WN/U x4ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:cc; bh=5FOjQTQ9281oeOBHI4YkrequmwdJ03uZvHdN0lIbnLo=; b=hBiszPYoyQACN7kXtd1uiCRLThZC0jp+sowr6MAf495sjNllShZeq1T0EAzK+8U15q wytI52HjVpCD/mIPQKKWjNtaplaXuLW+FrPYfkf5wYbe4ilHSrK/YFLDtTmtt6PExLHD xKxElXy+t1eJRTEBw+dPeXgxa49xUdgOeXnz1Fj0/rLGyNyG3ix2nKePED8weZ/SPk89 hzsyMZ8uy/tYr1Z2woJzORvksG34olLZGwKCtOWl5iZrQtoNUFaep76zuv9FYAqsLNR4 wzFOIZZ53og9ZDPeyrNemmlYa6k/Dl7Meoqqx2iGG/ttxd7OR7efC1ImeLNvZvK1VVXY Cv/g== X-Gm-Message-State: AIVw111SfDykbcTC6/PpltMConYLRMZfPApaCVRNXnSwdEeIixMIM/qK hjH5dMMAZj7H1KgFTt6V3oA5MXVJNQ== X-Received: by 10.84.172.1 with SMTP id m1mr13432827plb.174.1499616426673; Sun, 09 Jul 2017 09:07:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.149.130 with HTTP; Sun, 9 Jul 2017 09:07:06 -0700 (PDT) From: Christopher Li Date: Sun, 9 Jul 2017 09:07:06 -0700 X-Google-Sender-Auth: cqWZY4SapjQ1r3TSagwuc8RiSwA Message-ID: Subject: [PATCH] V2 move kill_unreachable_bbs to outer cse stage Was Re: [PATCH 1/5] do not corrupt ptrlist while killing unreachable BBs To: Luc Van Oostenryck Cc: Linux-Sparse Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sun, Jul 9, 2017 at 3:26 AM, Luc Van Oostenryck wrote: >> >> - repeat_phase &= ~REPEAT_CFG_CLEANUP; >> + repeat_phase |= REPEAT_CSE ; > > It would be good to add a comment for why the '|= REPEAT_CSE' is needed here. > You are right. Actually I just find out that is not needed. I was having impression that I need that to pass one of the test-suit. It seems fine without. It pass the full kernel check as well. It is likely due to I have an unclean tree of the ptr ref count stuff. Patch refreshed. https://git.kernel.org/pub/scm/devel/sparse/sparse.git/log/?h=sparse-next-20170709 Thanks Chris From 484a3a27d95b4bf3be9ac4b9bcf1aca1abe3ac19 Mon Sep 17 00:00:00 2001 From: Christopher Li Date: Sat, 8 Jul 2017 19:34:49 -0700 Subject: [PATCH] move kill_unreachable_bbs to outer cse stage The current way of kill_unreach_bbs in insert_branch() cause delete entry in ptrlist that the upper level caller is looping on. Move it outside to the cse stage avoid that problem. Reported-by: Luc Van Oostenryck Signed-of-By: Christopher Li --- cse.c | 3 +++ flow.c | 2 -- linearize.c | 3 --- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cse.c b/cse.c index 0d3815c..af9863f 100644 --- a/cse.c +++ b/cse.c @@ -387,6 +387,9 @@ repeat: } } + if (repeat_phase & REPEAT_CFG_CLEANUP) + kill_unreachable_bbs(ep); + if (repeat_phase & REPEAT_SYMBOL_CLEANUP) simplify_memops(ep); diff --git a/flow.c b/flow.c index c7161d4..fce8bde 100644 --- a/flow.c +++ b/flow.c @@ -840,8 +840,6 @@ void kill_unreachable_bbs(struct entrypoint *ep) DELETE_CURRENT_PTR(bb); } END_FOR_EACH_PTR(bb); PACK_PTR_LIST(&ep->bbs); - - repeat_phase &= ~REPEAT_CFG_CLEANUP; } static int rewrite_parent_branch(struct basic_block *bb, struct basic_block *old, struct basic_block *new) diff --git a/linearize.c b/linearize.c index 7313e72..a367207 100644 --- a/linearize.c +++ b/linearize.c @@ -671,9 +671,6 @@ void insert_branch(struct basic_block *bb, struct instruction *jmp, struct basic remove_parent(child, bb); } END_FOR_EACH_PTR(child); PACK_PTR_LIST(&bb->children); - - if (repeat_phase & REPEAT_CFG_CLEANUP) - kill_unreachable_bbs(bb->ep); }