From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94234 invoked by alias); 31 Aug 2019 06:30:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 94139 invoked by uid 89); 31 Aug 2019 06:30:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=2019-08-31 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 31 Aug 2019 06:30:15 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 05E8D7CBB1; Sat, 31 Aug 2019 06:30:09 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AA85600CC; Sat, 31 Aug 2019 06:30:08 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x7V6U6vY030073; Sat, 31 Aug 2019 08:30:06 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x7V6U3UF030072; Sat, 31 Aug 2019 08:30:03 +0200 Date: Sat, 31 Aug 2019 12:04:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix free_lang_data on asm stmts (PR lto/91572) Message-ID: <20190831063003.GE2120@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg02126.txt.bz2 Hi! The following testcase ICEs, because on the inline asm LTO streaming streams the constraint strings ("g" in this case), including their type, but the fld type discovery doesn't see that type and so we end up streaming const char type turned into its own main variant. The strings for asm are in TREE_PURPOSE of the TREE_LIST args. walk_tree doesn't walk TREE_PURPOSE though. Tried to change that, but it breaks way too much, tried to walk TREE_PURPOSE of TREE_LIST just for the fld walking (find_decls_types_r), but that doesn't work either, most of the TREE_PURPOSE we do not want to walk, usually it contains C++ default arguments which fld clears. So, this directed patch walks the TREE_PURPOSE solely for the asm stmt arguments. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-08-31 Jakub Jelinek PR lto/91572 * tree.c (find_decls_types_in_node): Also walk TREE_PURPOSE of GIMPLE_ASM TREE_LIST operands. * g++.dg/lto/pr91572_0.C: New test. --- gcc/tree.c.jj 2019-08-29 10:22:06.337702323 +0200 +++ gcc/tree.c 2019-08-29 11:07:16.120107950 +0200 @@ -6142,6 +6142,13 @@ find_decls_types_in_node (struct cgraph_ { tree arg = gimple_op (stmt, i); find_decls_types (arg, fld); + /* find_decls_types doesn't walk TREE_PURPOSE of TREE_LISTs, + which we need for asm stmts. */ + if (arg + && TREE_CODE (arg) == TREE_LIST + && TREE_PURPOSE (arg) + && gimple_code (stmt) == GIMPLE_ASM) + find_decls_types (TREE_PURPOSE (arg), fld); } } } --- gcc/testsuite/g++.dg/lto/pr91572_0.C.jj 2019-08-28 18:13:47.718349087 +0200 +++ gcc/testsuite/g++.dg/lto/pr91572_0.C 2019-08-28 18:13:41.695436342 +0200 @@ -0,0 +1,12 @@ +// PR lto/91572 +// { dg-lto-do link } +// { dg-lto-options { { -O -fPIC -flto } } } +// { dg-require-effective-target shared } +// { dg-require-effective-target fpic } +// { dg-extra-ld-options "-shared" } + +void foo (char); +namespace N { + class A { A (); }; + A::A () { asm ("" : : "g" (0)); } +} Jakub