From patchwork Wed Aug 16 15:34:37 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: 9903981 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 697EE60231 for ; Wed, 16 Aug 2017 15:35:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BA9E22B27 for ; Wed, 16 Aug 2017 15:35:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50BE5286AC; Wed, 16 Aug 2017 15:35: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 F173F22B27 for ; Wed, 16 Aug 2017 15:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751461AbdHPPf3 (ORCPT ); Wed, 16 Aug 2017 11:35:29 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38904 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751580AbdHPPf3 (ORCPT ); Wed, 16 Aug 2017 11:35:29 -0400 Received: by mail-wr0-f195.google.com with SMTP id g32so3683342wrd.5 for ; Wed, 16 Aug 2017 08:35:28 -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=okbBVCgYTu02zl2wELaSxb6vw2aYjV1kEETaNs9B3wc=; b=rD0aTCXH8l/2lAatubSgmeE+xKEnKRZiLxkyn/kkhvTKlmJtaK0Kf/aWSp1+dzVlYS sMNdzRiJp35WZ7UmI11lIA+9r8VjIGoXf70+yGKYyj2gYbW9AsB3ixOUIG2QAEtNNtXu +eAOQUAf09exZBV3k81RX6adfS8sgCHJ+2FFOI0S7Bb7/Nj3P4qT56I/6f/jZ5/miHMW uux7GzimEoftOqZ+Fc66ymCcJo4L035WSTJZHoJV4ir9ewAFGGmgq8MmP2uzxnV95f+Z PdKaBrPXnOoEcwozvKksfk4KqefHy7TEmuG0zQMPtGm/6C5ysLLSXlp1pr2iBMflF2Qt XP3w== 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=okbBVCgYTu02zl2wELaSxb6vw2aYjV1kEETaNs9B3wc=; b=slTf5LWGNyfyutLS0KkEFVU3YWYkDWj01YVbMKOfd0xekfA/APaIEAKFl8t+DvgXhe LZK98DEyKWTnsPONOnqWtazzrm0pJWPZSXqys5BMWjd1WJZKmq17fBofTbQPC2Y5DXSM TmOjfAOB+qNpmBpXfaQhiqH967s0D3nvD0djiqAHPiZwztchoGoiSu4sotQ7fOMwFtQ7 kDLPqObquWZ13u742Fh6kuNdEgBFKr3C5r0BokyLUVIerxaxHoXwx5UywVA5daEQMsNn wffvDr5i8q5rMBamAQL0u+dwQ9CUkP9wtr7s+HLoFfdwA06zhcMNgX37J/mpNmD0/1fe B09g== X-Gm-Message-State: AHYfb5hlGhUicixe0JjkDqhge2ll3ZVc1fYuBd4hGnmVSWtpdawKpG23 ch/2ZaBxHOrwTZYR3p8= X-Received: by 10.80.205.147 with SMTP id p19mr2309769edi.59.1502897727826; Wed, 16 Aug 2017 08:35:27 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4076:600:895a:bb88:13f:9772]) by smtp.gmail.com with ESMTPSA id y19sm690635edi.6.2017.08.16.08.35.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 08:35:27 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Linus Torvalds , Christopher Li , Luc Van Oostenryck Subject: [PATCH 11/29] add PSEUDO_UNDEF Date: Wed, 16 Aug 2017 17:34:37 +0200 Message-Id: <20170816153455.97693-12-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170816153455.97693-1-luc.vanoostenryck@gmail.com> References: <20170816153455.97693-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 Processing in the middle-end are much easier if undefined values have been clearly identified. Once done, we can then make choices like: - always initialize them to zero - allow arbitraly simplification, - ... Prepare for this by declaring a new type of pseudo: PSEUDO_UNDEF somewhat similar to PSEUDO_VOID. Signed-off-by: Luc Van Oostenryck --- linearize.c | 2 ++ linearize.h | 3 ++- sparse-llvm.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/linearize.c b/linearize.c index 190c47241..9ec65079a 100644 --- a/linearize.c +++ b/linearize.c @@ -155,6 +155,8 @@ const char *show_pseudo(pseudo_t pseudo) if (pseudo->ident) sprintf(buf+i, "(%s)", show_ident(pseudo->ident)); break; + case PSEUDO_UNDEF: + return "UNDEF"; default: snprintf(buf, 64, "", pseudo->type); } diff --git a/linearize.h b/linearize.h index c03940eea..54fcf2a46 100644 --- a/linearize.h +++ b/linearize.h @@ -21,6 +21,7 @@ DECLARE_PTR_LIST(pseudo_user_list, struct pseudo_user); enum pseudo_type { PSEUDO_VOID, + PSEUDO_UNDEF, PSEUDO_REG, PSEUDO_SYM, PSEUDO_VAL, @@ -290,7 +291,7 @@ static inline void add_pseudo_user_ptr(struct pseudo_user *user, struct pseudo_u static inline int has_use_list(pseudo_t p) { - return (p && p->type != PSEUDO_VOID && p->type != PSEUDO_VAL); + return (p && p->type != PSEUDO_VOID && p->type != PSEUDO_UNDEF && p->type != PSEUDO_VAL); } static inline struct pseudo_user *alloc_pseudo_user(struct instruction *insn, pseudo_t *pp) diff --git a/sparse-llvm.c b/sparse-llvm.c index 29fb65f15..f8d48d264 100644 --- a/sparse-llvm.c +++ b/sparse-llvm.c @@ -289,6 +289,7 @@ static void pseudo_name(pseudo_t pseudo, char *buf) assert(0); break; case PSEUDO_VAL: + case PSEUDO_UNDEF: assert(0); break; case PSEUDO_ARG: { @@ -372,6 +373,9 @@ static LLVMValueRef pseudo_to_value(struct function *fn, struct instruction *ins case PSEUDO_VOID: result = NULL; break; + case PSEUDO_UNDEF: + result = LLVMGetUndef(symbol_type(fn->module, insn->type)); + break; default: assert(0); }