This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Avoid NULL cfun ICE in gcc/config/nvptx/nvptx.c:nvptx_libcall_value
- From: Thomas Schwinge <thomas at codesourcery dot com>
- To: Bernd Schmidt <bschmidt at redhat dot com>, Alexander Monakov <amonakov at ispras dot ru>, Richard Biener <rguenther at suse dot de>, <gcc-patches at gcc dot gnu dot org>
- Cc: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Mon, 2 May 2016 13:29:20 +0200
- Subject: Re: Avoid NULL cfun ICE in gcc/config/nvptx/nvptx.c:nvptx_libcall_value
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1604271256500 dot 13384 at t29 dot fhfr dot qr> <87wpnixc4v dot fsf at kepler dot schwinge dot homeip dot net> <alpine dot LSU dot 2 dot 11 dot 1604281241260 dot 13384 at t29 dot fhfr dot qr> <alpine dot LNX dot 2 dot 20 dot 1604281400460 dot 19258 at monopod dot intra dot ispras dot ru> <5721F72F dot 2050002 at redhat dot com>
Hi!
On Thu, 28 Apr 2016 13:42:39 +0200, Bernd Schmidt <bschmidt@redhat.com> wrote:
> On 04/28/2016 01:15 PM, Alexander Monakov wrote:
> > So if my understanding is correct, additional !cfun check can be acceptable as
> > a fix along the existing hack. Perhaps with a note about the nature of the
> > hack.
>
> Yes, I think Thomas' patch is ok.
Thanks for the review of the patch as well as the existing code; I filed
<http://gcc.gnu.org/PR70860> "[nvptx] Revisit cfun->machine->doing_call".
To resolve the immediate problem, I committed to trunk in r235748:
commit 5fbb617747498ce3b0fd97aaa5334611e6220263
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon May 2 11:25:17 2016 +0000
[PR target/70860] [nvptx] Handle NULL cfun in nvptx_libcall_value
gcc/
PR target/70860
* config/nvptx/nvptx.c (nvptx_libcall_value): Handle NULL cfun.
(nvptx_function_value): Assert non-NULL cfun.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235748 138bc75d-0d04-0410-961f-82ee72b054a4
---
gcc/ChangeLog | 6 ++++++
gcc/config/nvptx/nvptx.c | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git gcc/ChangeLog gcc/ChangeLog
index 49a314a..f344e0f 100644
--- gcc/ChangeLog
+++ gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-05-02 Thomas Schwinge <thomas@codesourcery.com>
+
+ PR target/70860
+ * config/nvptx/nvptx.c (nvptx_libcall_value): Handle NULL cfun.
+ (nvptx_function_value): Assert non-NULL cfun.
+
2016-05-02 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/70886
diff --git gcc/config/nvptx/nvptx.c gcc/config/nvptx/nvptx.c
index b088cf8..a6c90b6 100644
--- gcc/config/nvptx/nvptx.c
+++ gcc/config/nvptx/nvptx.c
@@ -483,7 +483,7 @@ nvptx_strict_argument_naming (cumulative_args_t cum_v)
static rtx
nvptx_libcall_value (machine_mode mode, const_rtx)
{
- if (!cfun->machine->doing_call)
+ if (!cfun || !cfun->machine->doing_call)
/* Pretend to return in a hard reg for early uses before pseudos can be
generated. */
return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM);
@@ -502,6 +502,7 @@ nvptx_function_value (const_tree type, const_tree ARG_UNUSED (func),
if (outgoing)
{
+ gcc_assert (cfun);
cfun->machine->return_mode = mode;
return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM);
}
GrÃÃe
Thomas