From patchwork Thu Oct 12 20:51:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 825081 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-464082-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gUXevcrV"; 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 3yCjgy2Rtwz9sNV for ; Fri, 13 Oct 2017 07:51:40 +1100 (AEDT) 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=AGiGPw2Mtx9G040f nirN9ts+WJP1N0hZjRYwR1eDg0K6lqf4iryIzal5ngPvEyg7aOH9nbEb/aejbdSZ +vi1FonnjjPIwaS1ynLtlU1fH9rLPookeLcltpZUq/65xRiMFyrAl8v7GWvUPYVQ xqRr3nRm8R1b1GjvnePX/oxqZkk= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=6RYPJQvvRjgJ7ScNeDTpOr 1yYSo=; b=gUXevcrVAy2iIO+2OfDsNeX6e/wd8pxzjHH6V1ALi1f/NIwXdu5ueY nyYQGFs3QH4lC2qKiDKaj0kC/lohVygJRZ2YQ4QM0uDd/uEMcplruQfd4I5yHbfK HL3l7K26LsppJ9CZRj7rs8pUZva+f5pg08QMd6apysH66g8052CqU= Received: (qmail 86928 invoked by alias); 12 Oct 2017 20:51:29 -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 85885 invoked by uid 89); 12 Oct 2017 20:51:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=corner, efficiently X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Oct 2017 20:51:27 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9DC70822CE for ; Thu, 12 Oct 2017 22:51:24 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CFDMxHtHaUDQ for ; Thu, 12 Oct 2017 22:51:24 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 5F9BD8220F for ; Thu, 12 Oct 2017 22:51:24 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix PR debug/82509 Date: Thu, 12 Oct 2017 22:51:23 +0200 Message-ID: <14641386.x2jigZTk3C@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Hi, this PR reports a couple of problems with the support of the DW_AT_endianity attribute associated with the scalar_storage_order source attribute: it does not persist through typedefs and it can contaminate native order DIEs. The attached patch revamps it by associating native order DIEs and reverse order DIEs into adjacent pairs for base types, as well as looking through typedefs for base types with reverse order. This makes it possible to have a single reverse order DIE for each base type and look it up efficiently. Tested on x86_64-suse-linux, OK for the mainline? What about the 7 branch? 2017-10-12 Eric Botcazou PR debug/82509 * dwarf2out.c (base_type_die): Remove early return for corner cases. Allocate the new DIE manually and do not call add_pubtype on it. (is_base_type): Remove ERROR_MARK and return 0 for VOID_TYPE. (modified_type_die): Adjust the lookup for reverse order DIEs. Skip typedefs for base types with DW_AT_endianity. Make sure a DIE with native order exists for base types, attach the DIE manually and call add_pubtype on it. Do not equate a reverse order DIE to the type. 2017-10-12 Eric Botcazou * gcc.dg/debug/dwarf2/sso.c: Rename into... * gcc.dg/debug/dwarf2/sso-1.c: ...this. * gcc.dg/debug/dwarf2/sso-2.c: New test. * gcc.dg/debug/dwarf2/sso-3.c: Likewise. Index: dwarf2out.c =================================================================== --- dwarf2out.c (revision 253628) +++ dwarf2out.c (working copy) @@ -12090,9 +12090,6 @@ base_type_die (tree type, bool reverse) struct fixed_point_type_info fpt_info; tree type_bias = NULL_TREE; - if (TREE_CODE (type) == ERROR_MARK || TREE_CODE (type) == VOID_TYPE) - return 0; - /* If this is a subtype that should not be emitted as a subrange type, use the base type. See subrange_type_for_debug_p. */ if (TREE_CODE (type) == INTEGER_TYPE && TREE_TYPE (type) != NULL_TREE) @@ -12185,7 +12182,8 @@ base_type_die (tree type, bool reverse) gcc_unreachable (); } - base_type_result = new_die (DW_TAG_base_type, comp_unit_die (), type); + base_type_result = ggc_cleared_alloc (); + base_type_result->die_tag = DW_TAG_base_type; add_AT_unsigned (base_type_result, DW_AT_byte_size, int_size_in_bytes (type)); @@ -12241,8 +12239,6 @@ base_type_die (tree type, bool reverse) | dw_scalar_form_reference, NULL); - add_pubtype (type, base_type_result); - return base_type_result; } @@ -12270,8 +12266,6 @@ is_base_type (tree type) { switch (TREE_CODE (type)) { - case ERROR_MARK: - case VOID_TYPE: case INTEGER_TYPE: case REAL_TYPE: case FIXED_POINT_TYPE: @@ -12280,6 +12274,7 @@ is_base_type (tree type) case POINTER_BOUNDS_TYPE: return 1; + case VOID_TYPE: case ARRAY_TYPE: case RECORD_TYPE: case UNION_TYPE: @@ -12485,6 +12480,8 @@ modified_type_die (tree type, int cv_qua /* Only these cv-qualifiers are currently handled. */ const int cv_qual_mask = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC); + const bool reverse_base_type + = need_endianity_attribute_p (reverse) && is_base_type (type); if (code == ERROR_MARK) return NULL; @@ -12535,29 +12532,33 @@ modified_type_die (tree type, int cv_qua qualified_type = size_type_node; } - /* If we do, then we can just use its DIE, if it exists. */ if (qualified_type) { mod_type_die = lookup_type_die (qualified_type); - /* DW_AT_endianity doesn't come from a qualifier on the type. */ + /* DW_AT_endianity doesn't come from a qualifier on the type, so it is + dealt with specially: the DIE with the attribute, if it exists, is + placed immediately after the regular DIE for the same base type. */ if (mod_type_die - && (!need_endianity_attribute_p (reverse) - || !is_base_type (type) - || get_AT_unsigned (mod_type_die, DW_AT_endianity))) + && (!reverse_base_type + || ((mod_type_die = mod_type_die->die_sib) != NULL + && get_AT_unsigned (mod_type_die, DW_AT_endianity)))) return mod_type_die; } name = qualified_type ? TYPE_NAME (qualified_type) : NULL; /* Handle C typedef types. */ - if (name && TREE_CODE (name) == TYPE_DECL && DECL_ORIGINAL_TYPE (name) + if (name + && TREE_CODE (name) == TYPE_DECL + && DECL_ORIGINAL_TYPE (name) && !DECL_ARTIFICIAL (name)) { tree dtype = TREE_TYPE (name); - if (qualified_type == dtype) + /* Skip the typedef for base types with DW_AT_endianity, no big deal. */ + if (qualified_type == dtype && !reverse_base_type) { tree origin = decl_ultimate_origin (name); @@ -12729,7 +12730,21 @@ modified_type_die (tree type, int cv_qua item_type = TREE_TYPE (type); } else if (is_base_type (type)) - mod_type_die = base_type_die (type, reverse); + { + mod_type_die = base_type_die (type, reverse); + + /* The DIE with DW_AT_endianity is placed right after the naked DIE. */ + if (reverse_base_type) + { + dw_die_ref after_die + = modified_type_die (type, cv_quals, false, context_die); + add_child_die_after (comp_unit_die (), mod_type_die, after_die); + } + else + add_child_die (comp_unit_die (), mod_type_die); + + add_pubtype (type, mod_type_die); + } else { gen_type_die (type, context_die); @@ -12791,7 +12806,7 @@ modified_type_die (tree type, int cv_qua name ? IDENTIFIER_POINTER (name) : "__unknown__"); } - if (qualified_type) + if (qualified_type && !reverse_base_type) equate_type_number_to_die (qualified_type, mod_type_die); if (item_type)