From patchwork Thu Jun 8 07:39:26 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: 9774111 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 2C1866034B for ; Thu, 8 Jun 2017 07:39:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10A181FE85 for ; Thu, 8 Jun 2017 07:39:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03D2B25404; Thu, 8 Jun 2017 07:39:43 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 9EE8D1FE85 for ; Thu, 8 Jun 2017 07:39:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751629AbdFHHjm (ORCPT ); Thu, 8 Jun 2017 03:39:42 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:32826 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbdFHHjl (ORCPT ); Thu, 8 Jun 2017 03:39:41 -0400 Received: by mail-wm0-f66.google.com with SMTP id x3so5881255wme.0 for ; Thu, 08 Jun 2017 00:39:41 -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=c1/1wp9Lg4R+mF8518TVAnUIOEj0lRvKqYvlNYuRmbk=; b=hlpAHWQCqWNijOxA3f844slayDKTGF2hqiSpCfuW2AMGVgqBbQ6omGk3dHEwUiWtCY bvFq3ymsEi7O0l6L8ZluEbRG2EKY9sdMeS99fEzIWfoltHJpxe2us5WUyLOt5SmH679R V8m3Kr4qeajycVYvftKDpfBVP98Be3MR4gxwntAK0WwEfSTU7+da67egFsWJFn6M+w+5 ItpoblDVv7VFOBLl/hQx2rwFUd4XiqVpY/d30VZz0rjxQnQBLqc/0/3BWJjhn9qH95c2 kAnhkeiyOemtlf7zKLCJQKvlglSAUkVDluFMf3XioQfC0g+2jIGHJ4K47b3XcQkPsRP5 n4AA== 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=c1/1wp9Lg4R+mF8518TVAnUIOEj0lRvKqYvlNYuRmbk=; b=tEblcq9z6ulOTPldnUxEzocAeYDXKqWgQDKuDPQM1s2Kqm4QgtK7kwUr0/nHWbKJDe QrQnknFCdUz/XnzW+OLDk29Grm6tY/qtt3yWdOVCHNcYrTmoRf3gHiK9ssX90YOi+j14 h9kkEusiPTE0HgqKUJdXHXyirz6QWUcekKObtVXQSil1ckzul95GgjrX6+6fpvw+qcV0 oIi1KMdQTst6T1jBJN5aZdYOLEtNWJ2F2yW8C6Z6Gez+g5Jq9VJvSl6a8D5x697447Ir VjeYJaS7hLp7W8ScWiOMa+VLodcjX2avLUUqewPxDl37+30AskxmRn9FTZ/HE5khPELQ Q7gg== X-Gm-Message-State: AODbwcA8xRPw0egWaxE5f+TBDiTow00wnCEjiXtTdvxlKl9HL5h0P7y6 Mb98MLPSzvOgh6zk5tw= X-Received: by 10.80.142.219 with SMTP id x27mr19281156edx.3.1496907580119; Thu, 08 Jun 2017 00:39:40 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:89c:5400:21b3:ee4b:e91a:4fb6]) by smtp.gmail.com with ESMTPSA id o30sm1765888edc.22.2017.06.08.00.39.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 00:39:39 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Chris Li , Luc Van Oostenryck Subject: [PATCH 2/3] let kill_instruction() report if it made some changes or not Date: Thu, 8 Jun 2017 09:39:26 +0200 Message-Id: <20170608073927.55218-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170608073927.55218-1-luc.vanoostenryck@gmail.com> References: <20170608073927.55218-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 This let us take others actions if no changes have been made and allow simpler call to this function since its effect on 'repeat_phase' can be directly returned. Signed-off-by: Luc Van Oostenryck --- flow.h | 10 +++++----- simplify.c | 17 ++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/flow.h b/flow.h index b592ad4d3..a0a685ec5 100644 --- a/flow.h +++ b/flow.h @@ -26,14 +26,14 @@ extern void kill_bb(struct basic_block *); extern void kill_use(pseudo_t *); extern void kill_unreachable_bbs(struct entrypoint *ep); -extern void kill_insn(struct instruction *, int force); -static inline void kill_instruction(struct instruction *insn) +extern int kill_insn(struct instruction *, int force); +static inline int kill_instruction(struct instruction *insn) { - kill_insn(insn, 0); + return kill_insn(insn, 0); } -static inline void kill_instruction_force(struct instruction *insn) +static inline int kill_instruction_force(struct instruction *insn) { - kill_insn(insn, 1); + return kill_insn(insn, 1); } void check_access(struct instruction *insn); diff --git a/simplify.c b/simplify.c index 65114193a..d5e219200 100644 --- a/simplify.c +++ b/simplify.c @@ -220,10 +220,10 @@ static void kill_use_list(struct pseudo_list *list) * the function does that unconditionally (must only be used * for unreachable instructions. */ -void kill_insn(struct instruction *insn, int force) +int kill_insn(struct instruction *insn, int force) { if (!insn || !insn->bb) - return; + return 0; switch (insn->opcode) { case OP_SEL: @@ -265,9 +265,9 @@ void kill_insn(struct instruction *insn, int force) if (!force) { /* a "pure" function can be killed too */ if (!(insn->func->type == PSEUDO_SYM)) - return; + return 0; if (!(insn->func->sym->ctype.modifiers & MOD_PURE)) - return; + return 0; } kill_use_list(insn->arguments); if (insn->func->type == PSEUDO_REG) @@ -276,20 +276,20 @@ void kill_insn(struct instruction *insn, int force) case OP_LOAD: if (!force && insn->type->ctype.modifiers & MOD_VOLATILE) - return; + return 0; kill_use(&insn->src); break; case OP_STORE: if (!force) - return; + return 0; kill_use(&insn->src); kill_use(&insn->target); break; case OP_ENTRY: /* ignore */ - return; + return 0; case OP_BR: default: @@ -297,8 +297,7 @@ void kill_insn(struct instruction *insn, int force) } insn->bb = NULL; - repeat_phase |= REPEAT_CSE; - return; + return repeat_phase |= REPEAT_CSE; } static int has_users(pseudo_t p)