From patchwork Mon Oct 14 10:35:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1176166 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-510901-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YxNfYA1D"; 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 46sFMK6Q3Zz9sPd for ; Mon, 14 Oct 2019 21:35: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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=LEgDC2tpK/2uFYSDc04FzFiizcUJeAePwP3LkoHmOizkT/zyrMsKy VkKI26IBZsBsnnRX4eLyiFbJRHuOyVS23VFjrRKcnNKBunzonZH3ulNr+S/1Uxur 7r/IiMtgpukufHFbn4xpYGZOd+GL3oxbvjkhXitCM58HnxLPZVYHkE= 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=ghf++cRis6lo+bmthUYnjsFj7wk=; b=YxNfYA1DZqRW7pbHJ2Eb Kj6SRSlQT3m3Lz2P+I1v5OKa4RNgYmywuIlxIkeQJbWgeGnsKXX387ag8wQu71K+ uWW4pVzXHVDzQMsRhhbBDjlY0BBrAJZB1Z7Twb99j4+FOd/l782ygkhbsvTLVpVD MVsFaPFYR34tV4y498i5Me0= Received: (qmail 85283 invoked by alias); 14 Oct 2019 10:35:33 -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 85274 invoked by uid 89); 14 Oct 2019 10:35:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.1 spammy=REFERENCE X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Oct 2019 10:35:30 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3BCEFB6DB for ; Mon, 14 Oct 2019 10:35:28 +0000 (UTC) Date: Mon, 14 Oct 2019 12:35:28 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR91929 Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 The following tries to improve debug info for PRE inserted expressions by assigning them locations from any of the original expressions involved. For simple cases where there exists a 1:1 match this is "correct" while for more complex cases (like code-hoisting) this will pick the location of any of the hoisted equivalent expressions. An improvement to the current state where we pick up unrelated locations from surrounding stmts, sometimes missing complete inline chains on backtraces. Bootstrapped on x86_64-unknown-linux-gnu. Anybody think this is a bad idea? The result should be similar to inserting all participating exprs and then DCEing all but one minus missing the debug stmts generated by that. Thanks, Richard. 2019-10-14 Richard Biener PR tree-optimization/91929 * tree-ssa-pre.c (pre_expr_d::loc): New member. (get_or_alloc_expr_for_name): Initialize it. (get_or_alloc_expr_for_constant): Likewise. (phi_translate_1): Copy it. (create_expression_by_pieces): Use the original location of the expression for the inserted stmt. (compute_avail): Record the location of the stmt for the expressions created. Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 276760) +++ gcc/tree-ssa-pre.c (working copy) @@ -257,6 +257,7 @@ typedef struct pre_expr_d : nofree_ptr_h { enum pre_expr_kind kind; unsigned int id; + location_t loc; pre_expr_union u; /* hash_table support. */ @@ -421,6 +422,7 @@ get_or_alloc_expr_for_name (tree name) result = pre_expr_pool.allocate (); result->kind = NAME; + result->loc = UNKNOWN_LOCATION; PRE_EXPR_NAME (result) = name; alloc_expression_id (result); return result; @@ -1077,6 +1079,7 @@ get_or_alloc_expr_for_constant (tree con newexpr = pre_expr_pool.allocate (); newexpr->kind = CONSTANT; + newexpr->loc = UNKNOWN_LOCATION; PRE_EXPR_CONSTANT (newexpr) = constant; alloc_expression_id (newexpr); value_id = get_or_alloc_constant_value_id (constant); @@ -1334,6 +1337,7 @@ phi_translate_1 (bitmap_set_t dest, { basic_block pred = e->src; basic_block phiblock = e->dest; + location_t expr_loc = expr->loc; switch (expr->kind) { case NARY: @@ -1436,6 +1440,7 @@ phi_translate_1 (bitmap_set_t dest, expr = pre_expr_pool.allocate (); expr->kind = NARY; expr->id = 0; + expr->loc = expr_loc; if (nary && !nary->predicated_values) { PRE_EXPR_NARY (expr) = nary; @@ -1587,6 +1592,7 @@ phi_translate_1 (bitmap_set_t dest, expr = pre_expr_pool.allocate (); expr->kind = REFERENCE; expr->id = 0; + expr->loc = expr_loc; if (newref) new_val_id = newref->value_id; @@ -2789,6 +2795,7 @@ create_expression_by_pieces (basic_block args.quick_push (arg); } gcall *call = gimple_build_call_vec (fn, args); + gimple_set_location (call, expr->loc); gimple_call_set_fntype (call, currop->type); if (sc) gimple_call_set_chain (call, sc); @@ -2822,6 +2829,7 @@ create_expression_by_pieces (basic_block return NULL_TREE; name = make_temp_ssa_name (exprtype, NULL, "pretmp"); newstmt = gimple_build_assign (name, folded); + gimple_set_location (newstmt, expr->loc); gimple_seq_add_stmt_without_update (&forced_stmts, newstmt); gimple_set_vuse (newstmt, BB_LIVE_VOP_ON_EXIT (block)); folded = name; @@ -2860,6 +2868,7 @@ create_expression_by_pieces (basic_block folded = build_constructor (nary->type, elts); name = make_temp_ssa_name (exprtype, NULL, "pretmp"); newstmt = gimple_build_assign (name, folded); + gimple_set_location (newstmt, expr->loc); gimple_seq_add_stmt_without_update (&forced_stmts, newstmt); folded = name; } @@ -2868,16 +2877,17 @@ create_expression_by_pieces (basic_block switch (nary->length) { case 1: - folded = gimple_build (&forced_stmts, nary->opcode, nary->type, - genop[0]); + folded = gimple_build (&forced_stmts, expr->loc, + nary->opcode, nary->type, genop[0]); break; case 2: - folded = gimple_build (&forced_stmts, nary->opcode, nary->type, - genop[0], genop[1]); + folded = gimple_build (&forced_stmts, expr->loc, nary->opcode, + nary->type, genop[0], genop[1]); break; case 3: - folded = gimple_build (&forced_stmts, nary->opcode, nary->type, - genop[0], genop[1], genop[2]); + folded = gimple_build (&forced_stmts, expr->loc, nary->opcode, + nary->type, genop[0], genop[1], + genop[2]); break; default: gcc_unreachable (); @@ -3856,6 +3866,7 @@ compute_avail (void) result = pre_expr_pool.allocate (); result->kind = REFERENCE; result->id = 0; + result->loc = gimple_location (stmt); PRE_EXPR_REFERENCE (result) = ref; get_or_alloc_expression_id (result); @@ -3896,6 +3907,7 @@ compute_avail (void) result = pre_expr_pool.allocate (); result->kind = NARY; result->id = 0; + result->loc = gimple_location (stmt); PRE_EXPR_NARY (result) = nary; break; } @@ -4013,6 +4025,7 @@ compute_avail (void) result = pre_expr_pool.allocate (); result->kind = REFERENCE; result->id = 0; + result->loc = gimple_location (stmt); PRE_EXPR_REFERENCE (result) = ref; break; }