From patchwork Sun Sep 9 23:53:24 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: 10593527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50D9614E2 for ; Mon, 10 Sep 2018 02:55:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DCB528CC3 for ; Mon, 10 Sep 2018 02:55:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E5A428D0C; Mon, 10 Sep 2018 02:55:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 9A8A928CC3 for ; Mon, 10 Sep 2018 02:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726132AbeIJHqt (ORCPT ); Mon, 10 Sep 2018 03:46:49 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53964 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725960AbeIJHqt (ORCPT ); Mon, 10 Sep 2018 03:46:49 -0400 Received: by mail-wm0-f66.google.com with SMTP id b19-v6so19909190wme.3 for ; Sun, 09 Sep 2018 19:55:02 -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=SgqGoS7BHC02IjfsogezWuKtBF1aAfcQcEzl64td274=; b=AYNLSkr8LVp2Ka9iiDMOrgRXWQcL7IgyZ+6993d1L/zPzkQj6Q2sRQUM0dko3tQ8uq ESwUaRfRNaPAB2Ddc/BzysRYNUmk9S13HLWh3SdxiUhtNkEuBSswTMk/S/8/5UoI2se4 b2jMzThM9SMCE8omYv9lZDv3eQ901STw9pvTED6gwlocOF56kU/MuW4y9CLdkmIgTjYt +tEDPxjMl4+c7U14usElDO4iHNht8TTlh9HQu+URi9PqkyI8/SnbMzQ4DNxG43E9lMTL oWupFj4LKLiuRAxE+cr3mUtaEk3p1gdElhOo+j+jQZyTQ54zA0Ic6gvEwJzNrZW94/td KW8g== 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=SgqGoS7BHC02IjfsogezWuKtBF1aAfcQcEzl64td274=; b=bgWilIrGFSdu1V1cBQF1N/z/sD34wsuoqf2lM1ZXGMhe5VanzSF5wSPzLxijK3p2H1 pldWB8xKG00WY8s1Yy/dAr7AuX5mURdezhzTAv3nwG4jgzyVGVhYlVEvmUioBcNiYBvI qfNEaRwZdR/GvnzJ32NuUbz6h16G9CWLEpRHMeAePZihHR7axAGqbHkUKCYgmEI4njqe DXgUauDK3JlvPjjoj3Z9kIp3/BA/p5KRBZEnBlCljxXm7Ng9J7ypanMnwy7RgoiYSZjf sN+QFI9BIkkpJof45LJ4ibZDstKf+RJiYUSyfik5KWZYUbLWTTQ1W6w8dI3X1IvLTzKq 3JqQ== X-Gm-Message-State: APzg51BvR52F629gpqXJyJ7vSuoofnVDRx76Lxjy8MwQGBfo2Jls9kNY PhxMJHUtDF/Ligh5CI1kxQcoR6sr X-Google-Smtp-Source: ANB0VdZHRoRn97T4IxiWCYLLyJYsiSuEL4z0xW4wp0GnJiwynXugveRzFwOeTNUYsFTz8TENynthcA== X-Received: by 2002:a1c:b9cf:: with SMTP id j198-v6mr11521772wmf.93.1536537330858; Sun, 09 Sep 2018 16:55:30 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4006:df00:5977:db62:b6c9:6a45]) by smtp.gmail.com with ESMTPSA id n11-v6sm15121516wra.26.2018.09.09.16.55.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:55:30 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH 1/4] test: make test Waddress-space-strict succeed on 32-bit Date: Mon, 10 Sep 2018 01:53:24 +0200 Message-Id: <20180909235327.26252-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180909235327.26252-1-luc.vanoostenryck@gmail.com> References: <20180909235327.26252-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 The test Waddress-space-strict made assumptions about the relative size of integers & pointers. Since this test was crafted on a 64-bit machine, the test was running fine for LP64 but failed on a 32-bit machine (or anything using IP32, like using the -m32 option). However, since the test is about conversion of address-spaces, using integers of different size adds no value, and indeed brings problems. Fix this by limiting the conversions to a single integer type, the one with the same size as pointers on ILP32 & LP64: long. Reported-by: Ramsay Jones Signed-off-by: Luc Van Oostenryck --- validation/Waddress-space-strict.c | 33 +++++++----------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/validation/Waddress-space-strict.c b/validation/Waddress-space-strict.c index 5071aab26..871da282a 100644 --- a/validation/Waddress-space-strict.c +++ b/validation/Waddress-space-strict.c @@ -1,33 +1,22 @@ #define __user __attribute__((address_space(1))) typedef unsigned long ulong; -typedef long long llong; typedef struct s obj_t; -static void expl(int i, ulong u, llong l, void *v, obj_t *o, obj_t __user *p) +static void expl(ulong u, void *v, obj_t *o, obj_t __user *p) { - (obj_t*)(i); - (obj_t __user*)(i); - (obj_t*)(u); (obj_t __user*)(u); - (obj_t*)(l); - (obj_t __user*)(l); - (obj_t*)(v); (obj_t __user*)(v); - (int)(o); (ulong)(o); - (llong)(o); (void *)(o); (obj_t*)(o); (obj_t __user*)(o); - (int)(p); // w (ulong)(p); // w! - (llong)(p); // w (void *)(p); // w (obj_t*)(p); // w (obj_t __user*)(p); // ok @@ -38,19 +27,11 @@ static void expl(int i, ulong u, llong l, void *v, obj_t *o, obj_t __user *p) * check-command: sparse -Wcast-from-as -Wcast-to-as $file * * check-error-start -Waddress-space-strict.c:10:10: warning: cast adds address space to expression () -Waddress-space-strict.c:13:10: warning: cast adds address space to expression () -Waddress-space-strict.c:16:10: warning: cast adds address space to expression () -Waddress-space-strict.c:19:10: warning: cast adds address space to expression () -Waddress-space-strict.c:26:10: warning: cast adds address space to expression () -Waddress-space-strict.c:28:10: warning: cast removes address space of expression -Waddress-space-strict.c:29:10: warning: cast removes address space of expression -Waddress-space-strict.c:30:10: warning: cast removes address space of expression -Waddress-space-strict.c:31:10: warning: cast removes address space of expression -Waddress-space-strict.c:32:10: warning: cast removes address space of expression -Waddress-space-strict.c:9:18: warning: non size-preserving integer to pointer cast -Waddress-space-strict.c:10:25: warning: non size-preserving integer to pointer cast -Waddress-space-strict.c:21:15: warning: non size-preserving pointer to integer cast -Waddress-space-strict.c:28:15: warning: non size-preserving pointer to integer cast +Waddress-space-strict.c:9:10: warning: cast adds address space to expression () +Waddress-space-strict.c:12:10: warning: cast adds address space to expression () +Waddress-space-strict.c:17:10: warning: cast adds address space to expression () +Waddress-space-strict.c:19:10: warning: cast removes address space of expression +Waddress-space-strict.c:20:10: warning: cast removes address space of expression +Waddress-space-strict.c:21:10: warning: cast removes address space of expression * check-error-end */ From patchwork Sun Sep 9 23:53:25 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: 10593525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED93F14E2 for ; Mon, 10 Sep 2018 02:53:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9AAB28CC3 for ; Mon, 10 Sep 2018 02:53:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE1AC28D0C; Mon, 10 Sep 2018 02:53:38 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 5FDD428CC3 for ; Mon, 10 Sep 2018 02:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725960AbeIJHpW (ORCPT ); Mon, 10 Sep 2018 03:45:22 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33860 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbeIJHpW (ORCPT ); Mon, 10 Sep 2018 03:45:22 -0400 Received: by mail-wm0-f68.google.com with SMTP id j25-v6so4219441wmc.1 for ; Sun, 09 Sep 2018 19:53:36 -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=u4824QY+X1fcmoLgY50BwR9ljy4D+tdLpVmBmWWfa4w=; b=kLCnlWa+y+zj6ucYk5a8qRYOWcetbZIOOoGTIIlY/nhYi//l9578yeAj7dvdV+InUT g0iDCRrA2etkZH9Spy9HKt6kQsmdKq6V0X570mTMQUX8LtSnHt75V13qQAjDoSsaWiVJ xh/gbgjlQal4DZw+6bHuQxcHpcRc6EVQIMHmXQ5sZYeOC0OZgSvTNmys+cmll+95dgBF H7o875Owv9dQydYGyi/I5zINwlfx2xe/VxMW6tZgJO1Y3lT3R5ITk9TQVYIxjll27QrK o9vyDQ+PUtum2wdikMemzg8cD9zp50ghkbwPqHBLLJXW5dCsGYkigWPhLgZ20LbYUgR5 KYJw== 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=u4824QY+X1fcmoLgY50BwR9ljy4D+tdLpVmBmWWfa4w=; b=sgwXvzkPyJHtFM6on715OlUsQi68GrIcEERxJvlcGz99INtSxeF+111LpvHtsLoETe 2tvouFgbiu1hxn+9dIkeWd22ixK8oh2vd9t1Q8sc80qoCl+8aVUJLh48Jaezxn+Ip2Nv OG1iFgMXiaet4IksjPuJcOHMAEQux5o/mrBfSpRuPbvMGp57yeaymf/fGbsiJu24CAoD E1wOSM9pvgA3GxFgoKzvTkM41qu9aWfWADOR/Vl9LraJhR0Yfg1PB12ydU+FxUOMNFi1 riodr4JJrqdUFo6IsuR+Zca5WAeghOeGwedW4CZy6iWmJqRlSXstaXoaP+9BEmxffuka vlvw== X-Gm-Message-State: APzg51BcyFzZDGf8P1lAwwX8OQD7bD5IHlZPVgNNqsaaeJyBzQzctM3C 2rVPeXunQXekuWQTpNXEfcFJeSkk X-Google-Smtp-Source: ANB0VdaqQyJepR4Pwnq3F2I12uRSv8mzmn6bsmd4kOzf+rqfiZ5Nh2QgXxVl7tqf7duBqdXbqsTXoA== X-Received: by 2002:a1c:9808:: with SMTP id a8-v6mr10209636wme.62.1536537331848; Sun, 09 Sep 2018 16:55:31 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4006:df00:5977:db62:b6c9:6a45]) by smtp.gmail.com with ESMTPSA id n11-v6sm15121516wra.26.2018.09.09.16.55.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:55:31 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH 2/4] test: use integers of different sizes, even on 32-bit Date: Mon, 10 Sep 2018 01:53:25 +0200 Message-Id: <20180909235327.26252-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180909235327.26252-1-luc.vanoostenryck@gmail.com> References: <20180909235327.26252-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 The test optim/cse-size fials on 32-bit because it needs two integers of different size but uses int & long. These two types have indeed different sizes on 64-bit (LP64) but not on 32-bit (ILP32). Fix this by using short & int. Reported-by: Ramsay Jones Signed-off-by: Luc Van Oostenryck --- validation/optim/cse-size.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validation/optim/cse-size.c b/validation/optim/cse-size.c index e98c3cde7..5b31420c8 100644 --- a/validation/optim/cse-size.c +++ b/validation/optim/cse-size.c @@ -1,7 +1,7 @@ static void foo(void) { - unsigned p = 0; - long x; + unsigned short p = 0; + int x; for (;;) if (p) From patchwork Sun Sep 9 23:53:26 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: 10593523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF4C0112B for ; Mon, 10 Sep 2018 02:50:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD57728DFD for ; Mon, 10 Sep 2018 02:50:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD5CF28F4F; Mon, 10 Sep 2018 02:50:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 523F328DFD for ; Mon, 10 Sep 2018 02:50:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbeIJHlr (ORCPT ); Mon, 10 Sep 2018 03:41:47 -0400 Received: from mail-wr1-f49.google.com ([209.85.221.49]:41910 "EHLO mail-wr1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbeIJHlr (ORCPT ); Mon, 10 Sep 2018 03:41:47 -0400 Received: by mail-wr1-f49.google.com with SMTP id z96-v6so20211923wrb.8 for ; Sun, 09 Sep 2018 19:50:01 -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=XPhWMwYwLvFj1SNAI5uEA+jMFXoAcLvrC4X1bOpKv1s=; b=OlwSv3yViKhq0qZx7LUzx3FKHQs/jM3AI8I08TKbMVxkesJ9WLWLywQskZu77gR6T+ Z+voipDolKnCgyQ7SuU6OOXzIZK+Jx3DK4/qvT/Vxd0oiWas+ru7Ako6EYV0BavVb3AN Z6YylsY9v6KPJQaKqDceG/gl6wCrHaH3bkhAdyFuSmw64VSB1Hqelru3LmY4gEi/3fl1 6yZr5gezJKDw6hCAvHlMwiAtTAKPA450bEF5Q6BzwD/MGhrhBoExUgQh8hJWB76Z8LUQ hBSXG/kmu45NHh1LmbUdP1smb4ySPIJmqtsbQmBRge9Gl1KTg2hBQ54rjrfMyghXPyf1 cdZw== 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=XPhWMwYwLvFj1SNAI5uEA+jMFXoAcLvrC4X1bOpKv1s=; b=WoFdiAc3VqNbWwiCiSvtQCFeTIyfhK+glvmCLYy6jDEpE2bWU/zNUVwbpxoYXX98I7 +q/MEnngvQNH6VyhOkEeF3Opw/WO1yd2J7tzUhIKjBjmWMNl1RKH0zLQdWlxs+H1fp/c rbb1OX2fjIlYIXKjLVXnyLYLfZkuirhFq6pOxa8lljXC1qbl90HIyz3qox2dEmA/TMOh i007AORF8eJWwD68BFuSv6HswQLR4KRWUSo2RlZrJHwUBhx1Whcf0repi571dzB3KmKO iEEyXzXcBna5lBlkP5vARFkPseNB1ts9j31Gsepgs4AwUkHocf1A79jTXE13VRbnkcmn /moA== X-Gm-Message-State: APzg51DDgoBebHnanrtfCnC0fNX+Evd2YOdGOyxpRNgwZiYYck7OBYab +KBqRIeiHZ1pFhXOaQa0dnzu4uiR X-Google-Smtp-Source: ANB0VdZ3aRjKcr915hSJrE62lasZYd3n66U/JmTf64JNGNYC/1SUeQu6MSgSDoFsKQZfqtMeFvnSGQ== X-Received: by 2002:adf:fd90:: with SMTP id d16-v6mr13573568wrr.276.1536537332861; Sun, 09 Sep 2018 16:55:32 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4006:df00:5977:db62:b6c9:6a45]) by smtp.gmail.com with ESMTPSA id n11-v6sm15121516wra.26.2018.09.09.16.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:55:32 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH 3/4] test: make 32-bit version of failed test Date: Mon, 10 Sep 2018 01:53:26 +0200 Message-Id: <20180909235327.26252-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180909235327.26252-1-luc.vanoostenryck@gmail.com> References: <20180909235327.26252-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 The test mem2reg/init-local.c succeeds on 64-bit but fails on 32-bit. Duplicate the test, one with -m64 and the other with -m32 and mark this one as known-to-fail. Reported-by: Ramsay Jones Signed-off-by: Luc Van Oostenryck --- validation/mem2reg/init-local32.c | 29 +++++++++++++++++++ .../mem2reg/{init-local.c => init-local64.c} | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 validation/mem2reg/init-local32.c rename validation/mem2reg/{init-local.c => init-local64.c} (71%) diff --git a/validation/mem2reg/init-local32.c b/validation/mem2reg/init-local32.c new file mode 100644 index 000000000..c988bb6e7 --- /dev/null +++ b/validation/mem2reg/init-local32.c @@ -0,0 +1,29 @@ +int ssimple(void) +{ + struct { + int a; + } s; + + s.a = 1; + return s.a; +} + +double sdouble(void) +{ + struct { + double a; + } s; + + s.a = 1.23; + return s.a; +} + +/* + * check-name: init-local32 + * check-command: test-linearize -Wno-decl -m32 -fdump-ir=mem2reg $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: load\\. + * check-output-excludes: store\\. + */ diff --git a/validation/mem2reg/init-local.c b/validation/mem2reg/init-local64.c similarity index 71% rename from validation/mem2reg/init-local.c rename to validation/mem2reg/init-local64.c index d51c9247a..72f89742b 100644 --- a/validation/mem2reg/init-local.c +++ b/validation/mem2reg/init-local64.c @@ -19,8 +19,8 @@ double sdouble(void) } /* - * check-name: init-local - * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file + * check-name: init-local64 + * check-command: test-linearize -Wno-decl -m64 -fdump-ir=mem2reg $file * check-output-ignore * check-output-excludes: load\\. * check-output-excludes: store\\. From patchwork Sun Sep 9 23:53:27 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: 10593529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75F03112B for ; Mon, 10 Sep 2018 03:01:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29D2028D4B for ; Mon, 10 Sep 2018 03:01:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B76928D51; Mon, 10 Sep 2018 03:01:51 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 ADBFC28D4B for ; Mon, 10 Sep 2018 03:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726045AbeIJHxg (ORCPT ); Mon, 10 Sep 2018 03:53:36 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:37522 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbeIJHxg (ORCPT ); Mon, 10 Sep 2018 03:53:36 -0400 Received: by mail-wm0-f66.google.com with SMTP id n11-v6so19703766wmc.2 for ; Sun, 09 Sep 2018 20:01:48 -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=HtR6UPuQUq+eOzF2DkezP0TR2A1cSxTG7l5Ddugpqrw=; b=qKV7gWJBfchZ4WBPhiDH9xBKy441uWM+EIzvIRtUk4uPeXwtamJDk83LqYidq08luH 4r/Fojv6IDWaVdiS3cdh7htRp9tzoCV3y0DV7bUsVR6T517bEA5wTvSg4oUemIfTkEGL Yg6n02TzmFPK2jCcYPPZpErg982KM1CumHq1A8ykJ1xRCMkgymNulp/K8Je8YZM6ICpN 5138jiUInlVZpuuUaQbSGyrEbDlQmg4Pek3jQMgcEzgu/OrinWkuOFDdMsfjYqVcxWth 7enwWfepFOOLI2DFIHnGLxF6OF1uEZCp11HKOAvv9ehxcS0VinZYGzQRcf6HrpDQToYl q/yA== 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=HtR6UPuQUq+eOzF2DkezP0TR2A1cSxTG7l5Ddugpqrw=; b=tkLFMZropNPcCnMmA2IcbXh4guE9auT9fO8wDfp6z34y7CucLYWszDwZYu8lvCM7hK j5wkjGSHKT7VfBaLhjcvNLdY3UyWqCFM4AK6ePVqaGFwXXo/3sb0yIEUNmgal5s+pduz 0OijAZGsHEPojnM1ZuXwohwoMbLJ4hziRzQvcyq6HA4WmQWBuphy99NY5mZkU3LspQ92 kBh/45teSwP/b230yPfuyEmjMtLvOcm6CAdHNbmiKr+z7KUs1lIIZLIA+42nTp0ajt5m CPT81mlhRaUyfnpSXPHlGKbCoit+ycDusPs8GrF5OgcT5bjHGFE1Vh/zoIECRqID/Zzf OuLw== X-Gm-Message-State: APzg51B751c3O5EoZdR3BGGGbGn8gwoobb87o/GGEUJJHQqHgW/l0DfB bG09r2VhojQmUEaQpq9w3w+oQcsh X-Google-Smtp-Source: ANB0Vdb53+/4MdOOvEBeJBXGzr3Jd98SXQ56hfkZ3La8FR5tjxY7UriXaVQkt0ydGzJdRl8NPSAINA== X-Received: by 2002:a1c:4e16:: with SMTP id g22-v6mr11990267wmh.111.1536537333654; Sun, 09 Sep 2018 16:55:33 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4006:df00:5977:db62:b6c9:6a45]) by smtp.gmail.com with ESMTPSA id n11-v6sm15121516wra.26.2018.09.09.16.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:55:33 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH 4/4] ssa: relax what can be promoted Date: Mon, 10 Sep 2018 01:53:27 +0200 Message-Id: <20180909235327.26252-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180909235327.26252-1-luc.vanoostenryck@gmail.com> References: <20180909235327.26252-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 During SSA conversion, it is checked what can be promoted and what cannot. Obviously, ints, longs, pointers can be promoted, enums and bitfields can too. Complication arise with unions and structs. Currently union are only accepted if they contains integers of the same size. For structs its even more complicated because we want to convert simple bitfields. What should be accepted is structs containing either: * a single scalar * only bitfields and only if the total size is < long However the test was slightly more strict than that: it dodn't allowed a struct with a total size bigger than a long. As consequence, on IP32, a struct containing a single double wasn't promoted. Fix this by moving the test about the total size and only if some bitfield was present. Reported-by: Ramsay Jones Signed-off-by: Luc Van Oostenryck --- ssa.c | 4 ++-- validation/mem2reg/init-local32.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ssa.c b/ssa.c index 1c1ec6952..3e8800507 100644 --- a/ssa.c +++ b/ssa.c @@ -30,8 +30,6 @@ static inline bool is_promotable(struct symbol *type) case SYM_RESTRICT: // OK, always integer types return 1; case SYM_STRUCT: - if (type->bit_size > long_ctype.bit_size) - return 0; // we allow a single scalar field // but a run of bitfields count for 1 nbr = 0; @@ -49,6 +47,8 @@ static inline bool is_promotable(struct symbol *type) if (nbr++) return 0; } END_FOR_EACH_PTR(member); + if (bf_seen && (type->bit_size > long_ctype.bit_size)) + return 0; return 1; case SYM_UNION: // FIXME: should be like struct but has problem diff --git a/validation/mem2reg/init-local32.c b/validation/mem2reg/init-local32.c index c988bb6e7..9a65c2058 100644 --- a/validation/mem2reg/init-local32.c +++ b/validation/mem2reg/init-local32.c @@ -21,8 +21,6 @@ double sdouble(void) /* * check-name: init-local32 * check-command: test-linearize -Wno-decl -m32 -fdump-ir=mem2reg $file - * check-known-to-fail - * * check-output-ignore * check-output-excludes: load\\. * check-output-excludes: store\\.