From patchwork Thu Apr 13 16:55:44 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: 9679731 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 9B06260381 for ; Thu, 13 Apr 2017 16:56:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D0792869B for ; Thu, 13 Apr 2017 16:56:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81705286A4; Thu, 13 Apr 2017 16:56:02 +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 20E5D286AA for ; Thu, 13 Apr 2017 16:56:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754010AbdDMQ4A (ORCPT ); Thu, 13 Apr 2017 12:56:00 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36705 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753970AbdDMQz7 (ORCPT ); Thu, 13 Apr 2017 12:55:59 -0400 Received: by mail-wm0-f68.google.com with SMTP id q125so13647643wmd.3 for ; Thu, 13 Apr 2017 09:55:59 -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=VgOPKc1vT19kCgnrfTVg4tr+cbX21VrBA6YiP6yUF6o=; b=b9EOtXAMq3Afy+WxTmYmVaMTwGkd9MxuJnOWQw1dnqzPbZ9nQLMGmzgouoglIxrpxF 19gBKr5rTaoPbXaffplB/qj8UJWtSPFxjiDyY1sOAY6MC7rsDwWEa8MCdFU0TikNShxv jQL4J0vXnGlwSQwYVt3qOHZLR+JKyV5bUmDlvltnHT+xzumy42oPM9/ATIBn5sNAei2Q JTnSLjCCgb1q/a7tlcVx5t1E4fAouKwVdVKi1MkgMkFqUAnkV/MCDR/zxmy4Mz9yPyMi qBQ9M8W4FV/YcuhB3r+dQwHQCsLG25R4dt4RhBJI9AlM3FqlUyk/kA+uvDP4aoGsBuUM zjpQ== 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=VgOPKc1vT19kCgnrfTVg4tr+cbX21VrBA6YiP6yUF6o=; b=mHX8TkXF4+xb+JCLTVXFZ4siSAjuxSdsRZfA2Bzhn7Tn08gmHerPMGLX+RGooHE6Gj CiUGQs+IK8UNim7rLOytiRlURJ63kNVCWnJxlrvXDi/LzF6VlCsysdKPOXEKPxQaqSs1 ssfyV1x4ipDS9N1uXmA7ETmqvGx4BOA/6vlnUP0myFTLigrMHI9AmLbzZU6Dow3ovSa8 aBSAfexFOfSJsMvYxf8353zau3UQswTna3ydagKdwLZ/avVjjWF9j/ugVqvZ/8NwKBdh r3HrSq0z8Ir4Gvjr4k9cuXITFvkxund4VxiUn3lG4kl8q1d/r6GVtEKZ0//vWEAdTT9d LorQ== X-Gm-Message-State: AN3rC/4GxB9HOabATlvUpeBvFh7JfXaHgvE9ekM3IKqe18makYD5DdQU Fi6FYxjBU8QO5Q== X-Received: by 10.28.154.85 with SMTP id c82mr21582911wme.100.1492102558333; Thu, 13 Apr 2017 09:55:58 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:8b2:dc00:a909:829c:fd:bc60]) by smtp.gmail.com with ESMTPSA id q129sm13297803wmg.1.2017.04.13.09.55.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Apr 2017 09:55:57 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH 1/8] extract add_dominator() from find_dominating_parents() Date: Thu, 13 Apr 2017 18:55:44 +0200 Message-Id: <20170413165551.2785-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170413165551.2785-1-luc.vanoostenryck@gmail.com> References: <20170413165551.2785-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 Signed-off-by: Luc Van Oostenryck --- flow.c | 19 ++++++++++++------- flow.h | 1 + memops.c | 8 +------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/flow.c b/flow.c index 45bae773e..50507a5e7 100644 --- a/flow.c +++ b/flow.c @@ -374,8 +374,6 @@ static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn, FOR_EACH_PTR(bb->parents, parent) { struct instruction *one; - struct instruction *br; - pseudo_t phi; FOR_EACH_PTR_REVERSE(parent->insns, one) { int dominance; @@ -403,15 +401,22 @@ no_dominance: found_dominator: if (dominators && phisrc_in_bb(*dominators, parent)) continue; - br = delete_last_instruction(&parent->insns); - phi = alloc_phi(parent, one->target, one->type); - phi->ident = phi->ident ? : pseudo->ident; - add_instruction(&parent->insns, br); - use_pseudo(insn, phi, add_pseudo(dominators, phi)); + add_dominator(dominators, insn, one, pseudo->ident); } END_FOR_EACH_PTR(parent); return 1; } +void add_dominator(struct pseudo_list **phi_list, struct instruction *insn, + struct instruction *dom, struct ident *ident) +{ + struct basic_block *bb = dom->bb; + struct instruction *br = delete_last_instruction(&bb->insns); + pseudo_t phi = alloc_phi(bb, dom->target, dom->type); + phi->ident = phi->ident ? : ident ? : dom->target->ident; + add_instruction(&bb->insns, br); + use_pseudo(insn, phi, add_pseudo(phi_list, phi)); +} + /* * We should probably sort the phi list just to make it easier to compare * later for equality. diff --git a/flow.h b/flow.h index 31ed80d40..800585547 100644 --- a/flow.h +++ b/flow.h @@ -38,6 +38,7 @@ static inline void kill_instruction_force(struct instruction *insn) void check_access(struct instruction *insn); void convert_load_instruction(struct instruction *, pseudo_t); void rewrite_load_instruction(struct instruction *, struct pseudo_list *); +void add_dominator(struct pseudo_list **, struct instruction *, struct instruction *, struct ident*); int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local); extern void clear_liveness(struct entrypoint *ep); diff --git a/memops.c b/memops.c index 187a63284..ac43b6a0a 100644 --- a/memops.c +++ b/memops.c @@ -24,8 +24,6 @@ static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn, FOR_EACH_PTR(bb->parents, parent) { struct instruction *one; - struct instruction *br; - pseudo_t phi; FOR_EACH_PTR_REVERSE(parent->insns, one) { int dominance; @@ -51,11 +49,7 @@ no_dominance: continue; found_dominator: - br = delete_last_instruction(&parent->insns); - phi = alloc_phi(parent, one->target, one->type); - phi->ident = phi->ident ? : one->target->ident; - add_instruction(&parent->insns, br); - use_pseudo(insn, phi, add_pseudo(dominators, phi)); + add_dominator(dominators, insn, one, NULL); } END_FOR_EACH_PTR(parent); return 1; }