From patchwork Wed Aug 23 20:15:09 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: 9918245 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 D72EC602CB for ; Wed, 23 Aug 2017 20:16:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9D5C28A29 for ; Wed, 23 Aug 2017 20:16:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BED0B28A2D; Wed, 23 Aug 2017 20:16: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 59B8E28A29 for ; Wed, 23 Aug 2017 20:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932643AbdHWUQJ (ORCPT ); Wed, 23 Aug 2017 16:16:09 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36982 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932443AbdHWUQI (ORCPT ); Wed, 23 Aug 2017 16:16:08 -0400 Received: by mail-wm0-f65.google.com with SMTP id v186so629785wmf.4 for ; Wed, 23 Aug 2017 13:16: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=N3rQGxcGgNRq316cWvzbaQwSpzNs4zplPgqtzug5DYg=; b=QElM3/EVCdXy3rgS0MWCx5SIGTjny4nhRPJTVUGMwrd/WfMHA3SimM02LwsM4S0R0e om6eGHBJiGaV7FDWy0TlYn4wCw832wOigwd6c8QrBHl9Imcy4cmICmxaaax5ST7X4FiS VK1k26RW19wAqsCYMBAlAd5EkO5hOJKsz4ymCIyFN2bRicnPTbmVxh3TdvvxgaXAvLc4 j2zBtdoddw1gz7QyCpxQV1qQkfaZ5dpZzKq8LSpm82MvEz3sxjOGN2eMAqSoAKuhZ08N uvPkMUyUVFHLaVSRvu0AEVgiFKz9hqiOlZP68wekr85LTUJcC9x7fozEAHzcFUJAeAqY D7+g== 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=N3rQGxcGgNRq316cWvzbaQwSpzNs4zplPgqtzug5DYg=; b=S5dnmPHR2lTv4F5tpVP+W5DJI5SHpkWhbGy9r2YoR/8Rku69WK09rKKQQR8p1FPwo/ zUbXMJvJadovvFwXMJWfj8k+T9Tq16JmRgGkCXbRwMAPJ5g05bzjiccbwF3NFIQH6NBL J8s1ebn08rz01cGW0RCknlpbcR6y/gJKwSDrtldWbzHAb3AUn47RQB0AgBK1QOQnaTko Ho/pBrdc/uSenyxrEAy3wf7KUNvqRLeocGd5h/eIXkLzlnT7WKz1J4yQO+RIVzesv4Zj 6av3TT9Xywj/KA7CHSAQ6EM04SVTuJ70+L+q6roas6an0wzreSF3mStP1B48YBPjYX4u aEpQ== X-Gm-Message-State: AHYfb5hfgejkiq8emBru24AznZVV972s+Zbt5EqIIvgkgp/7M66UutSr D5BOgWS0SgRfPxC4q+U= X-Received: by 10.80.194.146 with SMTP id o18mr4075595edf.197.1503519366925; Wed, 23 Aug 2017 13:16:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 13:16:06 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [RFC PATCH 03/48] give a type to OP_PHISOURCEs Date: Wed, 23 Aug 2017 22:15:09 +0200 Message-Id: <20170823201554.90551-4-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, 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 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/flow.c b/flow.c index 6b2c879a8..78dd6b3a5 100644 --- a/flow.c +++ b/flow.c @@ -414,7 +414,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 ba76397ea..e3d234e7e 100644 --- a/linearize.c +++ b/linearize.c @@ -821,7 +821,7 @@ 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; pseudo_t phi; @@ -830,7 +830,7 @@ pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size) if (!source) return VOID; - insn = alloc_instruction(OP_PHISOURCE, size); + insn = alloc_typed_instruction(OP_PHISOURCE, type); phi = __alloc_pseudo(0); phi->type = PSEUDO_PHI; phi->nr = ++nr; @@ -1384,19 +1384,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); @@ -1410,7 +1409,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; @@ -1422,12 +1420,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); @@ -1926,7 +1924,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 bac82d7ff..c03940eea 100644 --- a/linearize.h +++ b/linearize.h @@ -331,7 +331,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);