From patchwork Mon Nov 8 17:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1552467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=FeJz6cFh; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=8qfSuu8X; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HnzJr6m46z9sCD for ; Tue, 9 Nov 2021 04:54:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6C643858428 for ; Mon, 8 Nov 2021 17:54:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 735D83858404 for ; Mon, 8 Nov 2021 17:54:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 735D83858404 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5F099218BB for ; Mon, 8 Nov 2021 17:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1636394057; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=sje1Wov7A4XR3Gqymlmy2a2/Nah85yFf7ds6AwsaYBs=; b=FeJz6cFhbtaI+Iw5RGVWvBdCcb/DkMafcqBsvyMrLvmsU+fBGsIVcjbuftqsiZsPbqref0 iDuRlWtzwsY9MxUe1wGmnT2bs/WpDjhcSLL/rRF433MV85EjYmuR7lFlUNET8mbZxqxcbw vPzlvmVRWP0IeN2DuoxIqYJHRR+ydG0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1636394057; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=sje1Wov7A4XR3Gqymlmy2a2/Nah85yFf7ds6AwsaYBs=; b=8qfSuu8XT84GuR0Yq1FEe20y52aJc7C9yG9/4ZrDwZ+bXxS/HXWw804RTt/vhQ28Tuhma0 jeQ79GAE+GzFgBCg== Received: from suse.cz (virgil.suse.cz [10.100.13.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 4BEFEA3B85; Mon, 8 Nov 2021 17:54:17 +0000 (UTC) From: Martin Jambor To: GCC Patches Subject: [PATCH] Introduce build_debug_expr_decl User-Agent: Notmuch/0.33.2 (https://notmuchmail.org) Emacs/27.2 (x86_64-suse-linux-gnu) Date: Mon, 08 Nov 2021 18:54:17 +0100 Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Biener Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch introduces a helper function build_debug_expr_decl to build DEBUG_EXPR_DECL tree nodes in the most common way and replaces with a call of this function all code pieces which build such a DECL itself and sets its mode to the TYPE_MODE of its type. There still remain 11 instances of open-coded creation of a DEBUG_EXPR_DECL which set the mode of the DECL to something else. It would probably be a good idea to figure out that has any effect and if not, convert them to calls of build_debug_expr_decl too. But this patch deliberately does not introduce any functional changes. Bootstrapped and tested on x86_64-linux, OK for trunk? Thanks, Martin gcc/ChangeLog: 2021-11-08 Martin Jambor * tree.h (build_debug_expr_decl): Declare. * tree.c (build_debug_expr_decl): New function. * cfgexpand.c (avoid_deep_ter_for_debug): Use build_debug_expr_decl instead of building a DEBUG_EXPR_DECL. * ipa-param-manipulation.c (ipa_param_body_adjustments::prepare_debug_expressions): Likewise. * omp-simd-clone.c (ipa_simd_modify_stmt_ops): Likewise. * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Likewise. * tree-ssa-phiopt.c (spaceship_replacement): Likewise. * tree-ssa-reassoc.c (make_new_ssa_for_def): Likewise. --- gcc/cfgexpand.c | 5 +---- gcc/ipa-param-manipulation.c | 5 +---- gcc/omp-simd-clone.c | 5 +---- gcc/tree-ssa-ccp.c | 5 +---- gcc/tree-ssa-phiopt.c | 10 ++-------- gcc/tree-ssa-reassoc.c | 5 +---- gcc/tree.c | 12 ++++++++++++ gcc/tree.h | 1 + 8 files changed, 20 insertions(+), 28 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 01d0cdc548a..55ff75bd78e 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -4341,11 +4341,8 @@ avoid_deep_ter_for_debug (gimple *stmt, int depth) tree &vexpr = deep_ter_debug_map->get_or_insert (use); if (vexpr != NULL) continue; - vexpr = make_node (DEBUG_EXPR_DECL); + vexpr = build_debug_expr_decl (TREE_TYPE (use)); gimple *def_temp = gimple_build_debug_bind (vexpr, use, g); - DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (use); - SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (use))); gimple_stmt_iterator gsi = gsi_for_stmt (g); gsi_insert_after (&gsi, def_temp, GSI_NEW_STMT); avoid_deep_ter_for_debug (def_temp, 0); diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c index 4610fc4ac03..ae3149718ca 100644 --- a/gcc/ipa-param-manipulation.c +++ b/gcc/ipa-param-manipulation.c @@ -1200,10 +1200,7 @@ ipa_param_body_adjustments::prepare_debug_expressions (tree dead_ssa) = unshare_expr_without_location (gimple_assign_rhs_to_tree (def)); remap_with_debug_expressions (&val); - tree vexpr = make_node (DEBUG_EXPR_DECL); - DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (val); - SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (val))); + tree vexpr = build_debug_expr_decl (TREE_TYPE (val)); m_dead_stmt_debug_equiv.put (def, val); m_dead_ssa_debug_equiv.put (dead_ssa, vexpr); return true; diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index b772b7ff520..4d43a86669a 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -910,11 +910,8 @@ ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data) gimple *stmt; if (is_gimple_debug (info->stmt)) { - tree vexpr = make_node (DEBUG_EXPR_DECL); + tree vexpr = build_debug_expr_decl (TREE_TYPE (repl)); stmt = gimple_build_debug_source_bind (vexpr, repl, NULL); - DECL_ARTIFICIAL (vexpr) = 1; - TREE_TYPE (vexpr) = TREE_TYPE (repl); - SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (repl))); repl = vexpr; } else diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 70ce6a4d5b8..60ae5e6601f 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -3452,10 +3452,7 @@ optimize_atomic_bit_test_and (gimple_stmt_iterator *gsip, tree temp = NULL_TREE; if (!throws || after || single_pred_p (e->dest)) { - temp = make_node (DEBUG_EXPR_DECL); - DECL_ARTIFICIAL (temp) = 1; - TREE_TYPE (temp) = TREE_TYPE (lhs); - SET_DECL_MODE (temp, TYPE_MODE (TREE_TYPE (lhs))); + temp = build_debug_expr_decl (TREE_TYPE (lhs)); tree t = build2 (LSHIFT_EXPR, TREE_TYPE (lhs), new_lhs, bit); g = gimple_build_debug_bind (temp, t, g); if (throws && !after) diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 0e339c46afa..173ac835ca6 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -2429,19 +2429,13 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb, all floating point numbers should be comparable. */ gimple_stmt_iterator gsi = gsi_after_labels (gimple_bb (phi)); tree type = TREE_TYPE (phires); - tree temp1 = make_node (DEBUG_EXPR_DECL); - DECL_ARTIFICIAL (temp1) = 1; - TREE_TYPE (temp1) = type; - SET_DECL_MODE (temp1, TYPE_MODE (type)); + tree temp1 = build_debug_expr_decl (type); tree t = build2 (one_cmp, boolean_type_node, lhs1, rhs2); t = build3 (COND_EXPR, type, t, build_one_cst (type), build_int_cst (type, -1)); gimple *g = gimple_build_debug_bind (temp1, t, phi); gsi_insert_before (&gsi, g, GSI_SAME_STMT); - tree temp2 = make_node (DEBUG_EXPR_DECL); - DECL_ARTIFICIAL (temp2) = 1; - TREE_TYPE (temp2) = type; - SET_DECL_MODE (temp2, TYPE_MODE (type)); + tree temp2 = build_debug_expr_decl (type); t = build2 (EQ_EXPR, boolean_type_node, lhs1, rhs2); t = build3 (COND_EXPR, type, t, build_zero_cst (type), temp1); g = gimple_build_debug_bind (temp2, t, phi); diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index db9fb4e1cac..6a555e7c553 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1259,15 +1259,12 @@ make_new_ssa_for_def (gimple *stmt, enum tree_code opcode, tree op) { if (new_debug_lhs == NULL_TREE) { - new_debug_lhs = make_node (DEBUG_EXPR_DECL); + new_debug_lhs = build_debug_expr_decl (TREE_TYPE (lhs)); gdebug *def_temp = gimple_build_debug_bind (new_debug_lhs, build2 (opcode, TREE_TYPE (lhs), new_lhs, op), stmt); - DECL_ARTIFICIAL (new_debug_lhs) = 1; - TREE_TYPE (new_debug_lhs) = TREE_TYPE (lhs); - SET_DECL_MODE (new_debug_lhs, TYPE_MODE (TREE_TYPE (lhs))); gimple_set_uid (def_temp, gimple_uid (stmt)); gimple_stmt_iterator gsi = gsi_for_stmt (stmt); gsi_insert_after (&gsi, def_temp, GSI_SAME_STMT); diff --git a/gcc/tree.c b/gcc/tree.c index 7bfd64160f4..845228a055b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -5280,6 +5280,18 @@ build_decl (location_t loc, enum tree_code code, tree name, return t; } +/* Create and return a DEBUG_EXPR_DECL node of the given TYPE. */ + +tree +build_debug_expr_decl (tree type) +{ + tree vexpr = make_node (DEBUG_EXPR_DECL); + DECL_ARTIFICIAL (vexpr) = 1; + TREE_TYPE (vexpr) = type; + SET_DECL_MODE (vexpr, TYPE_MODE (type)); + return vexpr; +} + /* Builds and returns function declaration with NAME and TYPE. */ tree diff --git a/gcc/tree.h b/gcc/tree.h index 7542d97ce12..f62c00bc870 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4567,6 +4567,7 @@ extern tree build_tree_list (tree, tree CXX_MEM_STAT_INFO); extern tree build_tree_list_vec (const vec * CXX_MEM_STAT_INFO); extern tree build_decl (location_t, enum tree_code, tree, tree CXX_MEM_STAT_INFO); +extern tree build_debug_expr_decl (tree type); extern tree build_fn_decl (const char *, tree); extern tree build_translation_unit_decl (tree); extern tree build_block (tree, tree, tree, tree);