From patchwork Thu Apr 10 21:04:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teresa Johnson X-Patchwork-Id: 338284 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 CB41C14007A for ; Fri, 11 Apr 2014 07:04:49 +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 :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=nBfOEJEL1xQ9OXY8gudXRkDm+gipxwB8HyaQ2zUT9NESs0 sErfw7w/k+dUrC3lf/v+zqdGd2Q3/tScW24tkLHBMnf0NoBnHtt96giOZdZOGcy/ NrsZ+NXJMsQJjiui+4vHiPxhnMreGrpvEl6g26TOYrpqF+rWWv3COyxTD69As= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=/PbT8byncUU0AIXyHgMryEsrV7k=; b=oaPto4tSPizL62EEn4AC r4xQ80vhPFBD7s70mSRG75p1IN+fcQvYgwJZNb7av0sm9Ms06xtU+Qr6tLNxpDiE OEhWHDNcoo5bqJBuq+Y9kOdvXXa6dI7k628TBTEitNlB5D3APDM2QyZmE4W6yGiw djLyx9Qt4zHvdTkuN+J58A4= Received: (qmail 9888 invoked by alias); 10 Apr 2014 21:04:42 -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 9876 invoked by uid 89); 10 Apr 2014 21:04:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qa0-f52.google.com Received: from mail-qa0-f52.google.com (HELO mail-qa0-f52.google.com) (209.85.216.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 10 Apr 2014 21:04:40 +0000 Received: by mail-qa0-f52.google.com with SMTP id s7so2416416qap.25 for ; Thu, 10 Apr 2014 14:04:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=MfwoQb7d2yeeuiJmHMX1cfXaZ66fm5D383q2qdf502k=; b=fs3YuOA3/xbUX+Gqtj0N4/9DEYWCmPbZQBHpQAjxKdbmEWgfY2JmE8PllzE120LHyw 6lylcWNcj55/XF4Zx5yMXGZxmbpvvhye8A0eMeHp9Lwj/ydIG1GbHdWVP9Jk9aPGCGJf +xWbV9154B+Pb4fStWkIzihgb8ZkCEehqKQgFNmvFTbtPPMuh+31druHwvyYk+20FRP6 HFKYhVlxej4xzNN/jrSZAnfp74ID/cK5Eh8vbBLf+AMEGWhDozCwCUPd58PgsWOFU21M xEiRe6aF/9TC13lVO14Zf9SfhyWS48Yu102pjxm5JAq12GQ4h+dM+cBmTNx3D8iZyDU3 qebQ== X-Gm-Message-State: ALoCoQljR7k5RR2HUv5Jb4GSYNGIZjAk6i8V4dDSTzYnq/f6qJF/4NnRqnwemJMEgpGf5omKMprlqDHFhO31pO/TKS1iraaNoBRomhKoTp9J9Kp0dYoaupLbI7as1Xa1sPRE3IndImGBhewFbOW0d6r635IIaOXX2SW0oSf+8eG1rDUa2ALrGhB7Di3X+yuksvm0lgWKav/5fngY1i+kuCHUixIVJEn8Hw== MIME-Version: 1.0 X-Received: by 10.140.84.134 with SMTP id l6mr22736618qgd.96.1397163877888; Thu, 10 Apr 2014 14:04:37 -0700 (PDT) Received: by 10.229.167.129 with HTTP; Thu, 10 Apr 2014 14:04:37 -0700 (PDT) Date: Thu, 10 Apr 2014 14:04:37 -0700 Message-ID: Subject: [GOOGLE] Fix incorrect detection of recursive calls during LIPO IPA inlining From: Teresa Johnson To: "gcc-patches@gcc.gnu.org" , David Li , Rong Xu X-IsSubscribed: yes This patch fixes an issue where self-recursive calls were missed during ipa inlining in LIPO compiles, since the resolved nodes were not checked. When a self-recursive call was inlined incorrectly, ipa_inline redirected the edge to the resolved node, leading to a cycle in the cgraph that wasn't expected and resulted in an infinite loop in estimate_calls_size_and_time. Also fix an inconsistency in the declaration of include_all_aux that was exposed when l-ipo.h was included in cgraph. Google ref b/13912450. Bootstrapped and tested. Ok for google/4_8? Thanks, Teresa 2014-04-10 Teresa Johnson * cgraph.h (cgraph_edge_recursive_p): Check the resolved node in LIPO compiles. * l-ipo.h (include_all_aux): Fix declaration that didn't match definition. * Makefile.in (CGRAPH_H): Include l-ipo.h. Index: cgraph.h =================================================================== --- cgraph.h (revision 209280) +++ cgraph.h (working copy) @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "basic-block.h" #include "function.h" #include "ipa-ref.h" +#include "l-ipo.h" /* Symbol table consists of functions and variables. TODO: add labels, constant pool and aliases. */ @@ -1388,10 +1389,15 @@ static inline bool cgraph_edge_recursive_p (struct cgraph_edge *e) { struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL); + struct cgraph_node *caller = e->caller; if (e->caller->global.inlined_to) - return e->caller->global.inlined_to->symbol.decl == callee->symbol.decl; - else - return e->caller->symbol.decl == callee->symbol.decl; + caller = e->caller->global.inlined_to; + if (L_IPO_COMP_MODE && cgraph_pre_profiling_inlining_done) + { + callee = cgraph_lipo_get_resolved_node (callee->symbol.decl); + caller = cgraph_lipo_get_resolved_node (caller->symbol.decl); + } + return (caller->symbol.decl == callee->symbol.decl); } /* Return true if the TM_CLONE bit is set for a given FNDECL. */ Index: l-ipo.h =================================================================== --- l-ipo.h (revision 209280) +++ l-ipo.h (working copy) @@ -44,7 +44,7 @@ extern unsigned primary_module_id; /* Current module id. */ extern unsigned current_module_id; -extern unsigned include_all_aux; +extern bool include_all_aux; extern struct gcov_module_info **module_infos; extern int is_last_module (unsigned mod_id); Index: Makefile.in =================================================================== --- Makefile.in (revision 209280) +++ Makefile.in (working copy) @@ -904,7 +904,8 @@ CFGLOOP_H = cfgloop.h $(BASIC_BLOCK_H) double-int. IPA_UTILS_H = ipa-utils.h $(TREE_H) $(CGRAPH_H) IPA_REFERENCE_H = ipa-reference.h $(BITMAP_H) $(TREE_H) CGRAPH_H = cgraph.h $(VEC_H) $(TREE_H) $(BASIC_BLOCK_H) $(FUNCTION_H) \ - cif-code.def ipa-ref.h ipa-ref-inline.h $(LINKER_PLUGIN_API_H) is-a.h + cif-code.def ipa-ref.h ipa-ref-inline.h $(LINKER_PLUGIN_API_H) is-a.h \ + l-ipo.h DF_H = df.h $(BITMAP_H) $(REGSET_H) sbitmap.h $(BASIC_BLOCK_H) \ alloc-pool.h $(TIMEVAR_H) VALTRACK_H = valtrack.h $(BITMAP_H) $(DF_H) $(RTL_H) $(BASIC_BLOCK_H) \