From patchwork Sun Dec 11 19:30:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 9469859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B6A5560761 for ; Sun, 11 Dec 2016 19:31:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9433B280D0 for ; Sun, 11 Dec 2016 19:31:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7741D28306; Sun, 11 Dec 2016 19:31:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B93D4280D0 for ; Sun, 11 Dec 2016 19:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753706AbcLKTbA (ORCPT ); Sun, 11 Dec 2016 14:31:00 -0500 Received: from belmont79srvr.owm.bell.net ([184.150.200.79]:44485 "EHLO mtlfep01.bell.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753620AbcLKTbA (ORCPT ); Sun, 11 Dec 2016 14:31:00 -0500 Received: from bell.net mtlfep01 184.150.200.30 by mtlfep01.bell.net with ESMTP id <20161211193058.EEXV24384.mtlfep01.bell.net@mtlspm01.bell.net> for ; Sun, 11 Dec 2016 14:30:58 -0500 Received: from [192.168.2.10] (really [184.144.120.170]) by mtlspm01.bell.net with ESMTP id <20161211193058.KTWE3828.mtlspm01.bell.net@[192.168.2.10]>; Sun, 11 Dec 2016 14:30:58 -0500 From: John David Anglin Mime-Version: 1.0 (Apple Message framework v1085) Date: Sun, 11 Dec 2016 14:30:58 -0500 Subject: [committed] parisc: -mcaller-copies option Cc: "linux-parisc@vger.kernel.org List" To: "gcc-patches@gcc.gnu.org Patches" Message-Id: <99E90516-2165-4BC3-9E46-6900C6BA8F79@bell.net> X-Mailer: Apple Mail (2.1085) X-Opwv-CommTouchExtSvcRefID: str=0001.0A020204.584DA972.0195, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The attached change implements a new -mcaller-copies option on hppa. The default 32-bit runtime specifies that the callee copies arguments passed by hidden reference. This is optimal but it causes problems with openmp. See PR middle-end/68733: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68733 It's not clear openmp can be fixed to work with callee copies targets. This option provides a work around. The general consensus is that caller copies is better tested and it seems probable that we will switch to caller copies on Debian when we switch to gcc-7. Tested on hppa-unknown-linux-gnu, hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11 with no observed regression. When enabled, it fixes the failures noted in PR 68733. Committed to trunk. Dave --- John David Anglin dave.anglin@bell.net 2012-12-11 John David Anglin * config/pa/pa.c (pa_callee_copies): New function. * config/pa/pa.opt (mcaller-copies): New option. * doc/invoke.texi (mcaller-copies): Document option. Index: config/pa/pa.c =================================================================== --- config/pa/pa.c (revision 243232) +++ config/pa/pa.c (working copy) @@ -195,6 +195,8 @@ static bool pa_legitimate_constant_p (machine_mode, rtx); static unsigned int pa_section_type_flags (tree, const char *, int); static bool pa_legitimate_address_p (machine_mode, rtx, bool); +static bool pa_callee_copies (cumulative_args_t, machine_mode, + const_tree, bool); /* The following extra sections are only used for SOM. */ static GTY(()) section *som_readonly_data_section; @@ -343,7 +345,7 @@ #undef TARGET_PASS_BY_REFERENCE #define TARGET_PASS_BY_REFERENCE pa_pass_by_reference #undef TARGET_CALLEE_COPIES -#define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true +#define TARGET_CALLEE_COPIES pa_callee_copies #undef TARGET_ARG_PARTIAL_BYTES #define TARGET_ARG_PARTIAL_BYTES pa_arg_partial_bytes #undef TARGET_FUNCTION_ARG @@ -10720,4 +10722,19 @@ return NULL_RTX; } +/* Implement TARGET_CALLEE_COPIES. The callee is responsible for copying + arguments passed by hidden reference in the 32-bit HP runtime. Users + can override this behavior for better compatibility with openmp at the + risk of library incompatibilities. Arguments are always passed by value + in the 64-bit HP runtime. */ + +static bool +pa_callee_copies (cumulative_args_t cum ATTRIBUTE_UNUSED, + machine_mode mode ATTRIBUTE_UNUSED, + const_tree type ATTRIBUTE_UNUSED, + bool named ATTRIBUTE_UNUSED) +{ + return !TARGET_CALLER_COPIES; +} + #include "gt-pa.h" Index: config/pa/pa.opt =================================================================== --- config/pa/pa.opt (revision 243232) +++ config/pa/pa.opt (working copy) @@ -41,6 +41,10 @@ Target Ignore Does nothing. Preserved for backward compatibility. +mcaller-copies +Target Report Mask(CALLER_COPIES) +Caller copies function arguments passed by hidden reference. + mdisable-fpregs Target Report Mask(DISABLE_FPREGS) Disable FP regs. Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 243232) +++ doc/invoke.texi (working copy) @@ -761,7 +761,7 @@ @emph{HPPA Options} @gccoptlist{-march=@var{architecture-type} @gol --mdisable-fpregs -mdisable-indexing @gol +-mcaller-copies -mdisable-fpregs -mdisable-indexing @gol -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol -mfixed-range=@var{register-range} @gol -mjump-in-delay -mlinker-opt -mlong-calls @gol @@ -17363,6 +17363,14 @@ @opindex mpa-risc-2-0 Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. +@item -mcaller-copies +@opindex mcaller-copies +The caller copies function arguments passed by hidden reference. This +option should be used with care as it is not compatible with the default +32-bit runtime. However, only aggregates larger than eight bytes are +passed by hidden reference and the option provides better compatibility +with openmp. + @item -mjump-in-delay @opindex mjump-in-delay This option is ignored and provided for compatibility purposes only.