From patchwork Mon Jul 1 09:32:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1125159 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-504044-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz 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 45chwx5LQFz9s4V for ; Mon, 1 Jul 2019 19:32:27 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=PgKsEP6MiA0zIpTzjf7/I3q1oQTNbz5RH8nUg69KqwdmFDZ2OzGiE pSv/6LdhmmqYTL/r21pam3dmihbvE1CiCqnYF6qJ1501iEp/aLQFAZiOzGcOcepo VQw1vXvajl1rnC+7jnmwtVyNAu2X7//t1sedoHC3U9owaPcLMT0gEc= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=uwLzXKoSn4/Z6MjJHIoco79e69w=; b=WzXDZKblsEfjrsHHXpno 4x3Ou6CagYgDcjo7JvX75rhcuCqwlBOSaQl6ImKrjXu8Ucvc/WFqAxdjfgPPPDdo P2YzunvRd8J1iXl+p2FZA1J+BfLpgoh0Y2moL1IcPSSndRw2MRXQs6OzRLf99dDh JqEf9xkpVhH2T0fxUv4yj+g= Received: (qmail 29722 invoked by alias); 1 Jul 2019 09:32:20 -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 29712 invoked by uid 89); 1 Jul 2019 09:32:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=H*Ad:U*jason, HTo:U*jason, nonexistent, nostdlib X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 Jul 2019 09:32:18 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 2D38D2825B3; Mon, 1 Jul 2019 11:32:16 +0200 (CEST) Date: Mon, 1 Jul 2019 11:32:16 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, marxin@suse.cz, rguenther@suse.de, jason@redhat.com Subject: Fix verifier ICE on CLOBBER of COMPONENT_REF Message-ID: <20190701093216.spartrylpbbyun5v@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, the testcase makes inliner to substitute RESULT_DECL by COMPONENT_REF inside CLOBBER statement. This is not allowed and leads to ICE in verifier (while I think we should fix code to support this). This patch simply makes inliner to watch for this case and do not remap the statement at all. The testcase works for 32bit only which is bit unfortunate. For 64bit build NRV does not happen, i did not look into why. OK? Honza * tree-inline.c (remap_gimple_stmt): Do not subtitute handled components to clobber of return value. * g++.dg/lto/pr90990_0.C: New testcase. Index: tree-inline.c =================================================================== --- tree-inline.c (revision 272846) +++ tree-inline.c (working copy) @@ -1757,6 +1757,18 @@ remap_gimple_stmt (gimple *stmt, copy_bo return NULL; } } + + /* We do not allow CLOBBERs of handled components. In case + returned value is stored via such handled component, remove + the clobber so stmt verifier is happy. */ + if (gimple_clobber_p (stmt) + && TREE_CODE (gimple_assign_lhs (stmt)) == RESULT_DECL) + { + tree remapped = remap_decl (gimple_assign_lhs (stmt), id); + if (!DECL_P (remapped) + && TREE_CODE (remapped) != MEM_REF) + return NULL; + } if (gimple_debug_bind_p (stmt)) { Index: testsuite/g++.dg/lto/pr90990_0.C =================================================================== --- testsuite/g++.dg/lto/pr90990_0.C (nonexistent) +++ testsuite/g++.dg/lto/pr90990_0.C (working copy) @@ -0,0 +1,31 @@ +// { dg-lto-do link } +/* { dg-extra-ld-options { -r -nostdlib } } */ +class A { +public: + float m_floats; + A() {} +}; +class B { +public: + A operator[](int); +}; +class C { + B m_basis; + +public: + A operator()(A) { + m_basis[1] = m_basis[2]; + A a; + return a; + } +}; +class D { +public: + C m_fn1(); +}; +class F { + A m_pivotInB; + F(D &, const A &); +}; +F::F(D &p1, const A &p2) : m_pivotInB(p1.m_fn1()(p2)) {} +