From patchwork Wed Aug 23 20:15:33 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: 9918293 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 A228C602CB for ; Wed, 23 Aug 2017 20:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 948AB28A2C for ; Wed, 23 Aug 2017 20:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 884E828A2E; Wed, 23 Aug 2017 20:16:54 +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 3B40C28A2C for ; Wed, 23 Aug 2017 20:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932600AbdHWUQy (ORCPT ); Wed, 23 Aug 2017 16:16:54 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33764 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932567AbdHWUQx (ORCPT ); Wed, 23 Aug 2017 16:16:53 -0400 Received: by mail-wm0-f65.google.com with SMTP id b79so663167wmf.0 for ; Wed, 23 Aug 2017 13:16:52 -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=PXmEh7MPW0CUi2dJ4rWOe3vnyr+Ej2EDQ3Zj4nFlbQA=; b=TyDfpS8HPT9zzYKE6rEXqNuzgwS8FI0a3kDQpeliBQH6f9GdOXrfu9fuzqFyOu9eRa jnNMghtpd8fWiY7a1NAFEhbYplIiuxElY1GZvk/oQ5KkMrHzR5wSVhxlLRs3RCHHzxCE uQHFfLcxBOUC9T95IvIIrzlV3hDPC8zcl6JWEok9AR3WF3KFWDHRerIlpWv4ZPHXbRxO Hvz3lH9MnISMSMZfUJDbPLPGbWP83fiK4+QF8rdYAGOho4abhiaeLuPoswMPmfoKapBe jfFZQcbwS51ReIywS3EoptGmWNpu5JnrLM9pn6Reci3XdLa/u2Xf4PreMGq8VvPXyZ72 qsow== 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=PXmEh7MPW0CUi2dJ4rWOe3vnyr+Ej2EDQ3Zj4nFlbQA=; b=AtoM/ZG7YcWALAFonpqZXSRlfqfP6G4H65lW8Mty2LGXtimCNsyOVGnWHk/n4ioE1i OzaP+XDtgrQS7lh265UBtOoWVu7GukZ5NOhDVMZexIeHwY1IcJ3gMcXID10/3QV8Cafj 7/tvFgXFOa1fTReiImSumsE9IN6PR1jTpoLgzxwWqu80aRW8O7iclpx4Rjl9Ngc0aNo2 f0T8Pn39f7W0cJ08hbQbaDiaslXHQNvaj/WN2Ou90JgQ6QDwpZClZpNXufYCm5GxHL7I BhDVTg9rJTHbVpGvDd5/kbBAK5TlFQc4Du1RcJLA3N/ZMQjwwr1nF65tJBUIk+XBvnFm uRsA== X-Gm-Message-State: AHYfb5jUM98gNBwt3oPZuG9yzKdZrFcyV7lqjinIF/AHu9zsUw1+rdR8 1YuSoPYFRegmcV+3wFg= X-Received: by 10.80.206.7 with SMTP id y7mr4067745edi.276.1503519412122; Wed, 23 Aug 2017 13:16:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 13:16:51 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [RFC PATCH 27/48] mem2reg: extract kill_pseudo_stores() Date: Wed, 23 Aug 2017 22:15:33 +0200 Message-Id: <20170823201554.90551-28-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 --- mem2reg.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mem2reg.c b/mem2reg.c index 7096a4bf2..4671d4710 100644 --- a/mem2reg.c +++ b/mem2reg.c @@ -148,6 +148,17 @@ static void kill_store(struct instruction *insn) } } +static void kill_pseudo_stores(pseudo_t pseudo) +{ + struct pseudo_user *pu; + + FOR_EACH_PTR(pseudo->users, pu) { + struct instruction *insn = pu->insn; + if (insn->opcode == OP_STORE) + kill_store(insn); + } END_FOR_EACH_PTR(pu); +} + /* Kill a pseudo that is dead on exit from the bb */ static void kill_dead_stores(pseudo_t pseudo, unsigned long generation, struct basic_block *bb, int local) { @@ -307,11 +318,7 @@ static void promote_symbol(struct entrypoint *ep, struct symbol *sym) /* If we converted all the loads, remove the stores. They are dead */ if (all && !mod) { - FOR_EACH_PTR(pseudo->users, pu) { - struct instruction *insn = pu->insn; - if (insn->opcode == OP_STORE) - kill_store(insn); - } END_FOR_EACH_PTR(pu); + return kill_pseudo_stores(pseudo); } else { /* * If we couldn't take the shortcut, see if we can at least kill some