From patchwork Tue Mar 11 19:00:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 329205 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 3145F2C00C2 for ; Wed, 12 Mar 2014 06:02:06 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=tlzqkAml3OkD 3F/TbGEFPB+4m0UFRLeMaRFRhegkF8XS9Olf6Iw0zci31wz8cSsDxVjoRaQ5j/K9 EjvPiFPoVr8JTuRwpkH8uQmYQcI/TYZW0Kk0xKB5ryIq8URNq1Mgq9GMHbxfZK1N geHqPtdM4wMmfMamCTAv4LPq90QgyfY= 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:from :to:cc:subject:date:message-id; s=default; bh=bpzHacQNvv2qDTu6ve r46cTIecM=; b=Cdb0h2GmkNtMGz1TXrd0o23ZGnhnCkTSs6NvNCY/bvGTFp/0Dt 99CyTv+sc0Fmq100LyQlfZNZI+M0nbH3tlpjFrO0yDpn0n0x3NXvYAmX4CrtaWJ2 liYlyEBfkckuSVzv/6uRMlUkvH6YCryGGCYZJf4075MuTB59ooMsYqjNI= Received: (qmail 7426 invoked by alias); 11 Mar 2014 19:01:57 -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 7395 invoked by uid 89); 11 Mar 2014 19:01:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Mar 2014 19:01:52 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2BJ1fu7009221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Mar 2014 15:01:42 -0400 Received: from surprise.redhat.com (vpn-239-202.phx2.redhat.com [10.3.239.202]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2BJ1eJK006773; Tue, 11 Mar 2014 15:01:40 -0400 From: David Malcolm To: jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [jit] Fix state issue in gcse.c Date: Tue, 11 Mar 2014 15:00:03 -0400 Message-Id: <1394564403-6617-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes Committed to branch dmalcolm/jit: Turning optimizations up from 0 to 3 showed a segfault on the 2nd iteration of test-linked-list.c in get_data_from_adhoc_loc whilst garbage-collecting. Investigation revealed the issue to be a CFG from the previous compile being kept alive by this GC root in gcse.c: static GTY(()) rtx test_insn; This wouldn't it itself be an issue, but one (or more) of the edges had: (gdb) p /x e->goto_locus $9 = 0x80000000 and was thus treated as an ADHOC_LOC. Hence, this line in the edge_def's gt_ggc_mx routine: 8313 tree block = LOCATION_BLOCK (e->goto_locus); led to a call (via LOCATION_BLOCK) to get_data_from_adhoc_loc: 152 void * 153 get_data_from_adhoc_loc (struct line_maps *set, source_location loc) 154 { 155 linemap_assert (IS_ADHOC_LOC (loc)); 156 return set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].data; 157 } but at this point, the ad-hoc location data from the previous in-process compile no longer makes sense, and, with: (gdb) p set->location_adhoc_data_map $5 = {htab = 0x60fbb0, curr_loc = 0, allocated = 0, data = 0x0} the read though the NULL "data" segfaults. gcse.c appears to create test_insn on-demand as part of the implementation of can_assign_to_reg_without_clobbers_p. Hence it seems to make most sense to simply clear test_insn in toplev_finalize, which this commit does. With this, the whole test suite now runs successfully with optimizations on, so also turn this up (in harness.h) from 0 to 3. gcc/ * gcse.c (gcse_c_finalize): New, to clear test_insn between in-process compiles. * gcse.h (gcse_c_finalize): New. * toplev.c: Include "gcse.h" so that we can... (toplev_finalize): Call gcse_c_finalize. gcc/testsuite/ * jit.dg/harness.h (set_options): Increase optimization level from 0 to 3. --- gcc/ChangeLog.jit | 8 ++++++++ gcc/gcse.c | 5 +++++ gcc/gcse.h | 2 ++ gcc/testsuite/ChangeLog.jit | 5 +++++ gcc/testsuite/jit.dg/harness.h | 2 +- gcc/toplev.c | 2 ++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog.jit b/gcc/ChangeLog.jit index 5c14fcc..77ac44c 100644 --- a/gcc/ChangeLog.jit +++ b/gcc/ChangeLog.jit @@ -1,5 +1,13 @@ 2014-03-11 David Malcolm + * gcse.c (gcse_c_finalize): New, to clear test_insn between + in-process compiles. + * gcse.h (gcse_c_finalize): New. + * toplev.c: Include "gcse.h" so that we can... + (toplev_finalize): Call gcse_c_finalize. + +2014-03-11 David Malcolm + * dwarf2out.c (dwarf2out_c_finalize): Release base_types. 2014-03-10 David Malcolm diff --git a/gcc/gcse.c b/gcc/gcse.c index bb9ba15..f2409ec 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -4226,4 +4226,9 @@ make_pass_rtl_hoist (gcc::context *ctxt) return new pass_rtl_hoist (ctxt); } +void gcse_c_finalize (void) +{ + test_insn = NULL; +} + #include "gt-gcse.h" diff --git a/gcc/gcse.h b/gcc/gcse.h index e1dea21..f459be2 100644 --- a/gcc/gcse.h +++ b/gcc/gcse.h @@ -39,4 +39,6 @@ extern struct target_gcse *this_target_gcse; #define this_target_gcse (&default_target_gcse) #endif +void gcse_c_finalize (void); + #endif diff --git a/gcc/testsuite/ChangeLog.jit b/gcc/testsuite/ChangeLog.jit index ec8af3d..5a84bfd 100644 --- a/gcc/testsuite/ChangeLog.jit +++ b/gcc/testsuite/ChangeLog.jit @@ -1,3 +1,8 @@ +2014-03-11 David Malcolm + + * jit.dg/harness.h (set_options): Increase optimization level from + 0 to 3. + 2014-03-07 David Malcolm * jit.dg/test-functions.c (create_test_of_hidden_function): New, diff --git a/gcc/testsuite/jit.dg/harness.h b/gcc/testsuite/jit.dg/harness.h index aa98028..e67ac36 100644 --- a/gcc/testsuite/jit.dg/harness.h +++ b/gcc/testsuite/jit.dg/harness.h @@ -132,7 +132,7 @@ static void set_options (gcc_jit_context *ctxt, const char *argv0) gcc_jit_context_set_int_option ( ctxt, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, - 0); + 3); gcc_jit_context_set_bool_option ( ctxt, GCC_JIT_BOOL_OPTION_DEBUGINFO, diff --git a/gcc/toplev.c b/gcc/toplev.c index 9de1c2d..f1ac560 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -79,6 +79,7 @@ along with GCC; see the file COPYING3. If not see #include "pass_manager.h" #include "dwarf2out.h" #include "ipa-reference.h" +#include "gcse.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -2000,6 +2001,7 @@ void toplev_finalize (void) cgraphbuild_c_finalize (); cgraphunit_c_finalize (); dwarf2out_c_finalize (); + gcse_c_finalize (); ipa_c_finalize (); ipa_reference_c_finalize (); predict_c_finalize ();