From patchwork Sun Mar 19 01:42:01 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: 9632373 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 80933601E9 for ; Sun, 19 Mar 2017 01:42:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 727D928306 for ; Sun, 19 Mar 2017 01:42:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 671A228339; Sun, 19 Mar 2017 01:42:45 +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 C98BE28306 for ; Sun, 19 Mar 2017 01:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751379AbdCSBmo (ORCPT ); Sat, 18 Mar 2017 21:42:44 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34985 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751189AbdCSBmn (ORCPT ); Sat, 18 Mar 2017 21:42:43 -0400 Received: by mail-wm0-f67.google.com with SMTP id z133so8937020wmb.2 for ; Sat, 18 Mar 2017 18:42:42 -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=DOfiuoYMUZCpipYUwmrQUrhmWjjk0okwVn9vsKpZ9Jg=; b=l0VwPKyyfsYmm8D0CHt2kH4R6MKbAsvIDPIIMnnP952W6FqO6BRcDA+A+KOQYzpGWI 6rG2WBgvhllxvwTkMeWe2/xIMLEqdkw80ReUZpSDiJDnyg0nU0690bfn+INOdDdvBOfW wjLH6O4vKqqkFKRpkzBDO6Ljdn96HuCC5h3bbmf4yjqHyQLZ4yDwtgvb9Y+HFnX4STlV DEePSYErIwraoq/SXzs5Z8/ZeKa31RoOgPl4KnQsXgdBD77NWAJrX53A0sXNaQocgGTa VxWgP+JYDvU+yhlISWl47ukzhmN3FqWWw8kSKg9PqbhP1Up7JmFSjWYRjux+WWhQsJrm dVIw== 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=DOfiuoYMUZCpipYUwmrQUrhmWjjk0okwVn9vsKpZ9Jg=; b=eUyQRR+Ka27CDvMsOOoxebsHqkwmmFIJne//1f/9HQoO/d4VKJrrq6LJXHQJpi7vMQ mmov9F9EGRSvbpk3e43vyVtKLL9VimpcdNC8Gn16bAt17ZTEEgLQ3HWpf3YNMrHqW4iG J+3pGDt45OFnP5W+fF8aUj1BgSKUB/Y9L/MA4xEKZukadjLGtWqI2izHZxFnG5mJAUYB UlHtla0WCyFNtwdkRYGTBD5gPDU1elkdAxk1jkwEyAeD5km/SCiaKSUYFWLSiJxyVZtw O0uHUf7omt6SM65PCjbtAnpcwJgPGuBpN4V0GyCwz+h5XgpAo5sujU/3I3hSs/2+y8pn bpQw== X-Gm-Message-State: AFeK/H2tKnbYEFfNX3UuZpWIjrWNRkLE9K/c2kQa0jcvwLB2z6wercdMCvIKkIGdpS7OjA== X-Received: by 10.28.215.74 with SMTP id o71mr4139916wmg.23.1489887761372; Sat, 18 Mar 2017 18:42:41 -0700 (PDT) Received: from localhost.localdomain (83.254-65-87.adsl-dyn.isp.belgacom.be. [87.65.254.83]) by smtp.gmail.com with ESMTPSA id m139sm10814099wma.2.2017.03.18.18.42.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Mar 2017 18:42:40 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Dibyendu Majumdar , Luc Van Oostenryck Subject: [PATCH v3 04/30] give a type to OP_PHISOURCE Date: Sun, 19 Mar 2017 02:42:01 +0100 Message-Id: <20170319014227.8833-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170319014227.8833-1-luc.vanoostenryck@gmail.com> References: <20170319014227.8833-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, OP_PHISOURCEs are given a size but not a type. For consistency, give it a type too. Signed-off-by: Luc Van Oostenryck --- flow.c | 2 +- linearize.c | 16 +++++++--------- linearize.h | 2 +- memops.c | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/flow.c b/flow.c index ec7e3f22c..9265a099d 100644 --- a/flow.c +++ b/flow.c @@ -371,7 +371,7 @@ found_dominator: if (dominators && phisrc_in_bb(*dominators, parent)) continue; br = delete_last_instruction(&parent->insns); - phi = alloc_phi(parent, one->target, one->size); + 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)); diff --git a/linearize.c b/linearize.c index 54752a1a2..6eacb2e36 100644 --- a/linearize.c +++ b/linearize.c @@ -820,9 +820,9 @@ static pseudo_t argument_pseudo(struct entrypoint *ep, int nr) return pseudo; } -pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size) +pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type) { - struct instruction *insn = alloc_instruction(OP_PHISOURCE, size); + struct instruction *insn = alloc_typed_instruction(OP_PHISOURCE, type); pseudo_t phi = __alloc_pseudo(0); static int nr = 0; @@ -1369,19 +1369,18 @@ static pseudo_t linearize_short_conditional(struct entrypoint *ep, struct expres struct basic_block *bb_false; struct basic_block *merge = alloc_basic_block(ep, expr->pos); pseudo_t phi1, phi2; - int size = type_size(expr->ctype); if (!expr_false || !ep->active) return VOID; bb_false = alloc_basic_block(ep, expr_false->pos); src1 = linearize_expression(ep, cond); - phi1 = alloc_phi(ep->active, src1, size); + phi1 = alloc_phi(ep->active, src1, expr->ctype); add_branch(ep, expr, src1, merge, bb_false); set_activeblock(ep, bb_false); src2 = linearize_expression(ep, expr_false); - phi2 = alloc_phi(ep->active, src2, size); + phi2 = alloc_phi(ep->active, src2, expr->ctype); set_activeblock(ep, merge); return add_join_conditional(ep, expr, phi1, phi2); @@ -1395,7 +1394,6 @@ static pseudo_t linearize_conditional(struct entrypoint *ep, struct expression * pseudo_t src1, src2; pseudo_t phi1, phi2; struct basic_block *bb_true, *bb_false, *merge; - int size = type_size(expr->ctype); if (!cond || !expr_true || !expr_false || !ep->active) return VOID; @@ -1407,12 +1405,12 @@ static pseudo_t linearize_conditional(struct entrypoint *ep, struct expression * set_activeblock(ep, bb_true); src1 = linearize_expression(ep, expr_true); - phi1 = alloc_phi(ep->active, src1, size); + phi1 = alloc_phi(ep->active, src1, expr->ctype); add_goto(ep, merge); set_activeblock(ep, bb_false); src2 = linearize_expression(ep, expr_false); - phi2 = alloc_phi(ep->active, src2, size); + phi2 = alloc_phi(ep->active, src2, expr->ctype); set_activeblock(ep, merge); return add_join_conditional(ep, expr, phi1, phi2); @@ -1894,7 +1892,7 @@ static pseudo_t linearize_return(struct entrypoint *ep, struct statement *stmt) phi_node->bb = bb_return; add_instruction(&bb_return->insns, phi_node); } - phi = alloc_phi(active, src, type_size(expr->ctype)); + phi = alloc_phi(active, src, expr->ctype); phi->ident = &return_ident; use_pseudo(phi_node, phi, add_pseudo(&phi_node->phi_list, phi)); } diff --git a/linearize.h b/linearize.h index 0cdd0fa9a..d437e268d 100644 --- a/linearize.h +++ b/linearize.h @@ -339,7 +339,7 @@ struct entrypoint { extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false); extern void insert_branch(struct basic_block *bb, struct instruction *br, struct basic_block *target); -pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size); +pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type); pseudo_t alloc_pseudo(struct instruction *def); pseudo_t value_pseudo(long long val); diff --git a/memops.c b/memops.c index 5efdd6f2d..187a63284 100644 --- a/memops.c +++ b/memops.c @@ -52,7 +52,7 @@ no_dominance: found_dominator: br = delete_last_instruction(&parent->insns); - phi = alloc_phi(parent, one->target, one->size); + 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));