From patchwork Wed Aug 23 20:15:07 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: 9918241 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 5E269602CB for ; Wed, 23 Aug 2017 20:16:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50D5A28A29 for ; Wed, 23 Aug 2017 20:16:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45B9528A2D; Wed, 23 Aug 2017 20:16:06 +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 DB2F328A29 for ; Wed, 23 Aug 2017 20:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932616AbdHWUQF (ORCPT ); Wed, 23 Aug 2017 16:16:05 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35612 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932443AbdHWUQF (ORCPT ); Wed, 23 Aug 2017 16:16:05 -0400 Received: by mail-wm0-f67.google.com with SMTP id x79so646879wma.2 for ; Wed, 23 Aug 2017 13:16:04 -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=IMu1fw+iyffCiCmEppjhoMlsYXZgaZcq8KlIg4q2u2bOgtgRhwPA7s67ys/fcVfcUV YH6eIGaRq+f+nF3btkUuKqUVpvdQLaGdLfkgYNIAENfFGd4LBxS7IN1SR7WoBFwHdHjJ rwolcf+5xLDqWQOe4mZ0AZU0I2kW/Z+i+EVVVdhaFHWIQxo9ThZv62T2zASQR3AHFWjs 8+woJA7sfyVLaqFwuxn843oubduwyOfa/pNtaL+GoBM0VAIYx+Em1V8LU2lJ84UlAJDI 51vCqbcnXDbndC/9CFdUqvPHOdk1lty14kQm2UgMEa01oQGzkLpSCSpfDvvP6EFyoGVG C8pA== 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=b/e6HqrTuEMPO81fRSa5jsleDXTjdP4XXHPdkI89rcnRxyJUEqi++20wbbrqV3ME8S 3qDenfBiJqTBKIAZliuytZcwqK1Xkj5UoPxIEC3HuGhuvvlP/rGWTvNCA+0gziL952yl WJBCUBj+M1soETv39+AYUVvt5qQbZwdO9x+sMQixbBYdHOKWpEnodZfoKse6uVjn+gb7 fQ0PJcBbwvCKhlJXUaqqSgmI2gMegr/k0dOsFOJi/KCQ2qt35uDM+eiiKa9XEkysthAQ RTAUxsPGsJAUBIU+7Y7iUPewwPdp5C/3PdrpVTWzihV5mzvncK6s/bhTKuxUvztQDDjl +slQ== X-Gm-Message-State: AHYfb5jio2tepQ6XPTUi878AoME8GNwjASD9TcmScB5rjuoTyT670ew/ 8yA8+vBYfKUOInmLqa4= X-Received: by 10.80.164.188 with SMTP id w57mr4029909edb.86.1503519363393; Wed, 23 Aug 2017 13:16:03 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4076:600:9020:103b:7912:3a40]) by smtp.gmail.com with ESMTPSA id e29sm1183374edd.88.2017.08.23.13.16.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 13:16:02 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [RFC PATCH 01/48] remove wrong part of simplify_loads() Date: Wed, 23 Aug 2017 22:15:07 +0200 Message-Id: <20170823201554.90551-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170823201554.90551-1-luc.vanoostenryck@gmail.com> References: <20170823201554.90551-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\\. */