Re: [patch] Fix PR middle-end/98082

2020-12-03 Thread Richard Biener via Gcc-patches
On Thu, Dec 3, 2020 at 11:49 AM Eric Botcazou  wrote:
>
> Hi,
>
> this fixes an ICE introduced on the mainline by my fix for PR middle-end/97078
> where I changed use_register_for_decl to return true at -O0 for a parameter of
> a thunk.  It turns out that we need to do the same for a result in this case.
>
> Tested on x86-64/Linux, OK for the mainline?

OK.

Richard.

>
> 2020-12-03  Eric Botcazou  
>
> PR middle-end/98082
> * function.c (use_register_for_decl): Also return true for a result
> if cfun->tail_call_marked is true.
>
>
> 2020-12-03  Eric Botcazou  
>
> * g++.dg/cpp2a/pr98082.C: New test.
>
> --
> Eric Botcazou


[patch] Fix PR middle-end/98082

2020-12-03 Thread Eric Botcazou
Hi,

this fixes an ICE introduced on the mainline by my fix for PR middle-end/97078 
where I changed use_register_for_decl to return true at -O0 for a parameter of 
a thunk.  It turns out that we need to do the same for a result in this case.

Tested on x86-64/Linux, OK for the mainline?


2020-12-03  Eric Botcazou  

PR middle-end/98082
* function.c (use_register_for_decl): Also return true for a result
if cfun->tail_call_marked is true.


2020-12-03  Eric Botcazou  

* g++.dg/cpp2a/pr98082.C: New test.

-- 
Eric Botcazoudiff --git a/gcc/function.c b/gcc/function.c
index 59fd72b0e82..af9618e18df 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -2206,13 +2206,15 @@ use_register_for_decl (const_tree decl)
   /* Otherwise, if RESULT_DECL is DECL_BY_REFERENCE, it will take
 	 the function_result_decl's assignment.  Since it's a pointer,
 	 we can short-circuit a number of the tests below, and we must
-	 duplicat e them because we don't have the
-	 function_result_decl to test.  */
+	 duplicate them because we don't have the function_result_decl
+	 to test.  */
   if (!targetm.calls.allocate_stack_slots_for_args ())
 	return true;
   /* We don't set DECL_IGNORED_P for the function_result_decl.  */
   if (optimize)
 	return true;
+  if (cfun->tail_call_marked)
+	return true;
   /* We don't set DECL_REGISTER for the function_result_decl.  */
   return false;
 }
/* PR middle-end/98082 */
/* Reported by Martin Liska  */

/* { dg-do compile { target c++20 } } */
/* { dg-options "-fipa-icf" } */

class GoodIter {
public:
  GoodIter();
  GoodIter(GoodIter &);
};

GoodIter operator-(int, GoodIter) { return GoodIter(); }
GoodIter operator+(int, GoodIter) { return GoodIter(); }