From patchwork Fri Sep 6 10:20:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 273136 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 98BE42C00F2 for ; Fri, 6 Sep 2013 20:20:51 +1000 (EST) 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=Ueu2aymKqcJ/x+UIzbRI8Ks8uaz6nadw7YGLQPI3YtCEMq3aHd4Vx Q6sRaE424AQHZO5658G5VSeOViM65nXccCuHs03nVkXQpizT/+G5jSFLB0aNv0xB J9PF3Hh04IEXotWkqJuvDzSTQY7u+tfGo96EGktwgZUNkaQMcGaQSM= 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=4/u0ar6EBHo1l7vI0Kn2gJE2TlM=; b=GZzMreD4dvt65DZf0YR2 aLTRa8ixrC/fSTEv3xyLamvTf+Nt7erNvBujmz+v7BPsBbG3GVALDfSMFu4Pv9Cj I3nDsb5NH7scSREhaBWbZFu9q4a+3SKA3iahYQ8V4qQ7GumO568r9BHO4Qg+mlvO wif46sRsKJtWJ+v93gJwm6o= Received: (qmail 27543 invoked by alias); 6 Sep 2013 10:20:35 -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 27455 invoked by uid 89); 6 Sep 2013 10:20:34 -0000 Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 06 Sep 2013 10:20:34 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, NO_RELAYS autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 24E64543BB8; Fri, 6 Sep 2013 12:20:30 +0200 (CEST) Date: Fri, 6 Sep 2013 12:20:30 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix ipa-devirt-11.C on AIX part 2 Message-ID: <20130906102029.GB12994@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Hi, this patch makes tree-sra to do its job in the case where function has an alias. There were two problems; first recursion is not detected correctly and second we did not see the callers and thus skipped the function. Rest of tree-sra seems to work as expected. Bootstrapped/regtsted x86_64-linux, comitted. Honza * Makefile.in (tree-sra.o): Update dependencies. * tree-sra.c: Include ipa-utils.h (scan_function): Use recursive_call_p. (has_caller_p): New function. (cgraph_for_node_and_aliases): Count also callers of aliases. Index: Makefile.in =================================================================== --- Makefile.in (revision 202316) +++ Makefile.in (working copy) @@ -3104,7 +3104,7 @@ tree-sra.o : tree-sra.c $(CONFIG_H) $(SY $(HASH_TABLE_H) $(TM_H) $(TREE_H) $(GIMPLE_H) $(CGRAPH_H) $(TREE_FLOW_H) \ $(IPA_PROP_H) $(DIAGNOSTIC_H) statistics.h \ $(PARAMS_H) $(TARGET_H) $(FLAGS_H) \ - $(DBGCNT_H) $(TREE_INLINE_H) $(GIMPLE_PRETTY_PRINT_H) + $(DBGCNT_H) $(TREE_INLINE_H) $(GIMPLE_PRETTY_PRINT_H) ipa-utils.h tree-switch-conversion.o : tree-switch-conversion.c $(CONFIG_H) $(SYSTEM_H) \ $(TREE_H) $(TM_P_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) $(TREE_INLINE_H) \ $(TM_H) coretypes.h $(GIMPLE_H) $(CFGLOOP_H) \ Index: tree-sra.c =================================================================== --- tree-sra.c (revision 202315) +++ tree-sra.c (working copy) @@ -91,6 +91,7 @@ along with GCC; see the file COPYING3. #include "tree-inline.h" #include "gimple-pretty-print.h" #include "ipa-inline.h" +#include "ipa-utils.h" /* Enumeration of all aggregate reductions we can do. */ enum sra_mode { SRA_MODE_EARLY_IPA, /* early call regularization */ @@ -1256,8 +1257,7 @@ scan_function (void) if (DECL_BUILT_IN_CLASS (dest) == BUILT_IN_NORMAL && DECL_FUNCTION_CODE (dest) == BUILT_IN_APPLY_ARGS) encountered_apply_args = true; - if (cgraph_get_node (dest) - == cgraph_get_node (current_function_decl)) + if (recursive_call_p (current_function_decl, dest)) { encountered_recursive_call = true; if (!callsite_has_enough_arguments_p (stmt)) @@ -4906,6 +4906,16 @@ modify_function (struct cgraph_node *nod return cfg_changed; } +/* If NODE has a caller, return true. */ + +static bool +has_caller_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) +{ + if (node->callers) + return true; + return false; +} + /* Return false the function is apparently unsuitable for IPA-SRA based on it's attributes, return true otherwise. NODE is the cgraph node of the current function. */ @@ -4949,7 +4959,7 @@ ipa_sra_preliminary_function_checks (str return false; } - if (!node->callers) + if (!cgraph_for_node_and_aliases (node, has_caller_p, NULL, true)) { if (dump_file) fprintf (dump_file,