From patchwork Mon Mar 27 17:34: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: 9647247 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 0BD6D601D7 for ; Mon, 27 Mar 2017 17:38:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F05FD28409 for ; Mon, 27 Mar 2017 17:38:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E512828403; Mon, 27 Mar 2017 17:38:30 +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 78AA7283FF for ; Mon, 27 Mar 2017 17:38:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751386AbdC0Rhd (ORCPT ); Mon, 27 Mar 2017 13:37:33 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34711 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751410AbdC0RhN (ORCPT ); Mon, 27 Mar 2017 13:37:13 -0400 Received: by mail-wr0-f196.google.com with SMTP id w43so12463429wrb.1 for ; Mon, 27 Mar 2017 10:36:25 -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=46bIQEAc9eBHovrKpYuD1Qs7DeNFaWgu0DR8ZRl8k1Q=; b=bWjhTDF7DGx2UCwlDuiD/UOKSvr2NIasorB0e+n4biKVxH5zPgdyCiwrWPV1XR7NYZ d4vWbClmCt2jKny/obFr/f9chhscf1U/5A5vLHxyAHF69PPui5ZdTuK6d2O5cfzZQ6pJ DLHpD6CC8pUmxIHzgQkh9+HiBDiwVCH7wGjPp/tn2t2iDAYKuBqFhk/HzUKojqcST3Le 7URYYjpe9Ne/+MLLV6E1bmVsKw+r8uHZZVgYQkGb3TFiJB+vWIiyVBFARcsn5PNEnbxF Npxua81AEeBeHtFuDAuCCCszpkjGaonon8XOLrTJo2HC3rUXufITR1zEdWOylZ50yU2p aklg== 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=46bIQEAc9eBHovrKpYuD1Qs7DeNFaWgu0DR8ZRl8k1Q=; b=dw9EFJbzW0gRpr5WQnVT6rGZxH43j8F8kJQUfTuUA5Z4d+h0J1muuw+4+sk0iKjuTf 920zr8BLFpCXwwCxnOTAosIzfeCkBytMqdCIgOd685uwR+hli9pif3skL2VWVDE1ZsY0 eHMcUfzmFCysUet+EginKb9XdaCnKiC97aSZrOmbeI07plE5OvItwctA+FoVoB20Pw+A Iz5N5yUggjE24h6YdEmxCoVk7lnxWNbHbbE4WIZ8d8dfrIInD7H2o2XNCMgt7N1cenzz bWgXqPByOc4n9P7Bgb/tA/0apshI49Nk3+sBqR+80ez3svzru2/+jAxOU/Zflb6bsydQ Jzvw== X-Gm-Message-State: AFeK/H2rbeLwSP3hCQUrqzAYOuuI/DmEwEXxLtwG+UuRLmIt92+UCCt4DbXwDxcee+U7RA== X-Received: by 10.28.135.21 with SMTP id j21mr10156381wmd.70.1490636184018; Mon, 27 Mar 2017 10:36:24 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:802:b00:496:ae63:aebb:a034]) by smtp.gmail.com with ESMTPSA id e72sm304116wma.5.2017.03.27.10.36.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 10:36:23 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH v6 11/15] give a type to OP_PHISOURCEs Date: Mon, 27 Mar 2017 19:34:01 +0200 Message-Id: <20170327173405.11405-12-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170327173405.11405-1-luc.vanoostenryck@gmail.com> References: <20170327173405.11405-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 and for sparse-LLVM which need it, give them 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 04ef8cd1d..45bae773e 100644 --- a/flow.c +++ b/flow.c @@ -404,7 +404,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 d4610de8f..4b6483efa 100644 --- a/linearize.c +++ b/linearize.c @@ -824,9 +824,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; @@ -1380,19 +1380,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); @@ -1406,7 +1405,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; @@ -1418,12 +1416,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); @@ -1905,7 +1903,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 0d27012aa..0a70d8129 100644 --- a/linearize.h +++ b/linearize.h @@ -342,7 +342,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));