From patchwork Wed Aug 16 15:34:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9903961 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 2DF8160231 for ; Wed, 16 Aug 2017 15:35:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FB7E22B27 for ; Wed, 16 Aug 2017 15:35:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1480E2823D; Wed, 16 Aug 2017 15:35: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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 A7D3222B27 for ; Wed, 16 Aug 2017 15:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751517AbdHPPfI (ORCPT ); Wed, 16 Aug 2017 11:35:08 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:38726 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751471AbdHPPfH (ORCPT ); Wed, 16 Aug 2017 11:35:07 -0400 Received: by mail-wr0-f194.google.com with SMTP id g32so3681793wrd.5 for ; Wed, 16 Aug 2017 08:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9vrChMCavBC/8cGAdfFL3mNHE9/3OpSCz45XVK4F+jA=; b=NBr9BCwOUM9MjAze+LMGyyOoAvuUcdkN+uxouar8Q1ffBgoLETvrIU26AC0pzu0Xhq nlbZjbTesTyYQd94ZlOoCytm1dOhYX3tOdj7jaOjeVTuNABUrxL/cDhDL8m/e7JzPgo5 uVmaUPFUnUEZXevkk6YCjDUUnoJqe4n2fCdln1HzgL3tibjWjKHZg+MpHho7Qp5Id1Z/ tct2i+JDnuS+IWakCPcix2SBYaDgFqiznFD+z5cpd92DRq8PSF6niKt5vXCoOvE6pu7E eOXBJr3MT6UyWVIU276iWPeH2II8ogx/cMgCxOSLnLbeJp23ox5XdgVx0NprlIsjgSxE nFQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9vrChMCavBC/8cGAdfFL3mNHE9/3OpSCz45XVK4F+jA=; b=jjU5S71E8r875PRBUPmEKF6VX0J9XCaKa7tVET8xCkHn0mMEkFKW3vpP49BXnAK26v zz/YDg01zUaUv7wn996iBXnBvBExPxwJYO9PL0a8BJRg6tpcIh/MUnRYgMbz+GcABZOo 1/KIKtCZi/YeR8wi4KSsdFMetk135swfRURxCsMDEys+AtIEBi5uGEMfHsPP0ij5jk2H cLnBVseyC1b3nwVMkPdG9E9v3ZDmFN0cen9HaqAtUjcHEOiYCc7dxxT51p8bD4vklv09 ylW3ACKC3EOgFW4kRVZC9V6h6zWkULZRSdzO1Eze1CTXYqqiU0XEgfj4Ouwh9QweWxPX yI6Q== X-Gm-Message-State: AHYfb5gw4AvL0yuWub3cw0397ID/W/ZXNtf1TrIGavxvLJFpUeRLC2EM 9x5BnV1tFJQclev8XWY= X-Received: by 10.80.171.92 with SMTP id t28mr2307247edc.242.1502897706317; Wed, 16 Aug 2017 08:35:06 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4076:600:895a:bb88:13f:9772]) by smtp.gmail.com with ESMTPSA id y19sm690635edi.6.2017.08.16.08.35.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 08:35:05 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Linus Torvalds , Christopher Li , Luc Van Oostenryck Subject: [PATCH 01/29] remove wrong part of simplify_loads() Date: Wed, 16 Aug 2017 17:34:27 +0200 Message-Id: <20170816153455.97693-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170816153455.97693-1-luc.vanoostenryck@gmail.com> References: <20170816153455.97693-1-luc.vanoostenryck@gmail.com> 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 Currently simplify_loads() is broken with exactly the same error as in simplify_one_symbol(). The core of the problem is that phi-nodes are stored at the place where the value is needed, where the initial load was, while phi-nodes must be placed where branches meet. Temporary fix this removing this 'simplification'. Note: It's possible to do this a bit less crudely Note: This patch is kinda useless without the SSA construction first fixed.. Signed-off-by: Luc Van Oostenryck --- memops.c | 63 ------------------------------------------------- validation/kill-casts.c | 1 - 2 files changed, 64 deletions(-) diff --git a/memops.c b/memops.c index aeacdf566..99430e455 100644 --- a/memops.c +++ b/memops.c @@ -16,51 +16,6 @@ #include "linearize.h" #include "flow.h" -static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn, - struct basic_block *bb, unsigned long generation, struct pseudo_list **dominators, - int local) -{ - struct basic_block *parent; - - FOR_EACH_PTR(bb->parents, parent) { - struct instruction *one; - struct instruction *br; - pseudo_t phi; - - FOR_EACH_PTR_REVERSE(parent->insns, one) { - int dominance; - if (!one->bb) - continue; - if (one == insn) - goto no_dominance; - dominance = dominates(pseudo, insn, one, local); - if (dominance < 0) { - if (one->opcode == OP_LOAD) - continue; - return 0; - } - if (!dominance) - continue; - goto found_dominator; - } END_FOR_EACH_PTR_REVERSE(one); -no_dominance: - if (parent->generation == generation) - continue; - parent->generation = generation; - - if (!find_dominating_parents(pseudo, insn, parent, generation, dominators, local)) - return 0; - continue; - -found_dominator: - br = delete_last_instruction(&parent->insns); - phi = alloc_phi(parent, one->target, one->size); - phi->ident = phi->ident ? : one->target->ident; - add_instruction(&parent->insns, br); - use_pseudo(insn, phi, add_pseudo(dominators, phi)); - } END_FOR_EACH_PTR(parent); - return 1; -} static int address_taken(pseudo_t pseudo) { @@ -91,8 +46,6 @@ static void simplify_loads(struct basic_block *bb) struct instruction *dom; pseudo_t pseudo = insn->src; int local = local_pseudo(pseudo); - struct pseudo_list *dominators; - unsigned long generation; /* Check for illegal offsets.. */ check_access(insn); @@ -117,22 +70,6 @@ static void simplify_loads(struct basic_block *bb) goto next_load; } } END_FOR_EACH_PTR_REVERSE(dom); - - /* OK, go find the parents */ - generation = ++bb_generation; - bb->generation = generation; - dominators = NULL; - if (find_dominating_parents(pseudo, insn, bb, generation, &dominators, local)) { - /* This happens with initial assignments to structures etc.. */ - if (!dominators) { - if (local) { - assert(pseudo->type != PSEUDO_ARG); - convert_load_instruction(insn, value_pseudo(0)); - } - goto next_load; - } - rewrite_load_instruction(insn, dominators); - } } next_load: /* Do the next one */; diff --git a/validation/kill-casts.c b/validation/kill-casts.c index cf52f2460..7b72c4719 100644 --- a/validation/kill-casts.c +++ b/validation/kill-casts.c @@ -18,5 +18,4 @@ void foo(struct s *x) * check-command: test-linearize $file * * check-output-ignore - * check-output-excludes: cast\\. */