From patchwork Mon Jul 10 15:32:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 9833265 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 1372A60350 for ; Mon, 10 Jul 2017 15:32:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26B6B205D6 for ; Mon, 10 Jul 2017 15:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B270284F7; Mon, 10 Jul 2017 15:32:56 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 A3F01205D6 for ; Mon, 10 Jul 2017 15:32:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754374AbdGJPcy (ORCPT ); Mon, 10 Jul 2017 11:32:54 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:33821 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754363AbdGJPcw (ORCPT ); Mon, 10 Jul 2017 11:32:52 -0400 Received: by mail-pg0-f49.google.com with SMTP id t186so51536611pgb.1 for ; Mon, 10 Jul 2017 08:32:52 -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=GgQYHveu3BRjWMvknRXU6GD5IBHhhUO/vZILoQ0uSbs=; b=gt4wWzYvdFwqNJu6nw7vM/I2P1PMAPHLbUiGqoIO5qeL6Bt95+x3qgDPjp0xe/c0/j 9M8Dtm6130VE12baO46HLk2Cgxh0dqZtA6eEtnFP/48JaYetmwq1m9Z5bKCC08zwtwQZ d18ttHhtvxg4BYQ6EjSfCdvK46CWrta4hhpA6YpQoYNCykheAzrMroCKYluXUnpwT+uI tyhO1UtgyXkhh8fFr1rIFboA/T0p/vBDkR6GaM+Y7QqsKw0TLd8WGWXPZivlt4eBcljL 7ytF/45rZ7VX0083UdNIR42hF9gMjV0QR3l2llMaiKUvqTNTf2fKjKvcGmHXl+9sOeQM i5Fg== 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=GgQYHveu3BRjWMvknRXU6GD5IBHhhUO/vZILoQ0uSbs=; b=s77fEhjqmFvhPS3jqeax8dMakPXgW5DRVsFNAsSJJCDHqZ66kYKDp9lZh3Nb+LOIIi kGkluoSp50JvKtJ6nNt7w78pbXsiPJmYbSHDjhq5WC8tUzsgOZWrCUAje8uGMyW2gyQe 7Ah6b+HTpdvia4LAB3UUIiqWNorVwF+qzHkvugQZ2JmggE6xSDBbsSb0SRAGWjFowyf8 FTfPXBCTk5vEffG3bU3EJA3bGWnQDOCf023Ee5jbkSO/CmUwpZB1FHaRVyGwGXk1C5Vl 2E12y4J5uC0VRpAQfBep7lNjx/PNgrpe0hPKQ47f48sp9XZ/M1+7uNP/1md//8gi19CP ZhLw== X-Gm-Message-State: AIVw110PGYQCY6ida73yWPkXml1afKzpFyogjHL8av6szhkDQWzw+GQA z1z5HRjUDuHn4Hr4SMGrOu2Pn4Na8w== X-Received: by 10.99.5.130 with SMTP id 124mr15205339pgf.51.1499700766999; Mon, 10 Jul 2017 08:32:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.149.130 with HTTP; Mon, 10 Jul 2017 08:32:46 -0700 (PDT) From: Christopher Li Date: Mon, 10 Jul 2017 08:32:46 -0700 X-Google-Sender-Auth: 4WthwbMdCfm5FvDY2PIJ3sZACW8 Message-ID: Subject: [PATCH RFC] Let pseudo->users loop on duplicate version of list To: Luc Van Oostenryck Cc: Linux-Sparse , Dibyendu Majumdar , Linus Torvalds 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 I found a temporary solution is simple enough. Instead of marking the entry deleted. I just use a duplicate version of the list->list[] when doing the loop. It will have unwanted effect that iterator will issue some ptr are already deleted. Other than that, it is very straight forward. It pass the kernel compile test without issue different warnings. It also pass the ptrlist ref checking. The ref count patch can now complete the full kernel check without die() on it. Again no difference in warning. Chris From 18453b4b920ae53f25bc389609218d97e7f583a1 Mon Sep 17 00:00:00 2001 From: Christopher Li Date: Mon, 10 Jul 2017 07:53:21 -0700 Subject: [PATCH] Let pseudo->users loop on duplicate version of list pseudo->users list will change during find dominator. That cause a bug in the ptrlist because the outer loop iterator is not award of the deletion of the entry. Let the outer loop using a duplicate version of entry to avoid this problem for now. This is to fix the bug report by the ptrlist ref counting check. With this change, the ptrlist ref counting check can complete the kernel compile without reporting an error. Signed-of-By: Christopher Li --- flow.c | 7 ++++++- ptrlist.h | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) } while (0); \ @@ -231,6 +245,9 @@ static inline void *last_ptr_list(struct ptr_list *list) #define FOR_EACH_PTR_REVERSE(head, ptr) \ DO_FOR_EACH_REVERSE(head, ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY) +#define FOR_EACH_PTR_REVERSE_DUP(head, ptr) \ + DO_FOR_EACH_REVERSE_DUP(head, ptr, __head##ptr, __list##ptr, __dup##ptr, __nr##ptr, PTR_ENTRY) + #define END_FOR_EACH_PTR_REVERSE(ptr) \ DO_END_FOR_EACH_REVERSE(ptr, __head##ptr, __list##ptr, __nr##ptr) diff --git a/flow.c b/flow.c index fce8bde..2705448 100644 --- a/flow.c +++ b/flow.c @@ -730,7 +730,12 @@ multi_def: complex_def: external_visibility: all = 1; - FOR_EACH_PTR_REVERSE(pseudo->users, pu) { + /* + * FIXME: pseudo->users will have some entry deleted during looping. + * The loop will run on a duplicated version of the list entry for now. + * Should fix it properly later. + */ + FOR_EACH_PTR_REVERSE_DUP(pseudo->users, pu) { struct instruction *insn = pu->insn; if (insn->opcode == OP_LOAD) all &= find_dominating_stores(pseudo, insn, ++bb_generation, !mod); diff --git a/ptrlist.h b/ptrlist.h index d09be2f..5299ee5 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -184,6 +184,20 @@ static inline void *last_ptr_list(struct ptr_list *list) ptr = PTR_ENTRY(__list,__nr); \ do { +#define DO_FOR_EACH_REVERSE_DUP(head, ptr, __head, __list, __dup, __nr, PTR_ENTRY) do { \ + struct ptr_list *__head = (struct ptr_list *) (head); \ + struct ptr_list *__list = __head; \ + CHECK_TYPE(head,ptr); \ + if (__head) { \ + do { int __nr; \ + __list = __list->prev; \ + __nr = __list->nr; \ + struct ptr_list __dup; \ + memcpy(__dup.list, __list->list, sizeof(ptr)*__nr); \ + while (--__nr >= 0) { \ + do { \ + ptr = PTR_ENTRY(&__dup,__nr); \ + do { #define DO_END_FOR_EACH_REVERSE(ptr, __head, __list, __nr) \