From patchwork Fri Mar 16 23:00:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iyer, Balaji V" X-Patchwork-Id: 147286 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]) by ozlabs.org (Postfix) with SMTP id C84F6B6FA1 for ; Sat, 17 Mar 2012 10:00:43 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332543645; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:Content-Type: MIME-Version:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=agUkKIH OMDT4pERIHMjiwa9hQVE=; b=rucGumwCv7zZH00H+sjpyLLoUwEmT93EJjtUohm d+PvA+2rqPimIXdjdpNoTM+ILHkcFQQB/lYXjKL11XvjvFb0dun2WAX5W9wuryiM sxCJYtzWHbewMQpMwQi0zBzpLU5rDHgq0JZboxQcn9Hq4ujnuKCpGTKO20Qb1AIU prMU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-ExtLoop1:Received:Received:Received:From:To:Subject:Date:Message-ID:Content-Type:MIME-Version:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=juKZ/iLttViNT3HllRzSxEckJ9qEKqAMeOAddr6cKSMrLOm+uCs3bCwhoaVA07 n4tDJ12/b4/ICTsFJERzGlTWHRfEvtMxdaRf2jwTqkB0OnRaBp9/yOLBsLuKN+f8 A6iRdKGKTPxZJcqyYQr8s3n4ZboIelxcc1nwIWDytB4V4=; Received: (qmail 17613 invoked by alias); 16 Mar 2012 23:00:33 -0000 Received: (qmail 17603 invoked by uid 22791); 16 Mar 2012 23:00:32 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Mar 2012 23:00:19 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 16 Mar 2012 16:00:18 -0700 X-ExtLoop1: 1 Received: from azsmsx601.amr.corp.intel.com ([10.2.121.193]) by AZSMGA002.ch.intel.com with ESMTP; 16 Mar 2012 16:00:18 -0700 Received: from fmsmsx106.amr.corp.intel.com (10.19.9.37) by azsmsx601.amr.corp.intel.com (10.2.121.193) with Microsoft SMTP Server (TLS) id 8.2.255.0; Fri, 16 Mar 2012 16:00:17 -0700 Received: from fmsmsx102.amr.corp.intel.com ([169.254.2.186]) by FMSMSX106.amr.corp.intel.com ([169.254.6.155]) with mapi id 14.01.0355.002; Fri, 16 Mar 2012 16:00:17 -0700 From: "Iyer, Balaji V" To: "gcc-patches@gcc.gnu.org" Subject: [PATCH][Cilkplus] Patch to fix spawn bug in templates Date: Fri, 16 Mar 2012 23:00:17 +0000 Message-ID: MIME-Version: 1.0 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 Hello Everyone, This patch is for the Cilkplus branch, mainly affecting the C++ compiler. This patch will fix a bug when spawn is used inside template functions. Thanks, Balaji V. Iyer. diff --git a/gcc/ChangeLog.cilk b/gcc/ChangeLog.cilk index 3667c75..f1935d2 100644 --- a/gcc/ChangeLog.cilk +++ b/gcc/ChangeLog.cilk @@ -1,3 +1,13 @@ +2012-03-16 Balaji V. Iyer + + * cilk-spawn.c (cilk_valid_spawn): Unwrapped the call_expr from expr + and cleanup point statements. + (gimplify_cilk_spawn): Likewise. + * function.c (allocate_struct_function): Initialized calls_spawns + correctly. + * tree.h: Removed cilk_hyper_flag and replaced with cilk_has_spawn. + Also added DECL_HAS_SPAWN_P and removed DECL_HYPER_LOOKUP_P. + 2012-03-12 Balaji V. Iyer * c-typeck.c (convert_arguments): Added array notation check for diff --git a/gcc/cilk-spawn.c b/gcc/cilk-spawn.c index 3ba1051..3a29250 100644 --- a/gcc/cilk-spawn.c +++ b/gcc/cilk-spawn.c @@ -295,6 +295,10 @@ cilk_valid_spawn (tree exp0) if (exp == NULL_TREE) return false; /* happens with C++ TARGET_EXPR */ + while (TREE_CODE (exp) == CLEANUP_POINT_EXPR + || TREE_CODE (exp) == EXPR_STMT) + exp = TREE_OPERAND (exp, 0); + /* Now we have a call, or this isn't a valid spawn. */ /* XXX This will reject any outer non-spawn AGGR_INIT_EXPR that is valid because of a spawn inside. Are there any @@ -394,7 +398,11 @@ gimplify_cilk_spawn (tree *spawn_p, gimple_seq *before ATTRIBUTE_UNUSED, *spawn_p = build_empty_stmt (UNKNOWN_LOCATION); return; } - + /* Remove cleanup point expr and expr stmt from *spawn_p */ + while (TREE_CODE (expr) == CLEANUP_POINT_EXPR + || TREE_CODE (expr) == EXPR_STMT) + expr = TREE_OPERAND (expr, 0); + new_args = NULL; function = build_cilk_wrapper (expr, &new_args); diff --git a/gcc/cp/ChangeLog.cilk b/gcc/cp/ChangeLog.cilk index 28bd0e1..0970089 100644 --- a/gcc/cp/ChangeLog.cilk +++ b/gcc/cp/ChangeLog.cilk @@ -1,3 +1,11 @@ +2012-03-16 Balaji V. Iyer + + * decl.c (finish_function_body): called DECL_HAS_SPAWN_P and set it to + calls_spawns. + * pt.c (tsubst_copy): Carried the spawn call information from one + call expression to another. + (tsubst_copy_and_build): Likewise. + 2012-02-14 Balaji V. Iyer * parser.c (cp_parser_compound_stmt): Added a check to see if the diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5b67c6d..71dfc8e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13402,6 +13402,7 @@ finish_function_body (tree compstmt) if (cfun->calls_spawn) cfun->cilk_frame_decl = cp_make_cilk_frame (); + DECL_HAS_SPAWN_P (cfun->decl) = cfun->calls_spawn; /* Close the block. */ finish_compound_stmt (compstmt); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9fb8573..5ca8aa7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12383,6 +12383,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) for (i = 0; i < n; i++) TREE_OPERAND (t, i) = tsubst_copy (TREE_OPERAND (t, i), args, complain, in_decl); + SPAWN_CALL_P (result) = SPAWN_CALL_P (t); return result; } @@ -13901,7 +13902,7 @@ tsubst_copy_and_build (tree t, in_decl, !qualified_p, integral_constant_expression_p); - + SPAWN_CALL_P (function) = SPAWN_CALL_P (t); if (BASELINK_P (function)) qualified_p = true; } diff --git a/gcc/function.c b/gcc/function.c index ed07a83..a8acd39 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4420,6 +4420,7 @@ allocate_struct_function (tree fndecl, bool abstract_p) cfun->can_throw_non_call_exceptions = flag_non_call_exceptions; cfun->elem_fn_already_cloned = false; + cfun->calls_spawn = DECL_HAS_SPAWN_P (fndecl); } } diff --git a/gcc/tree.h b/gcc/tree.h index 1d4b18c..b204e30 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3564,8 +3564,8 @@ struct GTY(()) /* In a FUNCTION_DECL for a Cilk function, indicates that the function is a hyperobject lookup. */ -#define DECL_HYPER_LOOKUP_P(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->function_decl.cilk_hyper_flag) +#define DECL_HAS_SPAWN_P(NODE) \ + (FUNCTION_DECL_CHECK (NODE)->function_decl.cilk_has_spawn) /* In a FUNCTION_DECL with a nonzero DECL_CONTEXT, indicates that the static chain is an explicit argument. */ @@ -3573,8 +3573,6 @@ struct GTY(()) (FUNCTION_DECL_CHECK (NODE)->function_decl.explicit_static_chain_flag) - - /* In a FUNCTION_DECL indicates that a static chain is needed. */ #define DECL_STATIC_CHAIN(NODE) \ (FUNCTION_DECL_CHECK (NODE)->function_decl.regdecl_flag) @@ -3707,7 +3705,7 @@ struct GTY(()) tree_function_decl { unsigned looping_const_or_pure_flag : 1; unsigned has_debug_args_flag : 1; unsigned cilk_knot_type : 2; - unsigned cilk_hyper_flag : 1; + unsigned cilk_has_spawn : 1; signed int kills_registers : DECL_KILLS_REGISTERS_BITS; unsigned tm_clone_flag : 1;