From patchwork Tue Jul 8 00:30:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 367770 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 C3E2E1400AA for ; Tue, 8 Jul 2014 10:30:54 +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=A/zvGnqU3GdzkHO3ndHqPPdh+sk3HMEJbTXlEHuju2Qyghc5rifjD KWMR2evFVSxEeMJ+fZApAiJB7OVrXJOA03PpsyUG2qinFv93zIpBtoufbWSQGmde 6EUmeAKuYEzibdn6hARSbe9l9RVQR4IxRjBJo1MO9mgYBi11mAC3zw= 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=PCOnKF3/CO4hR43Lc5xxags280Y=; b=x2vCXVM67u9Akp6UHRxj RtqLzH6H595pXLsF7kqD1zlgarCAtP2sGczG+W/YaxvauEXdxmoRx/KdQOI78+Kx g5EKbfFxHIjiUn0YMlD+kQY8lweJMhJ57sfqA4fD9sZgZyT1zP4svgXc3ASO12MP S5ZoB5YTYR7OceEHN6Oo0p4= Received: (qmail 21014 invoked by alias); 8 Jul 2014 00:30:48 -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 21005 invoked by uid 89); 8 Jul 2014 00:30:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz 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-GCM-SHA384 encrypted) ESMTPS; Tue, 08 Jul 2014 00:30:44 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 5F9CE542B7A; Tue, 8 Jul 2014 02:30:41 +0200 (CEST) Date: Tue, 8 Jul 2014 02:30:41 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Proper fix for PR58477 Message-ID: <20140708003041.GF12716@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, I had to revert change to ipa-prop.c that made stmt_may_be_vtbl_ptr_store to know that clobbers can not be such stores. This triggered byg in detect_type_change_from_memory_writes. This function does two things. First is that it tries to prove that vtbl pointer was not modified in the function body. Second it tries to prove that the modification is a known type. For this it needs to find proper vtbl store along every path to the call. This is not what happens because it only checks that all vtbl stores it found are of the same type. The object may come pre-initialized to the function. The bug on stopping of clobbers sort of fixed the issue, because we consider only object in declarations and those are constructed in a dominating block, but it works by accident. This is patch we discussed back then adding interface to walk_aliased_vdefs declaring whether entry of function was reached and avoids stmt_may_be_vtbl_ptr_store to jump into conclussion about the dynamic type in that case. Bootstrapped/regtested x86_64-linux, OK? Honza * tree-ssa-alias.c (walk_aliased_vdefs_1): Add FUNCTION_ENTRY_REACHED parameter. (walk_aliased_vdefs): Likewise. * tree-ssa-alias.h (walk_aliased_vdefs): Likewise. * ipa-prop.c (stmt_may_be_vtbl_ptr_store): Skip clobbers (detect_type_change_from_memory_writes): Check if entry was reached. Index: tree-ssa-alias.c =================================================================== --- tree-ssa-alias.c (revision 212339) +++ tree-ssa-alias.c (working copy) @@ -2643,6 +2643,9 @@ walk_non_aliased_vuses (ao_ref *ref, tre WALKER is called with REF, the current vdef and DATA. If WALKER returns true the walk is stopped, otherwise it continues. + If function entry is reached, FUNCTION_ENTRY_REACHED is set to true. + The pointer may be NULL and then we do not track this information. + At PHI nodes walk_aliased_vdefs forks into one walk for reach PHI argument (but only one walk continues on merge points), the return value is true if any of the walks was successful. @@ -2652,8 +2655,11 @@ walk_non_aliased_vuses (ao_ref *ref, tre static unsigned int walk_aliased_vdefs_1 (ao_ref *ref, tree vdef, bool (*walker)(ao_ref *, tree, void *), void *data, - bitmap *visited, unsigned int cnt) + bitmap *visited, unsigned int cnt, + bool *function_entry_reached) { + if (function_entry_reached) + *function_entry_reached = false; do { gimple def_stmt = SSA_NAME_DEF_STMT (vdef); @@ -2663,7 +2669,11 @@ walk_aliased_vdefs_1 (ao_ref *ref, tree return cnt; if (gimple_nop_p (def_stmt)) - return cnt; + { + if (function_entry_reached) + *function_entry_reached = true; + return cnt; + } else if (gimple_code (def_stmt) == GIMPLE_PHI) { unsigned i; @@ -2671,7 +2681,8 @@ walk_aliased_vdefs_1 (ao_ref *ref, tree *visited = BITMAP_ALLOC (NULL); for (i = 0; i < gimple_phi_num_args (def_stmt); ++i) cnt += walk_aliased_vdefs_1 (ref, gimple_phi_arg_def (def_stmt, i), - walker, data, visited, 0); + walker, data, visited, 0, + function_entry_reached); return cnt; } @@ -2690,7 +2701,8 @@ walk_aliased_vdefs_1 (ao_ref *ref, tree unsigned int walk_aliased_vdefs (ao_ref *ref, tree vdef, bool (*walker)(ao_ref *, tree, void *), void *data, - bitmap *visited) + bitmap *visited, + bool *function_entry_reached) { bitmap local_visited = NULL; unsigned int ret; @@ -2698,7 +2710,8 @@ walk_aliased_vdefs (ao_ref *ref, tree vd timevar_push (TV_ALIAS_STMT_WALK); ret = walk_aliased_vdefs_1 (ref, vdef, walker, data, - visited ? visited : &local_visited, 0); + visited ? visited : &local_visited, 0, + function_entry_reached); if (local_visited) BITMAP_FREE (local_visited); Index: tree-ssa-alias.h =================================================================== --- tree-ssa-alias.h (revision 212339) +++ tree-ssa-alias.h (working copy) @@ -123,7 +123,8 @@ extern void *walk_non_aliased_vuses (ao_ void *); extern unsigned int walk_aliased_vdefs (ao_ref *, tree, bool (*)(ao_ref *, tree, void *), - void *, bitmap *); + void *, bitmap *, + bool *function_entry_reached = NULL); extern void dump_alias_info (FILE *); extern void debug_alias_info (void); extern void dump_points_to_solution (FILE *, struct pt_solution *); Index: ipa-prop.c =================================================================== --- ipa-prop.c (revision 212339) +++ ipa-prop.c (working copy) @@ -638,7 +638,8 @@ stmt_may_be_vtbl_ptr_store (gimple stmt) { if (is_gimple_call (stmt)) return false; - /* TODO: Skip clobbers, doing so triggers problem in PR60306. */ + if (gimple_clobber_p (stmt)) + return false; else if (is_gimple_assign (stmt)) { tree lhs = gimple_assign_lhs (stmt); @@ -817,6 +818,7 @@ detect_type_change_from_memory_writes (t { struct type_change_info tci; ao_ref ao; + bool entry_reached = false; gcc_checking_assert (DECL_P (arg) || TREE_CODE (arg) == MEM_REF @@ -847,13 +849,16 @@ detect_type_change_from_memory_writes (t tci.multiple_types_encountered = false; walk_aliased_vdefs (&ao, gimple_vuse (call), check_stmt_for_type_change, - &tci, NULL); + &tci, NULL, &entry_reached); if (!tci.type_maybe_changed) return false; if (!tci.known_current_type || tci.multiple_types_encountered - || offset != 0) + || offset != 0 + /* When the walk reached function entry, it means that type + is set along some paths but not along others. */ + || entry_reached) jfunc->type = IPA_JF_UNKNOWN; else ipa_set_jf_known_type (jfunc, 0, tci.known_current_type, comp_type);