From patchwork Mon Jun 24 16:32:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1121436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503612-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="b7f8y5xX"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45XZZl5lCHz9s3l for ; Tue, 25 Jun 2019 02:32:31 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=s4BrlaIQotcrshIQJlDPPvu7I2p0zx9ANxgak0tkzAP0G2Idxl va1zVdjlkfqQ1aZeJaesm+kHphbjNyAZmZ+Xqn6ZKzNah2U/Zh0iutCPUVUllZvb Hq842prSTnOZfg1tmHzNk+QBszSoqJLjpXhfS7f/fOk6CqlHpkOgBCdbc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=VJbWKBbuaHcY+KAzjjxXX0gRd+s=; b=b7f8y5xXR7w1aDEzQDZs XTX8VbwjPZ6cJE/soMwFMQ5JFFex7x3YIsatUnnRYtpJebI5aRmLIL0nk6b3wmGV xfa2eeCvAgF/+ftZP3kjCX10yHIVb+PmYhVcki092rji6TyFoEhhvcYYoGfTUkc9 Ar7GVIC4cqmxvxcQqUw4/18= Received: (qmail 127664 invoked by alias); 24 Jun 2019 16:32:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 127656 invoked by uid 89); 24 Jun 2019 16:32:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=H*UA:https X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Jun 2019 16:32:23 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1E23FAE5E; Mon, 24 Jun 2019 16:32:21 +0000 (UTC) From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Martin Liska , Prathamesh Kulkarni Subject: [PR 90939] Remove outdated assert in ipcp_bits_lattice::meet_with User-Agent: Notmuch/0.29 (https://notmuchmail.org) Emacs/26.2 (x86_64-suse-linux-gnu) Date: Mon, 24 Jun 2019 18:32:20 +0200 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, in August 2016 Prathamesh implemented inter-procedural propagation of known non-zero bits on integers. In August that same year he then also added the ability to track it for pointer, replacing separate alignment tracking. However, we still have an assert in ipcp_bits_lattice::meet_with from the first commit that checks that any binary operation coming from an arithmetic jump function is performed on integers. Martin discovered that when you compile chromium and stars are aligned correctly, you can end up evaluating a pointer expression MAX_EXPR (param, 0) there which trips the assert. Unless Prathamesh can remember a reason why the assert is important, I believe the correct thing is just to remove it. In the case of this MAX_EXPR, it will end up being evaluated in bit_value_binop which cannot handle it and so we will end up with a BOTTOM lattice in the end. In the general case, bit_value_binop operates on widest_ints and so shoud have no problem dealing with pointers. I'm bootstrapping and testing the following patch to satisfy the rules but since it only removes an assert and adds a testcase that I checked, I do not expect any problems. Is it OK for trunk, GCC 9 and 8? Thanks, Martin 2019-06-24 Martin Jambor PR ipa/90939 * ipa-cp.c (ipcp_bits_lattice::meet_with): Remove assert. testsuite/ * g++.dg/lto/pr90939_[01].C: New test. --- gcc/ipa-cp.c | 1 - gcc/testsuite/g++.dg/lto/pr90939_0.C | 64 ++++++++++++++++++++++++++++ gcc/testsuite/g++.dg/lto/pr90939_1.C | 45 +++++++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/lto/pr90939_0.C create mode 100644 gcc/testsuite/g++.dg/lto/pr90939_1.C diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index d3a88756a91..69c00a9c5a5 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1085,7 +1085,6 @@ ipcp_bits_lattice::meet_with (ipcp_bits_lattice& other, unsigned precision, if (TREE_CODE_CLASS (code) == tcc_binary) { tree type = TREE_TYPE (operand); - gcc_assert (INTEGRAL_TYPE_P (type)); widest_int o_value, o_mask; get_value_and_mask (operand, &o_value, &o_mask); diff --git a/gcc/testsuite/g++.dg/lto/pr90939_0.C b/gcc/testsuite/g++.dg/lto/pr90939_0.C new file mode 100644 index 00000000000..8987c348015 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr90939_0.C @@ -0,0 +1,64 @@ +// PR ipa/90939 +// { dg-lto-do link } +// { dg-lto-options { { -flto -O3 } } } + + +typedef char uint8_t; +template class A { +public: + A(T *); +}; +template const Derived &To(Base &p1) { + return static_cast(p1); +} +class H; +template const H *To(Base *p1) { + return p1 ? &To(*p1) : nullptr; +} +enum TextDirection : uint8_t; +enum WritingMode : unsigned; +class B { +public: + WritingMode m_fn1(); +}; +class C { +public: + int &m_fn2(); +}; +class D { double d;}; +class H : public D {}; +class F { +public: + F(C, A, B *, WritingMode, TextDirection); +}; + +class G { +public: + C NGLayoutAlgorithm_node; + B NGLayoutAlgorithm_space; + TextDirection NGLayoutAlgorithm_direction; + H NGLayoutAlgorithm_break_token; + G(A p1) __attribute__((noinline)) + : break_token_(&NGLayoutAlgorithm_break_token), + container_builder_(NGLayoutAlgorithm_node, p1, &NGLayoutAlgorithm_space, + NGLayoutAlgorithm_space.m_fn1(), + NGLayoutAlgorithm_direction) {} + G(C p1, const H *) : G(&p1.m_fn2()) {} + A break_token_; + F container_builder_; +}; + +class I : G { +public: + I(const D *) __attribute__((noinline)); +}; +C a; +I::I(const D *p1) : G(a, To(p1)) {} + +D gd[10]; + +int main (int argc, char *argv[]) +{ + I i(&(gd[argc%2])); + return 0; +} diff --git a/gcc/testsuite/g++.dg/lto/pr90939_1.C b/gcc/testsuite/g++.dg/lto/pr90939_1.C new file mode 100644 index 00000000000..9add89494d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr90939_1.C @@ -0,0 +1,45 @@ +typedef char uint8_t; +template class A { +public: + A(T *); +}; + +enum TextDirection : uint8_t; +enum WritingMode : unsigned; +class B { +public: + WritingMode m_fn1(); +}; +class C { +public: + int &m_fn2(); +}; + +class F { +public: + F(C, A, B *, WritingMode, TextDirection); +}; +class D { double d;}; +class H : public D {}; + + + +template A::A(T*) {} + +template class A; +template class A; + +WritingMode __attribute__((noipa)) +B::m_fn1() +{ + return (WritingMode) 0; +} + +int gi; +int & __attribute__((noipa)) +C::m_fn2 () +{ + return gi; +} + +__attribute__((noipa)) F::F(C, A, B *, WritingMode, TextDirection) {}