From patchwork Sun Nov 29 14:49:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11939131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C448C71155 for ; Sun, 29 Nov 2020 14:50:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E288820825 for ; Sun, 29 Nov 2020 14:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a1GwdWV3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728092AbgK2OuR (ORCPT ); Sun, 29 Nov 2020 09:50:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgK2OuQ (ORCPT ); Sun, 29 Nov 2020 09:50:16 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9BBC0613D2 for ; Sun, 29 Nov 2020 06:49:29 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id m19so9979361ejl.11 for ; Sun, 29 Nov 2020 06:49:29 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=OckwUd4cIgpFSKEPj5ll7DpZrSOgqoPQejCBf4kM9eI=; b=a1GwdWV3h+I4WYT9FXqONzF5fCFeefIPgOw58aN8iWsiQ+BA1IgZOuAV/85hYr4eDq oEGdQ8tEmqmZUsqRwq517PBu/5yoMYP7C7xH78+ZYlTrOAfEYJuCYBaLxec55gUruCkA Ru2y+/HPXMgJHx5FQBYEalJci7fJDRsK9dLhR0r0dijLxZeSM0rnWDMC8c430e+BZ+aV h66SewPOtF1W0iE1xTc0tLJnG4eN9C6B53ISgkqnspGDofZKiSnIrvKLinWHfxeavusH lIPCQ7LDw4S96jmQ8Ettk2fKuWUGx3uT+g6ZakStq0CdPINsmTFkqkAr0ZPJxn1G+Fnf bVGg== 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:mime-version:content-transfer-encoding; bh=OckwUd4cIgpFSKEPj5ll7DpZrSOgqoPQejCBf4kM9eI=; b=Tinpq3NnP5YUDvgOxpfxRMpdHdQC5lFN7RMROdhPh4VkU7HtrnXXuJgvXvHAxGxq2P x+ppj7rlgQvz6290lupTnBO3EFHdbv/us1HaTh7ZfReR3JKh9bSxVKYdtvwFuVWN30VJ i3luZamDbYrOuYbEYQnWd8zcKryeLcgi3cYny09amBy02DThlqzwyQ8UTYWGPMbi8a/Y JMNmKiwlxY0+CeOudXCwb5hmOEUmMYKY2PhQQdKQfalnRHIg0GBZyfXOfYkYcvmMW4ja lk0Eci12/QlMqGZT5uRQiinNjlgbta19hdYuQJWKqIDrH8yGqlUJ4TxXiXdDnw63IHVp CXaQ== X-Gm-Message-State: AOAM530UFzg5qccXHOoCwcdBK/Wj1sx8VDyxXQybHCIARVxcJ/0oeKdP Z7S2N8Uc2M4+pKjVtlK9fmZJSsKpung= X-Google-Smtp-Source: ABdhPJzkPPY+iVlvIF6p8H+y6OdwrQMKsttICqdCV12liqokitUWBQ6xEUjrgkABME0iPvL+qeUepA== X-Received: by 2002:a17:906:e81:: with SMTP id p1mr16673823ejf.494.1606661368304; Sun, 29 Nov 2020 06:49:28 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:149a:de72:e1c0:dd0f]) by smtp.gmail.com with ESMTPSA id p25sm7435649eju.63.2020.11.29.06.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 06:49:27 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/5] let replace_with_pseudo() use kill_instruction() Date: Sun, 29 Nov 2020 15:49:18 +0100 Message-Id: <20201129144922.56209-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> References: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org In replace_with_pseudo(), the replaced instruction needs to be killed and for this contains ts own code. But this is a duplication of what is already done in kill_instruction(). So, replace this part of the code by a cal to kill_instruction(). Signed-off-by: Luc Van Oostenryck --- simplify.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/simplify.c b/simplify.c index de03d315ec33..29b368e94ff4 100644 --- a/simplify.c +++ b/simplify.c @@ -445,23 +445,7 @@ static inline int replace_pseudo(struct instruction *insn, pseudo_t *pp, pseudo_ static int replace_with_pseudo(struct instruction *insn, pseudo_t pseudo) { convert_instruction_target(insn, pseudo); - - switch (insn->opcode) { - case OP_SEL: - case OP_RANGE: - kill_use(&insn->src3); - case OP_BINARY ... OP_BINCMP_END: - kill_use(&insn->src2); - case OP_UNOP ... OP_UNOP_END: - case OP_SYMADDR: - kill_use(&insn->src1); - break; - - default: - assert(0); - } - insn->bb = NULL; - return REPEAT_CSE; + return kill_instruction(insn); } static inline int replace_with_value(struct instruction *insn, long long val) From patchwork Sun Nov 29 14:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11939127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABE5FC64E7C for ; Sun, 29 Nov 2020 14:50:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 639EE20825 for ; Sun, 29 Nov 2020 14:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dT8SEZIL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727531AbgK2OuM (ORCPT ); Sun, 29 Nov 2020 09:50:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgK2OuL (ORCPT ); Sun, 29 Nov 2020 09:50:11 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBE2BC0613D3 for ; Sun, 29 Nov 2020 06:49:30 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id jx16so15097169ejb.10 for ; Sun, 29 Nov 2020 06:49:30 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=CCiIEs6nNh78aSN1WYa7at1l/GNGiQmarIXqJd9KdtI=; b=dT8SEZILjs71ogpoS3oosfO4obfRtcYreR+anhAPaEv0zQUNLHOtoq7K9Sml01VYC7 4uQ/agekFputh7OYcFoigLhLzvvD31y7P1ioxCElg50BctQHuJz4wtWLQJhMK+qNzkZa A/ri+JjGfLunfbzhPe//xu6y4/cYf5xDL7f+5MMcnw9bTNh/7mZpjUk1yy2wNR/BIOg1 v0IGzQTOvdesIrEyXHnfh7/O129QDfctXJ0E/aiAGuu8/Fn+5ZBrhPHYkqPFpiiqcecM wdeAEIx/4ZeVWRu6bXCJhwn0vVbBYzHiXd8pHqJyWBdiOKrerdqrLf+DRyckTS+Rvd7Y 5rEQ== 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:mime-version:content-transfer-encoding; bh=CCiIEs6nNh78aSN1WYa7at1l/GNGiQmarIXqJd9KdtI=; b=fSPntPQ3tmOuBfev9Dt2oaGZwJSowxte54YTx4+8qfKppQe1889xepGfK5gzZn3BNJ c3X877ZPilARm/1Car86fxQ3JyyWOuLc3+Q0I2/vIUTcjWzypiaCXDAiptkyJCCOlYXp 5ju69G/nrBpkzxcl6cvapw66AoIx9gj2QHAAjCI1374VYK0R9zR2ZLI9E4WIEBkIqVJC QmWc/XbJDINV4Va6EY1YG1oTj2BiYMkXXT3B5eKDLIBxXhUtna2qRB4uCbXZysTPOgjZ 3yHSjC6s7qME1AAiQcmtt/cqO29TsFPHuh6tXpWQ8arhLjYsKql85GPDnKokfaE8LAYt sWUw== X-Gm-Message-State: AOAM533l/TF/sYCD3iIHYQYWX5gxapp3+6nzl2h0mXTuwie9r6a1Y6tP bHuCWWHWM3BqE5TX6sxYzWo07bFfg1o= X-Google-Smtp-Source: ABdhPJz2XU+kSvpG7drJ6FwnPqViXgA3E0JvvKb953O7JyFu85CRO9qd7wpPw4tjkvX5c9k2xxRzpA== X-Received: by 2002:a17:906:d1c3:: with SMTP id bs3mr16169153ejb.306.1606661369439; Sun, 29 Nov 2020 06:49:29 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:149a:de72:e1c0:dd0f]) by smtp.gmail.com with ESMTPSA id p25sm7435649eju.63.2020.11.29.06.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 06:49:28 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/5] make a header for simplification Date: Sun, 29 Nov 2020 15:49:19 +0100 Message-Id: <20201129144922.56209-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> References: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The few external functions defined in simplify.h are declared in flow.h (for historical reasons). In preparation for some changes, create a specific headers for these. Signed-off-by: Luc Van Oostenryck --- flow.h | 1 - optimize.c | 1 + simplify.c | 1 + simplify.h | 8 ++++++++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 simplify.h diff --git a/flow.h b/flow.h index c3461c8c33bd..7cdc7c2a496b 100644 --- a/flow.h +++ b/flow.h @@ -21,7 +21,6 @@ extern int simplify_cfg_early(struct entrypoint *ep); extern void convert_instruction_target(struct instruction *insn, pseudo_t src); extern void remove_dead_insns(struct entrypoint *); -extern int simplify_instruction(struct instruction *); extern void kill_bb(struct basic_block *); extern void kill_use(pseudo_t *); diff --git a/optimize.c b/optimize.c index 9b754831f8b0..3351e67b9d5e 100644 --- a/optimize.c +++ b/optimize.c @@ -12,6 +12,7 @@ #include "flowgraph.h" #include "linearize.h" #include "liveness.h" +#include "simplify.h" #include "flow.h" #include "cse.h" #include "ir.h" diff --git a/simplify.c b/simplify.c index 29b368e94ff4..69eae4f8a5a1 100644 --- a/simplify.c +++ b/simplify.c @@ -44,6 +44,7 @@ #include "parse.h" #include "expression.h" #include "linearize.h" +#include "simplify.h" #include "flow.h" #include "symbol.h" diff --git a/simplify.h b/simplify.h new file mode 100644 index 000000000000..200d79c00a83 --- /dev/null +++ b/simplify.h @@ -0,0 +1,8 @@ +#ifndef SIMPLIFY_H +#define SIMPLIFY_H + +#include "linearize.h" + +int simplify_instruction(struct instruction *insn); + +#endif From patchwork Sun Nov 29 14:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11939129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E34D4C64E7D for ; Sun, 29 Nov 2020 14:50:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BE8520829 for ; Sun, 29 Nov 2020 14:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VYTrHQS6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728083AbgK2OuN (ORCPT ); Sun, 29 Nov 2020 09:50:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgK2OuM (ORCPT ); Sun, 29 Nov 2020 09:50:12 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1DA1C0613D4 for ; Sun, 29 Nov 2020 06:49:31 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id m19so9979457ejl.11 for ; Sun, 29 Nov 2020 06:49:31 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=5PRiPKcB1AyORpScnS0YuvpCigQr/HDEuor6qNADadM=; b=VYTrHQS67lhB5ev7Q/bOizA3D0IegMYXjpL4chWIoWoqMKOIEFt5/TjxtXzqr29DoT EKejebeh9+j4/94ju+CugdaLAPQ1zHzQ6loAXUo+TbmYPbrZ9vhNqUfPKRE8UWJtBdRR 2A5NrvdLxYddlAtWS6fDEgHFiQQ0KqzdVAISCbw6UyU8zZZoSMAKIkl8xeETkNPlMmE0 BYw7hncVs4wr9jgyUu8b2w5Hc6vv+FtniF4L9SqU8O0UrFXhyqh8uxllTo6YN91EuisA cyE8dHFE7LwJs6AVKHduG21zjxLQLg4ib9rFPeuPmHc3FlE7XvOGdDUUx8spFp23TJ/A MzNA== 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:mime-version:content-transfer-encoding; bh=5PRiPKcB1AyORpScnS0YuvpCigQr/HDEuor6qNADadM=; b=H9hmxd+qd8ft+1DxHQz/lrMF2bOsYUjmE1Sqtp9jDTeVzfB5Tj3vH0RQOJuVl6KKbA LN1n1O9jY6gkeuZkXeTSkhAGtvlS/o0tkO1Ld7QBP5XVJu4shWPzka6NxP6gVNkXsj9k VVODTTmokWXVYYl1YYoeYkY+cTAdReN9QEeCLMqRFnyl/n8PsogQHeuuwfB1Gt0cToUX ieN1iT7TCaCNooM92g3ZepMRSd+1eAOHqavWBphhzfwVW2OWstvKRRewTd2rmDbJgd8R 3TvR+7GoHlK8wMQgWq+7tBtfZ9W6mLSRLMxYMMEIkPzuikquY9rfhRRbX6M/Yi1WxGLB /4iQ== X-Gm-Message-State: AOAM532GLuuhhpSBuvNXBxdWn12KEb3LjIlAXbuNXlQDwZ6NNvzMSiw0 pyFQW0KhXRil/S0FdAqYyjYkHRxWUGI= X-Google-Smtp-Source: ABdhPJyVx0lObo9rpNPOuugHDNO0jy/EYxb2D+RzomUt9oGksNQOvjiwl/yRYTajz1fzaBJV30pasQ== X-Received: by 2002:a17:906:8617:: with SMTP id o23mr12186747ejx.274.1606661370502; Sun, 29 Nov 2020 06:49:30 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:149a:de72:e1c0:dd0f]) by smtp.gmail.com with ESMTPSA id p25sm7435649eju.63.2020.11.29.06.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 06:49:29 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 3/5] make replace_with_pseudo() extern Date: Sun, 29 Nov 2020 15:49:20 +0100 Message-Id: <20201129144922.56209-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> References: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org This function can be useful since it can be useful in other files, for example in memops.c So make it extern.. Signed-off-by: Luc Van Oostenryck --- simplify.c | 2 +- simplify.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 69eae4f8a5a1..2c587bea3a8a 100644 --- a/simplify.c +++ b/simplify.c @@ -443,7 +443,7 @@ static inline int replace_pseudo(struct instruction *insn, pseudo_t *pp, pseudo_ return REPEAT_CSE; } -static int replace_with_pseudo(struct instruction *insn, pseudo_t pseudo) +int replace_with_pseudo(struct instruction *insn, pseudo_t pseudo) { convert_instruction_target(insn, pseudo); return kill_instruction(insn); diff --git a/simplify.h b/simplify.h index 200d79c00a83..ed3dd9716a3e 100644 --- a/simplify.h +++ b/simplify.h @@ -5,4 +5,6 @@ int simplify_instruction(struct instruction *insn); +int replace_with_pseudo(struct instruction *insn, pseudo_t pseudo); + #endif From patchwork Sun Nov 29 14:49:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11939133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A715C64E8A for ; Sun, 29 Nov 2020 14:50:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B858120756 for ; Sun, 29 Nov 2020 14:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XUzspIty" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728089AbgK2OuP (ORCPT ); Sun, 29 Nov 2020 09:50:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgK2OuO (ORCPT ); Sun, 29 Nov 2020 09:50:14 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D832C0617A7 for ; Sun, 29 Nov 2020 06:49:33 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id s13so333680ejr.1 for ; Sun, 29 Nov 2020 06:49:33 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=YEVPsw4SBnuuAvXsJvcYWmi9sv5t2fvnMFFCtvDFkw4=; b=XUzspItykNgS3nRj6sEMQB6UDtZUPsF1kXK4ppHThWwu+yJ3Hi9Bv/xMdQqKcCh1Kf aayumS7lnem/BUWTLC9XGIeFAJjH8alBjHtBbHGmIb6fSrY8Bmf3AXcGl345IayupG8x dnJf0gj4WVkwqjYmm9hWn1t2dtmJD7bn1eueL0pph30QvqRjm9ZpMuJH8KjoRb8BohIq PX9FIYMMtMwMKKd6ApTiYFaoOwWrFPrON5rDVThKamBcj6UdeLX9Wl6TsIG/0maFjB3Z Yvdp7hnXCfEwoflhQpJu+YAj8x/PVBrzX+QPmW/zTsRXChvvY6Mn7lDuwR7/jxarghJD Ryfw== 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:mime-version:content-transfer-encoding; bh=YEVPsw4SBnuuAvXsJvcYWmi9sv5t2fvnMFFCtvDFkw4=; b=mYpvnupHyFe8ca/mj1liZ0zCaW6qYJdo2kTQxcBEboOwdILgQ3NodWyxrGvuPmNUKL 0vcLo2Lhclo7jZo5VGaooqKaVB3lOOeiiTgs2O1kSbYSNIiIO3iXebVv0Nn16gHvchuQ SeuFNsTS3+Ywj3ycOFYYkLfF97LVNjPk5ukPIWaqgeNDsVFXVWqHzxp7q7zuptW62b5T Jz8Fs955CgfCmeq6TBmHBv5jBeOITqFtx4DNE02aN/+ekOLfPG9yqSO2K7ikrSkFQhxV N4I4jZhLrvbjq2IRO0R8ot/8/oGPexgZfOYDfNz4FvZ7nP4pL2k3NK05ugTLIoTApKeq jnNg== X-Gm-Message-State: AOAM530OOLb4qsmtEiLZ4lQ3pZ/KbwAbj8Btna6NBDu5EVSnC31SCDK/ iWCgU0nQYyrkiW3BSCr8KJpW+AQEk7E= X-Google-Smtp-Source: ABdhPJyhluD6LhzF+NMk/VsBNFdXHqvO5H8hANXzPvRktsGZxHR5eQjSnQdjbEpYS3UaGCMGBysvjg== X-Received: by 2002:a17:906:339a:: with SMTP id v26mr15271502eja.107.1606661372077; Sun, 29 Nov 2020 06:49:32 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:149a:de72:e1c0:dd0f]) by smtp.gmail.com with ESMTPSA id p25sm7435649eju.63.2020.11.29.06.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 06:49:31 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 4/5] memops: move rewrite_load_instruction() here Date: Sun, 29 Nov 2020 15:49:21 +0100 Message-Id: <20201129144922.56209-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> References: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The function rewrite_load_instruction() is defined in flow.c but: * is not directly related to 'flow' * it's only used in memops.c * needs some change related to simplify_loads(). So, move this code to memops.c Signed-off-by: Luc Van Oostenryck --- flow.c | 41 ----------------------------------------- flow.h | 1 - memops.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 42 deletions(-) diff --git a/flow.c b/flow.c index 1a871df16bd5..20827acce88b 100644 --- a/flow.c +++ b/flow.c @@ -520,47 +520,6 @@ int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom return 1; } -/* - * We should probably sort the phi list just to make it easier to compare - * later for equality. - */ -void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *dominators) -{ - pseudo_t new, phi; - - /* - * Check for somewhat common case of duplicate - * phi nodes. - */ - new = first_pseudo(dominators)->def->phi_src; - FOR_EACH_PTR(dominators, phi) { - if (new != phi->def->phi_src) - goto complex_phi; - new->ident = new->ident ? : phi->ident; - } END_FOR_EACH_PTR(phi); - - /* - * All the same pseudo - mark the phi-nodes unused - * and convert the load into a LNOP and replace the - * pseudo. - */ - convert_load_instruction(insn, new); - FOR_EACH_PTR(dominators, phi) { - kill_instruction(phi->def); - } END_FOR_EACH_PTR(phi); - goto end; - -complex_phi: - /* We leave symbol pseudos with a bogus usage list here */ - if (insn->src->type != PSEUDO_SYM) - kill_use(&insn->src); - insn->opcode = OP_PHI; - insn->phi_list = dominators; - -end: - repeat_phase |= REPEAT_CSE; -} - /* Kill a pseudo that is dead on exit from the bb */ // The context is: // * the variable is not global but may have its address used (local/non-local) diff --git a/flow.h b/flow.h index 7cdc7c2a496b..c55362de848e 100644 --- a/flow.h +++ b/flow.h @@ -39,7 +39,6 @@ static inline int kill_instruction_force(struct instruction *insn) void check_access(struct instruction *insn); void convert_load_instruction(struct instruction *, pseudo_t); -void rewrite_load_instruction(struct instruction *, struct pseudo_list *); int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local); extern void vrfy_flow(struct entrypoint *ep); diff --git a/memops.c b/memops.c index badcdbbb9378..6620688264ad 100644 --- a/memops.c +++ b/memops.c @@ -16,6 +16,47 @@ #include "linearize.h" #include "flow.h" +/* + * We should probably sort the phi list just to make it easier to compare + * later for equality. + */ +static void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *dominators) +{ + pseudo_t new, phi; + + /* + * Check for somewhat common case of duplicate + * phi nodes. + */ + new = first_pseudo(dominators)->def->phi_src; + FOR_EACH_PTR(dominators, phi) { + if (new != phi->def->phi_src) + goto complex_phi; + new->ident = new->ident ? : phi->ident; + } END_FOR_EACH_PTR(phi); + + /* + * All the same pseudo - mark the phi-nodes unused + * and convert the load into a LNOP and replace the + * pseudo. + */ + convert_load_instruction(insn, new); + FOR_EACH_PTR(dominators, phi) { + kill_instruction(phi->def); + } END_FOR_EACH_PTR(phi); + goto end; + +complex_phi: + /* We leave symbol pseudos with a bogus usage list here */ + if (insn->src->type != PSEUDO_SYM) + kill_use(&insn->src); + insn->opcode = OP_PHI; + insn->phi_list = dominators; + +end: + repeat_phase |= REPEAT_CSE; +} + static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn, struct basic_block *bb, unsigned long generation, struct pseudo_list **dominators, int local) From patchwork Sun Nov 29 14:49:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11939135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81661C3E8C5 for ; Sun, 29 Nov 2020 14:50:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48FA020756 for ; Sun, 29 Nov 2020 14:50:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p7Qo4do0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727660AbgK2Ouu (ORCPT ); Sun, 29 Nov 2020 09:50:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726021AbgK2Out (ORCPT ); Sun, 29 Nov 2020 09:50:49 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8902CC061A04 for ; Sun, 29 Nov 2020 06:49:34 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id c7so3930245edv.6 for ; Sun, 29 Nov 2020 06:49:34 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=JprRWokgKtSqghCRmRoVkQ6Lw9MTLOQDlBrl1DACqI0=; b=p7Qo4do0Rx/O56SKq2YIhbfZZQ/keGanKd/KRMT8jQEGOEjGdl+/gbxjOkSlvPeqMx /Qo7QkwmKkcto0SUtTrzF80yjJIpbgQfQHpczv9nvaR6I/ZTKqTmnSGCUdJoPq46NKSY TUvDMh3QtjCWtVL6H2/SzB4GoUr41Hb8x08MY0t1Az3MNZhlj6tu/7dflPyAYnXJxFmm Zl4S9N8MfdF2YY6N96VU26Wq/yJQXPDdIdK3gfXbhZ/Sj9ijuhKs/pU5H9bkof3DdbRO jWG+INUdatwcTpxDFFOJRJBK2AxLvqIjx5cWIEAlfXiOjcNWHCUoKOmEvC0a/GCfAcjf Q0JQ== 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:mime-version:content-transfer-encoding; bh=JprRWokgKtSqghCRmRoVkQ6Lw9MTLOQDlBrl1DACqI0=; b=JOiYJ7NXM/vap36Fo1gYANmJwDwLkduwZ3rsiW8hjbUTTOcQjbjhmUeNpwxVdrNHkK 59Dun+kFvj+zQunZKVkQU6rtwB9W3W4pzoIPMZ8qmXqh5uK2fD1pxCbFKtonixkmU+PH 20VqpRrA2zX0+BWRwt5huh54dRjjE2mEfGFAnJN/6HsclRGjJ1OgdlasNC4Lm87LpEyb pAzTWrk1Ad0gOfiusp5RgOdIppRY8nCbf/SEtQ0dS/W9UKSLLcQ4DtR7eFAbhYu1Tkca rmQ3VHo087kJy0x0TAgGtvNYWo93xs2p3q0QaE7du8+Ms4UdpolftD3H8efvbCXSup5L vFZA== X-Gm-Message-State: AOAM530sZrQ9l+arvYKI2pdioYenQbY3D3dTjg93frU3JGFKN0tHVplI Cc2A62WeORebJ3Yr4lWrYJ/mGoYLK40= X-Google-Smtp-Source: ABdhPJw8BM+4PlaJNdlVDjdj0WdpSoCZPoPC+MrxpL4DKiihGc7Y/wmKVnQWayyRhe0JsutxEC9URw== X-Received: by 2002:a50:9ee6:: with SMTP id a93mr12062426edf.174.1606661372875; Sun, 29 Nov 2020 06:49:32 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:149a:de72:e1c0:dd0f]) by smtp.gmail.com with ESMTPSA id p25sm7435649eju.63.2020.11.29.06.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 06:49:32 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 5/5] replace convert_load_instruction() by replace_with_pseudo() Date: Sun, 29 Nov 2020 15:49:22 +0100 Message-Id: <20201129144922.56209-6-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> References: <20201129144922.56209-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org These two functions are now exactly the same, so replace the first one by the second one. Signed-off-by: Luc Van Oostenryck --- flow.c | 7 +------ flow.h | 1 - memops.c | 7 ++++--- ssa.c | 9 +++++---- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/flow.c b/flow.c index 20827acce88b..95e44ac104f6 100644 --- a/flow.c +++ b/flow.c @@ -16,6 +16,7 @@ #include "parse.h" #include "expression.h" #include "linearize.h" +#include "simplify.h" #include "flow.h" #include "target.h" #include "flowgraph.h" @@ -453,12 +454,6 @@ void convert_instruction_target(struct instruction *insn, pseudo_t src) target->users = NULL; } -void convert_load_instruction(struct instruction *insn, pseudo_t src) -{ - convert_instruction_target(insn, src); - kill_instruction(insn); -} - static int overlapping_memop(struct instruction *a, struct instruction *b) { unsigned int a_start = bytes_to_bits(a->offset); diff --git a/flow.h b/flow.h index c55362de848e..46d76a780484 100644 --- a/flow.h +++ b/flow.h @@ -38,7 +38,6 @@ static inline int kill_instruction_force(struct instruction *insn) } void check_access(struct instruction *insn); -void convert_load_instruction(struct instruction *, pseudo_t); int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local); extern void vrfy_flow(struct entrypoint *ep); diff --git a/memops.c b/memops.c index 6620688264ad..7efade22c9b5 100644 --- a/memops.c +++ b/memops.c @@ -14,6 +14,7 @@ #include "parse.h" #include "expression.h" #include "linearize.h" +#include "simplify.h" #include "flow.h" /* @@ -40,7 +41,7 @@ static void rewrite_load_instruction(struct instruction *insn, struct pseudo_lis * and convert the load into a LNOP and replace the * pseudo. */ - convert_load_instruction(insn, new); + replace_with_pseudo(insn, new); FOR_EACH_PTR(dominators, phi) { kill_instruction(phi->def); } END_FOR_EACH_PTR(phi); @@ -167,7 +168,7 @@ static void simplify_loads(struct basic_block *bb) if (!compatible_loads(insn, dom)) goto next_load; /* Yeehaa! Found one! */ - convert_load_instruction(insn, dom->target); + replace_with_pseudo(insn, dom->target); goto next_load; } } END_FOR_EACH_PTR_REVERSE(dom); @@ -181,7 +182,7 @@ static void simplify_loads(struct basic_block *bb) if (!dominators) { if (local) { assert(pseudo->type != PSEUDO_ARG); - convert_load_instruction(insn, value_pseudo(0)); + replace_with_pseudo(insn, value_pseudo(0)); } goto next_load; } diff --git a/ssa.c b/ssa.c index 3e8800507f63..a2e27030e4b6 100644 --- a/ssa.c +++ b/ssa.c @@ -11,7 +11,8 @@ #include "dominate.h" #include "flowgraph.h" #include "linearize.h" -#include "flow.h" // for convert_load_instruction() +#include "simplify.h" +#include "flow.h" // Is it possible and desirable for this to be promoted to a pseudo? @@ -109,7 +110,7 @@ static void rewrite_local_var(struct basic_block *bb, pseudo_t addr, int nbr_sto case OP_LOAD: if (!val) val = undef_pseudo(); - convert_load_instruction(insn, val); + replace_with_pseudo(insn, val); break; case OP_STORE: val = insn->target; @@ -150,7 +151,7 @@ static bool rewrite_single_store(struct instruction *store) // undefs ? - convert_load_instruction(insn, store->target); + replace_with_pseudo(insn, store->target); } END_FOR_EACH_PTR(pu); // is there some unconverted loads? @@ -292,7 +293,7 @@ static void ssa_rename_insn(struct basic_block *bb, struct instruction *insn) if (!var || !var->torename) break; val = lookup_var(bb, var); - convert_load_instruction(insn, val); + replace_with_pseudo(insn, val); break; case OP_PHI: var = insn->type;