From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5065 invoked by alias); 9 Jun 2011 14:53:44 -0000 Received: (qmail 5056 invoked by uid 22791); 9 Jun 2011 14:53:43 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Jun 2011 14:53:25 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p59ErNLl001167 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 9 Jun 2011 10:53:24 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p59ErMYI004753 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 9 Jun 2011 10:53:23 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p59ErMGn027857; Thu, 9 Jun 2011 16:53:22 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p59ErKGr027855; Thu, 9 Jun 2011 16:53:20 +0200 Date: Thu, 09 Jun 2011 15:47:00 -0000 From: Jakub Jelinek To: Richard Henderson , Jason Merrill , Cary Coutant Cc: gcc-patches@gcc.gnu.org, Roland McGrath , Jan Kratochvil , Tom Tromey , Mark Wielaard Subject: Typed DWARF stack and convert to untyped Message-ID: <20110609145319.GO17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20110325113237.GY18914@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110325113237.GY18914@tyan-ft48-01.lab.bos.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-06/txt/msg00740.txt.bz2 Hi! On Fri, Mar 25, 2011 at 12:32:37PM +0100, Jakub Jelinek wrote: > This patch on top of > http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01224.html > and > http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01723.html > implements parts of Cary's typed DWARF stack proposal: > http://www.dwarfstd.org/doc/040408.1.html GCC currently doesn't fully adhere to the above SPEC (even with the agreed on slight changes for some binary ops), in particular to the binary ops operand need to have the same type. Currently once a value on the stack is typed, the typedness propagates forever through unary/binary ops (the only exception are comparisons that push untyped result even for typed operands). I'd like to propose convert to untyped operation, e.g. DW_OP_GNU_convert <0> could do it (and maybe DW_OP_GNU_reinterpret <0>), these would convert to an integral value of the same size as DWARF address and make it untyped. As DW_OP_GNU_convert operand is uleb128 DIE offset within current CU, offset 0 certainly won't contain any DIEs, because it is the first byte of the CU header. Without this, currently GCC will sometimes end up with one operand typed, another untyped. While it is solvable even just on the GCC side (mem_loc_descriptor would need to track whether the TOS of the expression it returned is typed, untyped (or uncertain, e.g. for DW_OP_GNU_parameter_ref), as that would be determined by the matching DW_AT_GNU_call_site_value, and when e.g. for binary operation one argument is determined as typed, the other argument would need to be converted to typed as well if untyped, and any uncertain operand of a binary op or unary that cares about the sign would need to be converted to typed), I think it would generate unnecessarily bloated code, as e.g. after a float is converted to int or other small integer suddenly all further additions etc. would need to convert constants etc. to typed values (or use DW_OP_const_type). With an convert to untyped operation, mem_loc_descriptor could just ensure that for integral modes <= DWARF_ADDR_SIZE the result is untyped (current gcc code sort of assumes that) and only when a larger mode is needed or non-integral, it would be typed, and when sign matters for operation of integral small modes, it could just temporarily convert to typed and back. Does this sound reasonable, or is it too ugly? Jakub