From patchwork Wed Aug 23 20:15:38 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: 9918303 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 22EA5602CB for ; Wed, 23 Aug 2017 20:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15DC128A2C for ; Wed, 23 Aug 2017 20:17:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B00F28A2E; Wed, 23 Aug 2017 20:17:06 +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 A1D2928A2C for ; Wed, 23 Aug 2017 20:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932629AbdHWURF (ORCPT ); Wed, 23 Aug 2017 16:17:05 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36074 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932567AbdHWURE (ORCPT ); Wed, 23 Aug 2017 16:17:04 -0400 Received: by mail-wm0-f65.google.com with SMTP id f127so641890wmf.3 for ; Wed, 23 Aug 2017 13:17:04 -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=HbYUZjomm/gIkm/ECK1UCX0Z8NUb7kmN7NL3XfCOg+Y=; b=KhHfnb4vKCBWhPTWg/ow6ne7QCyw//n06QtUDY8VYb5gclh2lpeTInyu63Y/TYnlhm jcsIXIC9MMoWN1XYnlMkRFfgC/8JAgg587bIVKRGslo/nZ26+oQtQJrtOPcDMX9Bt+iL ZkYct7ViGOSUzbwrPE9MZLhZf6fHUye98gKBmYL30op0P/4NYIyxeYjtwjD0kHpdRbst 9BrbFUiU6J14DNTjzONdjoCy45KTz7Zmz+JCXLgMbFOSwinB6yoUY/Pckw8ZP6ZqVt3Z BGIoRswloRdahLW3FXMvrV1Q7VsTGK7EibW6lA8E2iPuzU77SIO2921F98JCOt+hZ3Ah ZQhw== 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=HbYUZjomm/gIkm/ECK1UCX0Z8NUb7kmN7NL3XfCOg+Y=; b=QnEqlWw+hivZBTpz9BBLH46S3gRuCLmjrLHZk1ghEMflVsLoXFn4pcgZ2qbRsiXJ84 nP517u99sAR3675Q+JHcrwDKFnfMZ5Ttv255AShWxFo2xoxgdukoHwYSUTwhy/pu2bFM Ck58AaRbQafCdDkZp9uJXS8mTFAuUxuyFJjjkm9mb+qkzckWnFMl66nN5luOmJYJRJ7E EjpJ4/XnBplWBbLWiDXoRir1bvcQGGtJbbiDYOmJ9lyQUSYGu9d19w/vTqGlGQXGUsVJ IemI9IXC/U9gxVTzsI1P6AZ6ojOxVo+ZLm1xoFb76hlXORddMQCWiwfYGzdZPHYVed5z nFbA== X-Gm-Message-State: AHYfb5jhZkKyeGWJs5OgbSAMbVEgU4gY99aqq+OHhdbODvz/Msn2bUCR Qulqlm1yBrem6e9yY/w= X-Received: by 10.80.171.24 with SMTP id s24mr4131222edc.150.1503519423292; Wed, 23 Aug 2017 13:17:03 -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.17.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 13:17:02 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [RFC PATCH 32/48] mem2reg: add flags to enable/disable some parts Date: Wed, 23 Aug 2017 22:15:38 +0200 Message-Id: <20170823201554.90551-33-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 --- lib.c | 8 ++++++++ lib.h | 6 +++++- mem2reg.c | 3 +++ memops.c | 17 ++++++++++++++++- sparse.1 | 28 ++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/lib.c b/lib.c index d3aaf10d2..0705775e5 100644 --- a/lib.c +++ b/lib.c @@ -260,6 +260,10 @@ int dbg_dead = 0; int fmem_report = 0; int fdump_ir; unsigned long long fmemcpy_max_count = 100000; +int fpromote_symbols_usage = 1; +int fsimplify_loads = 1; +int fsimplify_loads_full = 0; // currently broken +int fsimplify_stores = 1; int preprocess_only; @@ -780,6 +784,10 @@ err: static struct flag fflags[] = { { "mem-report", &fmem_report }, + { "promote-symbols-usage", &fpromote_symbols_usage }, + { "simplify-loads", &fsimplify_loads }, + { "simplify-loads-full", &fsimplify_loads_full }, + { "simplify-stores", &fsimplify_stores }, { }, }; diff --git a/lib.h b/lib.h index d0b699535..a2fd04e67 100644 --- a/lib.h +++ b/lib.h @@ -154,9 +154,13 @@ extern int dump_macro_defs; extern int dbg_entry; extern int dbg_dead; -extern int fmem_report; extern int fdump_ir; +extern int fmem_report; extern unsigned long long fmemcpy_max_count; +extern int fpromote_symbols_usage; +extern int fsimplify_loads; +extern int fsimplify_loads_full; +extern int fsimplify_stores; extern int arch_m64; extern int arch_msize_long; diff --git a/mem2reg.c b/mem2reg.c index 26837935c..c2f77ffbe 100644 --- a/mem2reg.c +++ b/mem2reg.c @@ -359,6 +359,9 @@ void promote_symbols_usage(struct entrypoint *ep) { pseudo_t pseudo; + if (!fpromote_symbols_usage) + return; + FOR_EACH_PTR(ep->accesses, pseudo) { promote_symbol(ep, pseudo->sym); } END_FOR_EACH_PTR(pseudo); diff --git a/memops.c b/memops.c index 99430e455..501973788 100644 --- a/memops.c +++ b/memops.c @@ -120,15 +120,30 @@ next_store: } END_FOR_EACH_PTR_REVERSE(insn); } -void simplify_memops(struct entrypoint *ep) +static void simplify_all_loads(struct entrypoint *ep) { struct basic_block *bb; + if (!fsimplify_loads) + return; FOR_EACH_PTR_REVERSE(ep->bbs, bb) { simplify_loads(bb); } END_FOR_EACH_PTR_REVERSE(bb); +} + +static void simplify_all_stores(struct entrypoint *ep) +{ + struct basic_block *bb; + if (!fsimplify_stores) + return; FOR_EACH_PTR_REVERSE(ep->bbs, bb) { kill_dominated_stores(bb); } END_FOR_EACH_PTR_REVERSE(bb); } + +void simplify_memops(struct entrypoint *ep) +{ + simplify_all_loads(ep); + simplify_all_stores(ep); +} diff --git a/sparse.1 b/sparse.1 index c7ad4483b..87958ef35 100644 --- a/sparse.1 +++ b/sparse.1 @@ -378,6 +378,34 @@ Set the distance between tab stops. This helps sparse report correct column numbers in warnings or errors. If the value is less than 1 or greater than 100, the option is ignored. The default is 8. . +.SH DEVELOPER OPTIONS +.TP +.B \-fno-promote-symbol-usage +Enable or disable the promotion of memory accesses via symbol to registers. + +This option is enabled by default. +. +.TP +.B \-fno-simplify-loads +Enable or disable the promotion of memory loads to registers during +the optimization passes. + +This option is enabled by default. +. +.TP +.B \-fsimplify-loads-full +Enable or disable the promotion of complex memory loads to registers during +the optimization passes. + +This option is disabled by default. +. +.TP +.B \-fno-simplify-stores +Enable or disable the elimination of some stores to memory during +the optimization passes. + +This option is enabled by default. +. .SH SEE ALSO .BR cgcc (1) .