From patchwork Wed Apr 27 08:03:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 615461 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3qvstX0lzpz9t3b for ; Wed, 27 Apr 2016 18:04:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=cblZUtJf; dkim-atps=neutral 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; q=dns; s=default; b=rYkD4ZF5ZFhS mdCNuA0OsD6NPqslMp20okIDoI0kRVbAAJDXvI7kOdy6/wd+v1tI5wct4ByYxx7m 0ZAD3Jna2/VE5XF4HQ3kUlVxsy5OisFIE30GNtgXOJaYGRzdBXbgEwpXV0BYX2fo nf1NxPN7Os4GepGEPuUVVpXxOtlm44o= 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; s=default; bh=aGuTgbAE86BfePL9uZ nDOUALagI=; b=cblZUtJfP4gJqzXaw6+lyemtU2mVyybvOMfJlkotr3Uuz+ESLM dkhHQPwo8h8nWw1Y3Z+Nt26KlK1c5k+MaLuP9sz/CjhY/p0JBs7ZzbrfxSX1rInk PkTFgv1vubbE0rlRONOk/zVfhVNb/TejpQjVe22ORj4vI7RU+2zqcGZr8= Received: (qmail 54621 invoked by alias); 27 Apr 2016 08:04:07 -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 54606 invoked by uid 89); 27 Apr 2016 08:04:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=advance!, Associate, operational, visit 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 27 Apr 2016 08:03:56 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 725BF81308; Wed, 27 Apr 2016 10:03:53 +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 guLLlJAIoE7m; Wed, 27 Apr 2016 10:03:53 +0200 (CEST) Received: from cacatoes.act-europe.fr (cacatoes.act-europe.fr [10.10.1.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 5D173812CB; Wed, 27 Apr 2016 10:03:53 +0200 (CEST) From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Pierre-Marie de Rodat Subject: [PATCH] DWARF: turn dw_loc_descr_node field into hash map for frame offset check Date: Wed, 27 Apr 2016 10:03:45 +0200 Message-Id: <1461744225-25469-1-git-send-email-derodat@adacore.com> X-IsSubscribed: yes Hello, As discussed on , this change removes a field in the dw_loc_descr_node structure so we can get rid of the CHECKING_P macro usage. This field was used to perform consistency checks for frame offset in DWARF procedures. As a replacement, this commit turns the "visited nodes" set in resolve_args_picking_1 into a map that remembers for each dw_loc_descr_node the frame offset associated to it, so that the consistency check is still operational. Boostrapped and regtested on x86_64-linux. Ok to commit? Thank you in advance! --- gcc/dwarf2out.c | 37 +++++++++++++++++++------------------ gcc/dwarf2out.h | 6 ------ 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 0bbff87..463863d 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -1325,9 +1325,6 @@ new_loc_descr (enum dwarf_location_atom op, unsigned HOST_WIDE_INT oprnd1, dw_loc_descr_ref descr = ggc_cleared_alloc (); descr->dw_loc_opc = op; -#if CHECKING_P - descr->dw_loc_frame_offset = -1; -#endif descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const; descr->dw_loc_oprnd1.val_entry = NULL; descr->dw_loc_oprnd1.v.val_unsigned = oprnd1; @@ -15353,12 +15350,14 @@ is_handled_procedure_type (tree type) && int_size_in_bytes (type) <= DWARF2_ADDR_SIZE); } -/* Helper for resolve_args_picking. Stop when coming across VISITED nodes. */ +/* Helper for resolve_args_picking: do the same but stop when coming across + visited nodes. For each node we visit, register in FRAME_OFFSETS the frame + offset *before* evaluating the corresponding operation. */ static bool resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned initial_frame_offset, struct dwarf_procedure_info *dpi, - hash_set &visited) + hash_map &frame_offsets) { /* The "frame_offset" identifier is already used to name a macro... */ unsigned frame_offset_ = initial_frame_offset; @@ -15366,19 +15365,18 @@ resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned initial_frame_offset, for (l = loc; l != NULL;) { + bool existed; + unsigned &l_frame_offset = frame_offsets.get_or_insert (l, &existed); + /* If we already met this node, there is nothing to compute anymore. */ - if (visited.add (l)) + if (existed) { -#if CHECKING_P /* Make sure that the stack size is consistent wherever the execution flow comes from. */ - gcc_assert ((unsigned) l->dw_loc_frame_offset == frame_offset_); -#endif + gcc_assert ((unsigned) l_frame_offset == frame_offset_); break; } -#if CHECKING_P - l->dw_loc_frame_offset = frame_offset_; -#endif + l_frame_offset = frame_offset_; /* If needed, relocate the picking offset with respect to the frame offset. */ @@ -15601,7 +15599,7 @@ resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned initial_frame_offset, { case DW_OP_bra: if (!resolve_args_picking_1 (l->dw_loc_next, frame_offset_, dpi, - visited)) + frame_offsets)) return false; /* Fall through... */ @@ -15623,17 +15621,20 @@ resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned initial_frame_offset, /* Make a DFS over operations reachable through LOC (i.e. follow branch operations) in order to resolve the operand of DW_OP_pick operations that - target DWARF procedure arguments (DPI). Stop at already visited nodes. - INITIAL_FRAME_OFFSET is the frame offset *before* LOC is executed. Return - if all relocations were successful. */ + target DWARF procedure arguments (DPI). INITIAL_FRAME_OFFSET is the frame + offset *before* LOC is executed. Return if all relocations were + successful. */ static bool resolve_args_picking (dw_loc_descr_ref loc, unsigned initial_frame_offset, struct dwarf_procedure_info *dpi) { - hash_set visited; + /* Associate to all visited operations the frame offset *before* evaluating + this operation. */ + hash_map frame_offsets; - return resolve_args_picking_1 (loc, initial_frame_offset, dpi, visited); + return resolve_args_picking_1 (loc, initial_frame_offset, dpi, + frame_offsets); } /* Try to generate a DWARF procedure that computes the same result as FNDECL. diff --git a/gcc/dwarf2out.h b/gcc/dwarf2out.h index 91b3d6b..abf0550 100644 --- a/gcc/dwarf2out.h +++ b/gcc/dwarf2out.h @@ -239,12 +239,6 @@ struct GTY((chain_next ("%h.dw_loc_next"))) dw_loc_descr_node { frame offset. */ unsigned int frame_offset_rel : 1; int dw_loc_addr; -#if CHECKING_P - /* When translating a function into a DWARF procedure, contains the frame - offset *before* evaluating this operation. It is -1 when not yet - initialized. */ - int dw_loc_frame_offset; -#endif dw_val_node dw_loc_oprnd1; dw_val_node dw_loc_oprnd2; };