From patchwork Wed Aug 21 17:29:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1151006 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-507463-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YGwAFeKT"; 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 46DF8v02JLz9s3Z for ; Thu, 22 Aug 2019 03:32:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :resent-from:resent-date:resent-message-id:resent-to:message-id :from:date:subject:to:cc; q=dns; s=default; b=u9JX6BhIsc4pbheVWw LYXUIOeYDnuwRCBl/HtWdZFe2Dg0q9tu4YSiSq93Iw0uYscKIWcwgyv0J8AfjLby +LeQsz8FStAeHP5n54nJvRU+SKh0dgKzADLQACf7bbcd3Bio9iLnfiohUqQW5kCz qcQeL6AFrxArr+tr7PqR/4x2k= 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 :resent-from:resent-date:resent-message-id:resent-to:message-id :from:date:subject:to:cc; s=default; bh=jMXPf5zVTmsOHqx/4qFLbwqD Neo=; b=YGwAFeKTkrCkNbeUkaIsQncV1Pv+8NF5UDlfpEJmzCeRyn83uifZUQaM n19C4e3/Zv8BOK+pwPfTiXIe64L19w19FxD4VKsmfC1+Q51CnsUQuwFG4zBt0VCk KSCeK+ez3AYfoPGZvN0SoSRk4ZjBognhbD2U4hhNO5vdZcQsi14= Received: (qmail 110359 invoked by alias); 21 Aug 2019 17:32:03 -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 110343 invoked by uid 89); 21 Aug 2019 17:32:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.1 required=5.0 tests=AWL, BAYES_00, KAM_SHORT, SPF_PASS autolearn=ham version=3.3.1 spammy=connected, noipa, sk:cgraph_, UD:cgraph.c 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; Wed, 21 Aug 2019 17:32:01 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 11DB5AF47 for ; Wed, 21 Aug 2019 17:31:59 +0000 (UTC) Resent-From: Martin Jambor Resent-Date: Wed, 21 Aug 2019 19:31:58 +0200 Resent-Message-ID: <20190821173158.GA28216@virgil.suse.cz> Resent-To: gcc-patches@gcc.gnu.org Message-Id: From: Martin Jambor Date: Wed, 21 Aug 2019 19:29:46 +0200 Subject: [PATCH 0/4] True IPA reimplementation of IPA-SRA (v4) To: GCC Patches Cc: Jan Hubicka , Jan Hubicka X-IsSubscribed: yes Hello, I have fixed two bugs of the previous IPA-SRA submission and re-based it on a recent trunk and am posting it again so that people can have look at an up-to-date version (and also as a reminder that it is still pending review). Previous submissions are available at: - https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01529.html and - https://gcc.gnu.org/ml/gcc-patches/2019-05/msg00472.html This reimplementation is a full IPA pass that can handle strictly connected components in the call-graph, can take advantage of LTO and does not weirdly switch functions in pass-pipeline like our current quasi-IPA SRA does. Unlike the current IPA-SRA it can also remove return values, even in SCCs. On the other hand, it is less powerful when it comes to structures passed by reference. By design it will not create references to bits of an aggregate because that turned out to be just obfuscation in practice. However, it also cannot usually split aggregates passed by reference that are just passed to another function (where splitting would be useful) because it cannot perform the same TBAA analysis like the current implementation which already knows what types it should look at because it has access to bodies of all functions attempts to modify (for an example see https://gcc.gnu.org/ml/gcc-patches/2019-05/msg00955.html). Since May I have switched the order of IPA-CP and IPA-SRA, so that IPA-CP is run before IPA-SRA and it can propagate constants in aggregates before these are split and tracking is lost. The July submission frequently cloned even if all the parameter removal work has already been done by IPA-CP, this version does not have that problem. Like before, there are dbgcounters. This submission has https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01567.html incorporated. The patch has successfully bootstrapped and LTO-profilebootstrapped and tested on x86_64-linux. Testing on x86_64 fixes 24 LTO tests in guality/pr68860-1.c but regresses 13 guality tests, 3 of which are not LTO. I plan to bootstrap on ppc64le and aarch64 like I did before submitting the previous version. Right after my last submission, Martin Liška used a version which contained both aforementioned fixes (but of course not the re-base) to build over 5000 openSUSE packages (vast majority of them with LTO). After the patches are approved, I would like to commit them in one big commit but in order to ease review, I have split the big patch into four patches: 1. Removal of old IPA-SRA, 2. New parameter manipulation infrastructure, 3. New IPA-SRA implementation, and 4. Modifications to the testsuite. When applied one after another they should compile but I have only exhaustively tested the complete patch. If you want to experiment with new IPA-SRA or the parameter manipulation infrastructure it introduces, I suggest that you clone the jamborm/ipa-sra branch from our git "mirror" (https://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/jamborm/ipa-sra). Thanks in advance for any questions, comments and suggestions, Martin 2019-08-20 Martin Jambor * coretypes.h (cgraph_edge): Declare. * ipa-param-manipulation.c: Rewrite. * ipa-param-manipulation.h: Likewise. * Makefile.in (GTFILES): Added ipa-param-manipulation.h and ipa-sra.c. (OBJS): Added ipa-sra.o. * cgraph.h (ipa_replace_map): Removed fields old_tree, replace_p and ref_p, added fields param_adjustments and performed_splits. (struct cgraph_clone_info): Remove ags_to_skip and combined_args_to_skip, new field param_adjustments. (cgraph_node::create_clone): Changed parameters to use ipa_param_adjustments. (cgraph_node::create_virtual_clone): Likewise. (cgraph_node::create_virtual_clone_with_body): Likewise. (tree_function_versioning): Likewise. (cgraph_build_function_type_skip_args): Removed. * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Convert to using ipa_param_adjustments. (clone_of_p): Likewise. * cgraphclones.c (cgraph_build_function_type_skip_args): Removed. (build_function_decl_skip_args): Likewise. (duplicate_thunk_for_node): Adjust parameters using ipa_param_body_adjustments, copy param_adjustments instead of args_to_skip. (cgraph_node::create_clone): Convert to using ipa_param_adjustments. (cgraph_node::create_virtual_clone): Likewise. (cgraph_node::create_version_clone_with_body): Likewise. (cgraph_materialize_clone): Likewise. (symbol_table::materialize_all_clones): Likewise. * ipa-fnsummary.c (ipa_fn_summary_t::duplicate): Simplify ipa_replace_map check. * ipa-cp.c (get_replacement_map): Do not initialize removed fields. (initialize_node_lattices): Make aware that some parameters might have already been removed. (want_remove_some_param_p): New function. (create_specialized_node): Convert to using ipa_param_adjustments and deal with possibly pre-existing adjustments. * lto-cgraph.c (output_cgraph_opt_summary_p): Likewise. (output_node_opt_summary): Do not stream removed fields. Stream parameter adjustments instead of argumetns to skip. (input_node_opt_summary): Likewise. (input_node_opt_summary): Likewise. * lto-section-in.c (lto_section_name): Added ipa-sra section. * lto-streamer.h (lto_section_type): Likewise. * tree-inline.h (copy_body_data): New fields killed_new_ssa_names and param_body_adjs. (copy_decl_to_var): Declare. * tree-inline.c (update_clone_info): Do not remap old_tree. (remap_gimple_stmt): Use ipa_param_body_adjustments to modify gimple statements, walk all extra generated statements and remap their operands. (redirect_all_calls): Add killed SSA names to a hash set. (remap_ssa_name): Do not remap killed SSA names. (copy_arguments_for_versioning): Renames to copy_arguments_nochange, half of functionality moved to ipa_param_body_adjustments. (copy_decl_to_var): Make exported. (copy_body): Destroy killed_new_ssa_names hash set. (expand_call_inline): Remap performed splits. (update_clone_info): Likewise. (tree_function_versioning): Simplify tree_map processing. Updated to accept ipa_param_adjustments and use ipa_param_body_adjustments. * omp-simd-clone.c (simd_clone_vector_of_formal_parm_types): Adjust for the new interface. (simd_clone_clauses_extract): Likewise, make args an auto_vec. (simd_clone_compute_base_data_type): Likewise. (simd_clone_init_simd_arrays): Adjust for the new interface. (simd_clone_adjust_argument_types): Likewise. (struct modify_stmt_info): Likewise. (ipa_simd_modify_stmt_ops): Likewise. (ipa_simd_modify_function_body): Likewise. (simd_clone_adjust): Likewise. * tree-sra.c: Removed IPA-SRA. Include tree-sra.h. (type_internals_preclude_sra_p): Make public. * tree-sra.h: New file. * ipa-inline-transform.c (save_inline_function_body): Update to refelct new tree_function_versioning signature. * ipa-prop.c (adjust_agg_replacement_values): Use a helper from ipa_param_adjustments to get current parameter indices. (ipcp_modif_dom_walker::before_dom_children): Likewise. (ipcp_update_bits): Likewise. (ipcp_update_vr): Likewise. * ipa-split.c (split_function): Convert to using ipa_param_adjustments. * ipa-sra.c: New file. * multiple_target.c (create_target_clone): Update to reflet new type of create_version_clone_with_body. * trans-mem.c (ipa_tm_create_version): Update to reflect new type of tree_function_versioning. (modify_function): Update to reflect new type of tree_function_versioning. * params.def (PARAM_IPA_SRA_MAX_REPLACEMENTS): New. * passes.def: Remove old IPA-SRA and add new one. * tree-pass.h (make_pass_early_ipa_sra): Remove declaration. (make_pass_ipa_sra): Declare. * dbgcnt.def: Remove eipa_sra. Added ipa_sra_params and ipa_sra_retvalues. * doc/invoke.texi (ipa-sra-max-replacements): New. testsuite/ * g++.dg/ipa/pr81248.C: Adjust dg-options and dump-scan. * gcc.dg/ipa/ipa-sra-1.c: Likewise. * gcc.dg/ipa/ipa-sra-10.c: Likewise. * gcc.dg/ipa/ipa-sra-11.c: Likewise. * gcc.dg/ipa/ipa-sra-3.c: Likewise. * gcc.dg/ipa/ipa-sra-4.c: Likewise. * gcc.dg/ipa/ipa-sra-5.c: Likewise. * gcc.dg/ipa/ipacost-2.c: Disable ipa-sra. * gcc.dg/ipa/ipcp-agg-9.c: Likewise. * gcc.dg/ipa/pr78121.c: Adjust scan pattern. * gcc.dg/ipa/vrp1.c: Likewise. * gcc.dg/ipa/vrp2.c: Likewise. * gcc.dg/ipa/vrp3.c: Likewise. * gcc.dg/ipa/vrp7.c: Likewise. * gcc.dg/ipa/vrp8.c: Likewise. * gcc.dg/noreorder.c: use noipa attribute instead of noinline. * gcc.dg/ipa/20040703-wpa.c: New test. * gcc.dg/ipa/ipa-sra-12.c: New test. * gcc.dg/ipa/ipa-sra-13.c: Likewise. * gcc.dg/ipa/ipa-sra-14.c: Likewise. * gcc.dg/ipa/ipa-sra-15.c: Likewise. * gcc.dg/ipa/ipa-sra-16.c: Likewise. * gcc.dg/ipa/ipa-sra-17.c: Likewise. * gcc.dg/ipa/ipa-sra-18.c: Likewise. * gcc.dg/ipa/ipa-sra-19.c: Likewise. * gcc.dg/ipa/ipa-sra-20.c: Likewise. * gcc.dg/ipa/ipa-sra-21.c: Likewise. * gcc.dg/ipa/ipa-sra-22.c: Likewise. * gcc.dg/sso/ipa-sra-1.c: Likewise. * g++.dg/ipa/ipa-sra-2.C: Likewise. * g++.dg/ipa/ipa-sra-3.C: Likewise. * gcc.dg/tree-ssa/ipa-cp-1.c: Make return value used. * g++.dg/ipa/devirt-19.C: Add missing return, add -fipa-cp-clone option. * g++.dg/lto/devirt-19_0.C: Add -fipa-cp-clone option. * gcc.dg/ipa/ipa-sra-2.c: Mark to be removed. * gcc.dg/ipa/ipa-sra-6.c: Likewise.