From patchwork Sun Mar 21 17:08:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12153181 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 0F4D2C433DB for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1C116192C for ; Sun, 21 Mar 2021 17:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230182AbhCURJG (ORCPT ); Sun, 21 Mar 2021 13:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbhCURI2 (ORCPT ); Sun, 21 Mar 2021 13:08:28 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46D8AC061762 for ; Sun, 21 Mar 2021 10:08:28 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id hq27so17492518ejc.9 for ; Sun, 21 Mar 2021 10:08: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 :mime-version:content-transfer-encoding; bh=JF3q0Wp1aD+/Ry+ocJbhaHWsTsz6av/7CMpb4TrpYDU=; b=iMH6J6IfegfDOMspTsPCZ+XJZoZLrvjuJlFjObRBwos8uVx3/F93a7h7EwN0z4+m3+ c/3vV+S6deXDyzrp8ZeECPHdEO0v2SlyYH9eq4sCQvV3DY35XG4+JUtY0vWWFran3FJs JLlb7APRdPkNCVUB+BHEp10YoDJe71dNiLV7rQ7oeghH82s4sX5dlok5XtEWgHj+6uau wEwXSshzOsYcaePQz0CaTVm6LSSRw/oiTpc87M5sCb26zjx/2PR71fTvdiwsfniaQClm QN5y1IbpJ5mN/rI9uElqawuKqxFTiKyLzlkzXtA6glvT79VxFAuAuowTZd8W46wq/7VO XAsA== 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=JF3q0Wp1aD+/Ry+ocJbhaHWsTsz6av/7CMpb4TrpYDU=; b=mnNaeFYLoRLngV4cSPMT2dsE56XaGhpUn/X925HpZ6HjCUxEFcUD7fgq9qMmtA5oMv c+DOE+ESrKyLtAwUAHh7pUKLS/nPTUwDe6FAXY7685UGJ/HLxZz9xLOylRVCeXek6qYS Ywt1CGTnqSjSZZOU1TZ7JABCJ0olLClbxGXQ+v/OA+XqTpIWzBYqKjQeESb6JqzjSnDc g6pegbkiHXiGJGWGuzVid3U+CDLW3sdjWx18cFGbTKoMWFBaw8a1LkCmt0OlTd6UspW2 MTnAlv8I923yawD5N53k87ye/xsTd3JjXPY519AQ387PL7Ox96iTYQ4BLwe0OU3XEPOG ShIQ== X-Gm-Message-State: AOAM530G7MP6S4Xpcd06/YxQFQLYHew1pupFZgye6qU0tR1QGLq0qSBX FSt66LFeNbOgidaQngTJeP0YwNnuodU= X-Google-Smtp-Source: ABdhPJx1A5Y+GZYv7vUc+n0pZA1V9n9Z1aYw5uhYDm59c3VHGCb4NkufqWUkxXM50wVsViNl5CUM8Q== X-Received: by 2002:a17:906:78d:: with SMTP id l13mr15441296ejc.97.1616346507000; Sun, 21 Mar 2021 10:08:27 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:dc34:259e:8292:82c0]) by smtp.gmail.com with ESMTPSA id 90sm9108044edr.69.2021.03.21.10.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 10:08:26 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/6] memops: dominates()s first arg is redundant Date: Sun, 21 Mar 2021 18:08:17 +0100 Message-Id: <20210321170822.46854-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> References: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The first argument of dominates(), 'pseudo', is simply the 'src' pseudo of it's second argument, the load or store instruction. It's thus not needed to give it in a separate argument. So, remove this redundant argument, since it makes things slightly clearer. Signed-off-by: Luc Van Oostenryck --- flow.c | 4 ++-- flow.h | 2 +- memops.c | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/flow.c b/flow.c index cb94fcf20834..c235c5e92c8a 100644 --- a/flow.c +++ b/flow.c @@ -423,7 +423,7 @@ static inline int distinct_symbols(pseudo_t a, pseudo_t b) * * Return 0 if it doesn't, and -1 if you don't know. */ -int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local) +int dominates(struct instruction *insn, struct instruction *dom, int local) { switch (dom->opcode) { case OP_CALL: case OP_ENTRY: @@ -440,7 +440,7 @@ int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom return 0; } - if (dom->src != pseudo) { + if (dom->src != insn->src) { if (local) return 0; /* We don't think two explicitly different symbols ever alias */ diff --git a/flow.h b/flow.h index c489ebe03034..d578fa95061a 100644 --- a/flow.h +++ b/flow.h @@ -41,7 +41,7 @@ static inline int kill_instruction_force(struct instruction *insn) } void check_access(struct instruction *insn); -int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local); +int dominates(struct instruction *insn, struct instruction *dom, int local); extern void vrfy_flow(struct entrypoint *ep); extern int pseudo_in_list(struct pseudo_list *list, pseudo_t pseudo); diff --git a/memops.c b/memops.c index ff54208e2d54..7d9e4d703ee3 100644 --- a/memops.c +++ b/memops.c @@ -58,7 +58,7 @@ end: repeat_phase |= REPEAT_CSE; } -static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn, +static int find_dominating_parents(struct instruction *insn, struct basic_block *bb, unsigned long generation, struct pseudo_list **dominators, int local) { @@ -75,7 +75,7 @@ static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn, continue; if (one == insn) goto no_dominance; - dominance = dominates(pseudo, insn, one, local); + dominance = dominates(insn, one, local); if (dominance < 0) { if (one->opcode == OP_LOAD) continue; @@ -90,7 +90,7 @@ no_dominance: continue; parent->generation = generation; - if (!find_dominating_parents(pseudo, insn, parent, generation, dominators, local)) + if (!find_dominating_parents(insn, parent, generation, dominators, local)) return 0; continue; @@ -160,7 +160,7 @@ static void simplify_loads(struct basic_block *bb) int dominance; if (!dom->bb) continue; - dominance = dominates(pseudo, insn, dom, local); + dominance = dominates(insn, dom, local); if (dominance) { /* possible partial dominance? */ if (dominance < 0) { @@ -180,7 +180,7 @@ static void simplify_loads(struct basic_block *bb) generation = ++bb_generation; bb->generation = generation; dominators = NULL; - if (find_dominating_parents(pseudo, insn, bb, generation, &dominators, local)) { + if (find_dominating_parents(insn, bb, generation, &dominators, local)) { /* This happens with initial assignments to structures etc.. */ if (!dominators) { if (local) { @@ -226,7 +226,7 @@ static void kill_dominated_stores(struct basic_block *bb) int dominance; if (!dom->bb) continue; - dominance = dominates(pseudo, insn, dom, local); + dominance = dominates(insn, dom, local); if (dominance) { /* possible partial dominance? */ if (dominance < 0) From patchwork Sun Mar 21 17:08:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12153187 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 2055CC433E1 for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7BB061944 for ; Sun, 21 Mar 2021 17:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbhCURJF (ORCPT ); Sun, 21 Mar 2021 13:09:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbhCURI3 (ORCPT ); Sun, 21 Mar 2021 13:08:29 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E486EC061574 for ; Sun, 21 Mar 2021 10:08:28 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id jy13so17482412ejc.2 for ; Sun, 21 Mar 2021 10:08: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 :mime-version:content-transfer-encoding; bh=+Ayr6xXcgT8EK4oQFot03FfNuLz7CNdrWrUWlWcR5Fg=; b=E5hlHzMgL9tecGCV8RMoZAE9W1u4CmWBoZzz+8rPXkf2/0cfSxI2kt1+jq4EfiSNmY fkm/SKDvsgKzDPuY14/nMdkvu/Cvz3r7OquTpJS7Fjirns35PwaZpPvS5J1eDDTSzEeX CAwKApE0MTKDuK8pgcizVQA9hQxHfwOSrd9phjblaW8nc4stvup91/IYMKJtQLBTbr9n 8C0thbhvL+TZZyPXB04h/EN2epooLOiUvhEXHLfEoFkm4UkSuTmVU7XoiA69ZK42JMh6 s0heBFmxz2emsgAWPHHlyoGlUpAavUSMoJAIqu2AlBkV4rX8UM6CR4j/A/fQdECqFI/b EyQw== 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=+Ayr6xXcgT8EK4oQFot03FfNuLz7CNdrWrUWlWcR5Fg=; b=mpK40HrC6B1GbjwiQ5pB2QKGB9iK0yrY2MfOrKlq5cIS/y9GlXK60bYHm0W+BGU4ad b9YqFsXJALdQ6L/hx9E7Ue+22UOkYtRoQ/y9mretCXrXuwQsAlRvvQpjx67Hs/9pJwyN P4S0tX9HDoMiI1RTeC2I6evyvGFGTKPBBZsN9Q6TyTWTFhj0jLctMJqMlF6cCkReGxJ5 qZAyifIEFL4jdT5IUDsIj4oxBrLTJvFyvi6wUmcRrdyogejbnis+BS4FXcJZ3GXgp1Ei m0dLi7yHl7eAVentGEMsA7mmm2IUcXvGaJ39sU4p2kYbC4hSKcif5uQq24YRudLvvC9q +V4Q== X-Gm-Message-State: AOAM530ldpaVbaxg4HSKsvabTZ14m7CdECtKZWydQk1WgggMijKlO/V1 Q51jKzGL6FTxLMmmJPcln5lGnQvRRkE= X-Google-Smtp-Source: ABdhPJxHmiz7ILDg/NI71/SOi//lsfDyPiFPaojKhX968Xd/R/HnTf6GPY+2ljvPoRsXiZ1p5knBGQ== X-Received: by 2002:a17:906:1c98:: with SMTP id g24mr15386583ejh.51.1616346507709; Sun, 21 Mar 2021 10:08:27 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:dc34:259e:8292:82c0]) by smtp.gmail.com with ESMTPSA id 90sm9108044edr.69.2021.03.21.10.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 10:08:27 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/6] memops: find_dominating_parents()s generation is redundant Date: Sun, 21 Mar 2021 18:08:18 +0100 Message-Id: <20210321170822.46854-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> References: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org find_dominating_parents() has an argument 'generation' used to check if a BB has already been visited. But this argument is not needed since this generation is also stored in the field ::generation of the current BB. So, remove this argument. Signed-off-by: Luc Van Oostenryck --- memops.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/memops.c b/memops.c index 7d9e4d703ee3..753eb3a7a914 100644 --- a/memops.c +++ b/memops.c @@ -59,7 +59,7 @@ end: } static int find_dominating_parents(struct instruction *insn, - struct basic_block *bb, unsigned long generation, struct pseudo_list **dominators, + struct basic_block *bb, struct pseudo_list **dominators, int local) { struct basic_block *parent; @@ -86,11 +86,11 @@ static int find_dominating_parents(struct instruction *insn, goto found_dominator; } END_FOR_EACH_PTR_REVERSE(one); no_dominance: - if (parent->generation == generation) + if (parent->generation == bb->generation) continue; - parent->generation = generation; + parent->generation = bb->generation; - if (!find_dominating_parents(insn, parent, generation, dominators, local)) + if (!find_dominating_parents(insn, parent, dominators, local)) return 0; continue; @@ -146,7 +146,6 @@ static void simplify_loads(struct basic_block *bb) pseudo_t pseudo = insn->src; int local = local_pseudo(pseudo); struct pseudo_list *dominators; - unsigned long generation; if (insn->is_volatile) continue; @@ -177,10 +176,9 @@ static void simplify_loads(struct basic_block *bb) } END_FOR_EACH_PTR_REVERSE(dom); /* OK, go find the parents */ - generation = ++bb_generation; - bb->generation = generation; + bb->generation = ++bb_generation; dominators = NULL; - if (find_dominating_parents(insn, bb, generation, &dominators, local)) { + if (find_dominating_parents(insn, bb, &dominators, local)) { /* This happens with initial assignments to structures etc.. */ if (!dominators) { if (local) { From patchwork Sun Mar 21 17:08:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12153183 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 38BADC433E0 for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03FCE61947 for ; Sun, 21 Mar 2021 17:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230079AbhCURJG (ORCPT ); Sun, 21 Mar 2021 13:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230186AbhCURI3 (ORCPT ); Sun, 21 Mar 2021 13:08:29 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8522EC061574 for ; Sun, 21 Mar 2021 10:08:29 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id h10so16529437edt.13 for ; Sun, 21 Mar 2021 10:08:29 -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 :mime-version:content-transfer-encoding; bh=GlKgS8okPEknJRnDBRtjMVSR0o1/pphCbVaJfk7IUEE=; b=Sh5bo4oPPPP+cPRkoCzbT2faUdSLOcjYcgBuQTZeLfam3FXqkCvJ8IhdQYioEPu48s yJr1RtDiq6x3Y3/VlgwtYPs+Yh+rwcrIw9L22Qy067Q4wjDXW+ibkrZBOa0MnqPZ1MSd BavF5s3w/jhcGOGgmtLWqdPbMXDrNMdSMWBurPgFxGZLgr8fzkQPj8FNmKHFBFKzTYwz HujtFZ2WS8naszs++wMz9SUgFotqtFpHd8UJgOD/Rt4ku+0L+OW7R+tSxwzRBWnKq/AL tcJcSklPXQOz9OcI9ow0V2+7Im0aTtqwFNGNI47uRqgtlXLMzuLRewipN1dVglza+jse +A7w== 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=GlKgS8okPEknJRnDBRtjMVSR0o1/pphCbVaJfk7IUEE=; b=gAsedBr+uPMjGii91MbxLDpVwU9+vtDm6ZQ/OlrL6M9+WgMxhg+mvbY+PuwCMnT6SV vpGhG2xpMLuu45Po6C/GlmcXFZy7fK2UYISO9E0M4OKJQVSKZA5RzL4HhFIdr4gEJl9e 0/kxcePOiBweR7tCQoXFP8Wmem1GNg1wb/NGqanXg0KaQGvgKfyct2q5ke2svjO6hEn5 C1q9GOmDN2lm82EXGL7DVMmyWTbpGABwfTc/xSsdvodpT4ZtnxCRY8E+Jp2dLnS4vMAe kOcneoww9rp9CexU6DwrMfJfrkaI6uOwznrCpjnP1J0FwbAAEHw2KxSvrnOEYXbiZoeZ YwCQ== X-Gm-Message-State: AOAM5320GkcYUnihMXUfNMID/qwac5yARoMOAZu7aeHh54btBcD875pF p2UBzPoMU4TddOhLvqIiIldvRVtkYRY= X-Google-Smtp-Source: ABdhPJx5dlYIRS2fyIzWq9gHK+T3KS4B788ErrGpxC4rVqTjd4D5B9pI9mLUkrpsv8s8kCi/e8CShg== X-Received: by 2002:aa7:d813:: with SMTP id v19mr21543890edq.213.1616346508333; Sun, 21 Mar 2021 10:08:28 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:dc34:259e:8292:82c0]) by smtp.gmail.com with ESMTPSA id 90sm9108044edr.69.2021.03.21.10.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 10:08:28 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 3/6] memops: remove obsolete comment Date: Sun, 21 Mar 2021 18:08:19 +0100 Message-Id: <20210321170822.46854-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> References: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The comment above rewrite_load_instruction(), about comparing phi-lists for equality, was (most probably) written when there was some intention to do CSE on phi-nodes or phi-sources. However, such CSE is currently not an objective at all. So, remove this comment. Signed-off-by: Luc Van Oostenryck --- memops.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/memops.c b/memops.c index 753eb3a7a914..5386c5a1f416 100644 --- a/memops.c +++ b/memops.c @@ -17,10 +17,6 @@ #include "simplify.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; From patchwork Sun Mar 21 17:08:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12153189 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 4BCE3C433E4 for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3417361944 for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230201AbhCURJI (ORCPT ); Sun, 21 Mar 2021 13:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbhCURIa (ORCPT ); Sun, 21 Mar 2021 13:08:30 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20449C061762 for ; Sun, 21 Mar 2021 10:08:30 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id u5so17502699ejn.8 for ; Sun, 21 Mar 2021 10:08:30 -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 :mime-version:content-transfer-encoding; bh=v+voen80HxgUrnrUvPyBBSXSDXFTN7ud5BWjQyoJVio=; b=ncMhhhvgt/m7M6P4xg+pOR43yU6es5d7pt6zY53wG+7mtBdNLTdCEgnhSJNxicUizq vD8tblEVTc17fr/XhFdU/9AkZrhly86L4l1n7YGRU9Y0u/fOxz4NZamIFf557tLHv3FX HwWcjZLkPlBx/0m9/iVeWajS399g2ShiNXnG/6hByKwkuC8JBGcz8NottqS0LF9O/DgH WhvZjUzpxqnoBWVSl0WeQ+IvTTCs9E4PgEj6LcYjmZH/6HQRMVPIoN+m3RwSiup3rz4P 9fg3VmaLA9Mq42rGniWrWnSLBCqRobwHcSaOUnVniT7fqgB5R4UoJ/Jsm4xPvG+ghyd8 RAcA== 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=v+voen80HxgUrnrUvPyBBSXSDXFTN7ud5BWjQyoJVio=; b=b1PYqh/8xJ2BdKDM5c/ijcxDD/GpeUCG3EBQqFPq0XVrokNnfNtWNwbAItykhLWl2X kXBlg5xjF9CXNRF9TNFXo+fw2iPnTKP2fiKnOVXVhb2/sqasvifMNxd6Q4NtwBiotNx0 mnswjvxpaHDzyMAJg7oA2miI9mJte5fErVa6+ymOFHF1zue5C8jtuOcfbz00rlOCQj+f 7umI7UACpY7FWwIi4TsaOiLlLGdY3gyOSHlMpp+0TCwLlvAVX1dI/sjNVX22QyOLWIzY sUu0qy1EFYbr4DmSbWhSaTwfvzTbGqEC7JC1AuZzi/8prtoyxzXV+IqdG101qOLrLad2 oZUw== X-Gm-Message-State: AOAM531Wh0ItKHIZK/iy2hu7LOW96bmn5pl47Vt+qOhU79/vYkLRe5C5 g1aDK2RDcIYPtSMCjwMFlW9hCJc+XK8= X-Google-Smtp-Source: ABdhPJxdYnm5YiB6qt9Th2k681oMhjAP2HW8ZH5a5CiedpBhnbxKfibYEG3/3oWXkxN3T2GsESQ3nA== X-Received: by 2002:a17:906:948d:: with SMTP id t13mr14978340ejx.402.1616346508936; Sun, 21 Mar 2021 10:08:28 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:dc34:259e:8292:82c0]) by smtp.gmail.com with ESMTPSA id 90sm9108044edr.69.2021.03.21.10.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 10:08:28 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 4/6] memops: do not mess up with phisource's source ident Date: Sun, 21 Mar 2021 18:08:20 +0100 Message-Id: <20210321170822.46854-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> References: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org In rewrite_load_instruction(), when testing if all phi-sources are the same, the candidate is given an identifier if it hasn't one already. But doing this inside this loop is strange: * the pseudo may, at the end, not be selected but is changed anyway * the identifier should be given either when the phi-source is created or at the end of the loop if selected. So, do not change the identifier inside the selection loop. Signed-off-by: Luc Van Oostenryck --- memops.c | 1 - 1 file changed, 1 deletion(-) diff --git a/memops.c b/memops.c index 5386c5a1f416..119a39a180d5 100644 --- a/memops.c +++ b/memops.c @@ -29,7 +29,6 @@ static void rewrite_load_instruction(struct instruction *insn, struct pseudo_lis 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); /* From patchwork Sun Mar 21 17:08:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12153191 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 4BD78C433E5 for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1259B61946 for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230186AbhCURJH (ORCPT ); Sun, 21 Mar 2021 13:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbhCURIb (ORCPT ); Sun, 21 Mar 2021 13:08:31 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C28C6C061574 for ; Sun, 21 Mar 2021 10:08:30 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id u9so17489822ejj.7 for ; Sun, 21 Mar 2021 10:08:30 -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 :mime-version:content-transfer-encoding; bh=o9O/t7DIwQXjQjmlQ8dOVimiEpImz/xtfBcJterv9Ss=; b=A07jUq6b/8OnJ0alfY1ZqqtDdg3XhKF4Pr8bw71y310NvbajpxxlxgLVeE1TA6bL6y IsbXhKQ22sizG7WVh93SggeibD/kykbtMchbBfANqR4vsnEVnayXvV96u+1V3uFFqwkQ gh/YeEcm1DhlebmtHnqrGfAxE5IjCcY1H1nGnOFmq17Oq2/FAfdRP6Qwkdi8ivn8snVG G3wU+VQpQIUoxynTbQBVvAEZJErxYcghaAKQlhd03QXwX5i95m5Z8NQUZkStBBm6mYVW Iweod+LUV4Ui3Qpaa9im4wIx/OU93jrqevJsw/Q91SsJ6SinEbHrLlgvyuW1oenDDP/x w7FQ== 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=o9O/t7DIwQXjQjmlQ8dOVimiEpImz/xtfBcJterv9Ss=; b=Cn7PJra8t3OfXoMN2z8Rbynl0apRauV6V5A97h4ubUzk/7HFnN7E1vfQ6+GjQ28ddD 4/wauhxLiRmfNM+llUXrHSpnTR22RbMNhE4mskbWMRSced3+68IWgs5DOjLHm5omvIvK j2t7RA4ep+8B2PoGfNv/aIuI7MRBbNrgYJlLcCNjAPaP5T2z0mrUqNpvHzYAwii/0SWm tzsBd4l0VTdkMoFtchSz9i98OYdtA2pr+KUws9thcBb370AuHeuRJ/rPDRr2UAj266NR 3MR4/qeSjWUzTx76Zm5k1XzSDOQzYudYD5NfUyuUgyZ2OX0Mb2NHAJTNrFNVRlciIrBE L3Jg== X-Gm-Message-State: AOAM530VnF7hTSvzL0S4/fe7DHKdz2vLRwkAydhc6Adx1lNPtJc6gL8N X9+AgGm3abo4YZ/neT/2kONlN6Ka4QE= X-Google-Smtp-Source: ABdhPJySC82nmu3LmURTJ3K+nd5B0mSaU87RgivX0zCooxkTb2bXLWDf+f5ex34cKU4gh1UJg8fC1g== X-Received: by 2002:a17:906:f6ce:: with SMTP id jo14mr15637580ejb.476.1616346509603; Sun, 21 Mar 2021 10:08:29 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:dc34:259e:8292:82c0]) by smtp.gmail.com with ESMTPSA id 90sm9108044edr.69.2021.03.21.10.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 10:08:29 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 5/6] memops: avoid using first_pseudo() Date: Sun, 21 Mar 2021 18:08:21 +0100 Message-Id: <20210321170822.46854-6-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> References: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The loop in rewrite_load_instruction() uses first_pseudo() to not have to special case the first element. But this slightly complicates further changes. So, simply use a null-or-no-null test inside the loop to identify this first element. Signed-off-by: Luc Van Oostenryck --- memops.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/memops.c b/memops.c index 119a39a180d5..897fb6bf57fe 100644 --- a/memops.c +++ b/memops.c @@ -19,15 +19,17 @@ static void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *dominators) { - pseudo_t new, phi; + pseudo_t new = NULL; + pseudo_t 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) + if (!new) + new = phi->def->phi_src; + else if (new != phi->def->phi_src) goto complex_phi; } END_FOR_EACH_PTR(phi); From patchwork Sun Mar 21 17:08:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12153185 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 3F8B3C433E2 for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 238396192C for ; Sun, 21 Mar 2021 17:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230205AbhCURJJ (ORCPT ); Sun, 21 Mar 2021 13:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbhCURId (ORCPT ); Sun, 21 Mar 2021 13:08:33 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFC03C061574 for ; Sun, 21 Mar 2021 10:08:32 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id dm8so16588537edb.2 for ; Sun, 21 Mar 2021 10:08:32 -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 :mime-version:content-transfer-encoding; bh=gCVNznYt4xWAEnmklaw669LNcnYdLkZR1+ec1waUP5Q=; b=jN7Gj1iIEKM+HATbnIiLGsbhF4krR5UvgqrWD2TwciwsumHb3gi3V4FlQ+Qclt9yNN IVGPWKFlz9p/IPfavjff3fa4yeBySH7kBquWWtdzNXbt6LksJEA9G1ZmxPvdpmqrbLU3 9YTVfNjQvmd3K0thY1hqAI3R0GhEPb/CQXvvxztjMmrm8GLwVjKRKs3AXa4YlD/2r4qB t4QqBodQed2khpGYQSVwluiVl+S8UdJrDNXKkya8N7LIRiYDgHDFPxvntDo3Pxp8dTH7 RglEgAI76bgQUNKlNK3rzN5YeXkvKH94fZ7OViHwnt6EyD+qnkT+Yt+Ij/9rBANx4ebh dDJA== 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=gCVNznYt4xWAEnmklaw669LNcnYdLkZR1+ec1waUP5Q=; b=SWnM+GaLXGnxJlRbegbEMKgLcZcxHhn8RktIyUGRZXVsx+8293BWT0Nx8Hh33sgZgy GS48FwE7UWrqf8fPtvVl501rA1lk+zUQ4mF3b7goIOQFKJmo6OgEmDN4x74fm0KyyLvs b4DBW/VBo+NRKCS9sPvr7ntLoeSS+eiPnTz5WxcbD+/8lEPiucnfhHlatDUIR3oObfxw cfwzLTitJ5hHjsXM0JkOonfh2AqayPheHtJ7vYnuBfX/3kaZrtGCVp6n3FWBXqN5qtzM eLUl3DgK+KtnreWbmNmMx0/Fik9azGQgyKk6pFp48Fodk8TK/HJf+PhePMwprhZbkhEw uYLQ== X-Gm-Message-State: AOAM530/DX6owFPZlUeX3NOUB5vR0nk8AyV6olfQWPSoD8TsZfM5W7On Gzc7oxd0B/LRAP5+yamdDbmVVA5Vr60= X-Google-Smtp-Source: ABdhPJx759j6lLtqlmhzZXdXFWG+boO+6+PkzUDLGWH4o/12jjKJqjSTBK8e1I5oRSy/fU6L34B6iA== X-Received: by 2002:aa7:c353:: with SMTP id j19mr21297608edr.263.1616346510334; Sun, 21 Mar 2021 10:08:30 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:dc34:259e:8292:82c0]) by smtp.gmail.com with ESMTPSA id 90sm9108044edr.69.2021.03.21.10.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 10:08:30 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 6/6] memops: we can kill addresses unconditionally Date: Sun, 21 Mar 2021 18:08:22 +0100 Message-Id: <20210321170822.46854-7-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> References: <20210321170822.46854-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org In rewrite_load_instruction(), if the load instruction is converted into a phi-node, its address is then no more used and must be removed. However, this is only done when this address is not a symbol. This was explicitly done in the following commit because of the problem of removing an element from the usage list while walking this list: 602f6b6c0d41 ("Leave symbol pseudo usage intact when doing phi-node conversion.") But currently rewrite_load_instruction() is only used during memops simplification where the usage list is not walked. So, kill the address' usage unconditionally. Signed-off-by: Luc Van Oostenryck --- memops.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/memops.c b/memops.c index 897fb6bf57fe..6d24604c2aae 100644 --- a/memops.c +++ b/memops.c @@ -45,9 +45,7 @@ static void rewrite_load_instruction(struct instruction *insn, struct pseudo_lis goto end; complex_phi: - /* We leave symbol pseudos with a bogus usage list here */ - if (insn->src->type != PSEUDO_SYM) - kill_use(&insn->src); + kill_use(&insn->src); insn->opcode = OP_PHI; insn->phi_list = dominators;