From patchwork Mon Mar 19 00:33:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10291441 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 31B6E60291 for ; Mon, 19 Mar 2018 00:34:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24B8828F29 for ; Mon, 19 Mar 2018 00:34:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1992328F40; Mon, 19 Mar 2018 00:34:12 +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 A51FF28F29 for ; Mon, 19 Mar 2018 00:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754596AbeCSAeK (ORCPT ); Sun, 18 Mar 2018 20:34:10 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:53871 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754531AbeCSAeJ (ORCPT ); Sun, 18 Mar 2018 20:34:09 -0400 Received: by mail-wm0-f65.google.com with SMTP id e194so12178470wmd.3 for ; Sun, 18 Mar 2018 17:34:08 -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=Sjmm4kve2QOwslJdiPDLXBAyVHqiAfLmkWqjAkH7/aA=; b=vJ+jius4jl2Fp2cAgkMoWq204b1lT17tm9ef4i9sPwZUcH2cqe3C0eBR9u4fQzhytb jZvLJ5iE88Sixbro6ZWaK1DU1FL83iN2Lt0fZ7o3Bz4IPnGRdKpFxyUpY/k+eLgYMXcO kGbWOpyqFP5w+b6Wq4Id33viJdF/KZzHOhKgTAeo00KoDpc+7zm/uhjsvJBusM7x32E9 zvGd4nQyWcKMgCIN1J3eOmHTD1O8XWl3bIcFkWcLPd3lDnNL7tY3SnZ2CoWb4BEtf42s H9P679ilEpK0ENjUTUSNg+Wt3pHGGnLp6MYZyGZQsgeTR9TAD3APCHNy1aHXHdWC/gL4 PN4A== 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=Sjmm4kve2QOwslJdiPDLXBAyVHqiAfLmkWqjAkH7/aA=; b=CGmmzph1e4KfJe1KJOfnBME0Cz62vlD50uAIy6NKIy34qsT/AZdq8BUenc0QcoRTh0 8HaRzST20bG9YBpETFqdNeXI/EZjIwK8KQt2ZyOm88DmFs9kIFGYNlPYDqWFAONgbo2D ER6X26y3+qiKya88004qIDYfoUSnmyJUhwz+1/lwrU+G2yfJwmZnI3ULhOeRZSUKMOQN ynfjj319c7PnqI3n5AqfNwGVWLgeNhZcnWEGAuzg/DoFN7DXE99omsPvyNvwCO2d3KsR lSEdVsWqBaGiO73cdWqeOZKCSaTvxIWnyaL0SQX3n/L0+JjjSWshUBWzkbEeXvOHUaHo Di5A== X-Gm-Message-State: AElRT7HRDRBHR/mkKZhBadNWvkV0+DxMvhldTA7hDOxrmwUHLe7VcTRa vYPslooWrnWxFUuSym9RqzapAJjO X-Google-Smtp-Source: AG47ELtGrET8INvGNyQ1slMA44RA4hN7sdlZmUaVIC5phsoR/wNma0ye8E6ULF6ycxpcHtyewN/lww== X-Received: by 10.28.54.8 with SMTP id d8mr2150606wma.145.1521419648005; Sun, 18 Mar 2018 17:34:08 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:401e:ed00:e01b:1ecc:3247:52ec]) by smtp.gmail.com with ESMTPSA id d48sm7139898wrd.12.2018.03.18.17.34.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Mar 2018 17:34:07 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/7] kds: add testcases for kill_dead_stores() Date: Mon, 19 Mar 2018 01:33:48 +0100 Message-Id: <20180319003354.90872-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319003354.90872-1-luc.vanoostenryck@gmail.com> References: <20180319003354.90872-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 Signed-off-by: Luc Van Oostenryck --- validation/optim/kill-stores0.c | 35 +++++++++++++++++++++++++++++ validation/optim/kill-stores1.c | 49 +++++++++++++++++++++++++++++++++++++++++ validation/optim/kill-stores2.c | 18 +++++++++++++++ validation/optim/live-stores0.c | 29 ++++++++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 validation/optim/kill-stores0.c create mode 100644 validation/optim/kill-stores1.c create mode 100644 validation/optim/kill-stores2.c create mode 100644 validation/optim/live-stores0.c diff --git a/validation/optim/kill-stores0.c b/validation/optim/kill-stores0.c new file mode 100644 index 000000000..eb6eaa4e3 --- /dev/null +++ b/validation/optim/kill-stores0.c @@ -0,0 +1,35 @@ +struct p { + int x, y; +}; + +struct q { + int w; +}; + +static int foo(void) +{ + int x = 1; + int y = x; + return &x == &y; +} + +static int bar(struct p p) +{ + if (p.x != 0) + ; +} + +static int baz(struct p p, struct q q) +{ + if (p.x != 0 || p.y != 1 || q.w == 0) + ; +} + +/* + * check-name: kill-stores0 + * check-command: test-linearize $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: store\\. + */ diff --git a/validation/optim/kill-stores1.c b/validation/optim/kill-stores1.c new file mode 100644 index 000000000..095378720 --- /dev/null +++ b/validation/optim/kill-stores1.c @@ -0,0 +1,49 @@ +struct s { + int c[1]; +}; + +static struct s x, y; +static int p; + +static void foo0(void) +{ + (x = y).c; // x = y; +} + +static void foo1(void) +{ + int *t = (x = y).c; // x = y; +} + +static void foo2(void) +{ + (x = y).c + 1; // x = y; +} + +static void foo3(void) +{ + (x = y).c[0]; // x = y; +} + +static void foo4(void) +{ + (p ? x : y).c[0]; // ; +} + +static void foo5(void) +{ + (p, y).c[0]; // ; +} + +/* + * check-name: kill-stores1 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-pattern(4): load\\. + * check-output-pattern(4): load\\..*0\\[y\\] + * check-output-pattern(4): store\\. + * check-output-pattern(4): store\\..*0\\[x\\] + * check-output-excludes: select\\. + */ diff --git a/validation/optim/kill-stores2.c b/validation/optim/kill-stores2.c new file mode 100644 index 000000000..692888489 --- /dev/null +++ b/validation/optim/kill-stores2.c @@ -0,0 +1,18 @@ +extern void def(int *); + +static void foo(void) +{ + int c; + def(&c); + if (c) + c = c; +} + +/* + * check-name: kill-stores2 + * check-command: test-linearize $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: store\\. + */ diff --git a/validation/optim/live-stores0.c b/validation/optim/live-stores0.c new file mode 100644 index 000000000..2cbc5ab14 --- /dev/null +++ b/validation/optim/live-stores0.c @@ -0,0 +1,29 @@ +void init(int *x); + +static int foo(void) +{ + int a[2] = { 0, 123, }; + + if (a[1] != 123) + return 1; + init(a); + if (a[1] == 123) + return 2; + return 0; +} + +#if 0 +void init(int *x) +{ + x[0] = x[1] = 0; +} +#endif + +/* + * check-name: live-stores + * check-command: test-linearize $file + * + * check-output-ignore + * check-output-contains: store.32 *\\$123 + * check-output-pattern(2,3): store\\. + */