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\\.