re PR c++/71210 (internal compiler error: in assign_temp, at function.c:961)

PR c++/71210
	* gimple-fold.c (gimple_fold_call): Do not remove lhs of noreturn
	calls if the LHS is variable length or has addressable type.
	If targets[0]->decl is a noreturn call with void return type and
	zero arguments, adjust fntype and remove lhs in that case.

	* g++.dg/opt/pr71210-1.C: New test.
	* g++.dg/opt/pr71210-2.C: New test.

From-SVN: r236506
This commit is contained in:
Jakub Jelinek 2016-05-20 13:58:49 +02:00 committed by Jakub Jelinek
parent 6804797178
commit 1895484016
5 changed files with 66 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2016-05-20 Jakub Jelinek <jakub@redhat.com>
PR c++/71210
* gimple-fold.c (gimple_fold_call): Do not remove lhs of noreturn
calls if the LHS is variable length or has addressable type.
If targets[0]->decl is a noreturn call with void return type and
zero arguments, adjust fntype and remove lhs in that case.
2016-05-20 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/71079

View File

@ -3039,10 +3039,25 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
}
if (targets.length () == 1)
{
gimple_call_set_fndecl (stmt, targets[0]->decl);
tree fndecl = targets[0]->decl;
gimple_call_set_fndecl (stmt, fndecl);
changed = true;
/* If changing the call to __cxa_pure_virtual
or similar noreturn function, adjust gimple_call_fntype
too. */
if ((gimple_call_flags (stmt) & ECF_NORETURN)
&& VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fndecl)))
&& TYPE_ARG_TYPES (TREE_TYPE (fndecl))
&& (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)))
== void_type_node))
gimple_call_set_fntype (stmt, TREE_TYPE (fndecl));
/* If the call becomes noreturn, remove the lhs. */
if (lhs && (gimple_call_flags (stmt) & ECF_NORETURN))
if (lhs
&& (gimple_call_flags (stmt) & ECF_NORETURN)
&& (VOID_TYPE_P (TREE_TYPE (gimple_call_fntype (stmt)))
|| ((TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs)))
== INTEGER_CST)
&& !TREE_ADDRESSABLE (TREE_TYPE (lhs)))))
{
if (TREE_CODE (lhs) == SSA_NAME)
{

View File

@ -1,5 +1,9 @@
2016-05-20 Jakub Jelinek <jakub@redhat.com>
PR c++/71210
* g++.dg/opt/pr71210-1.C: New test.
* g++.dg/opt/pr71210-2.C: New test.
PR tree-optimization/29756
gcc.dg/tree-ssa/vector-6.c: Add -Wno-psabi -w to dg-options.
Add -msse2 for x86 and -maltivec for powerpc. Use scan-tree-dump-times

View File

@ -0,0 +1,14 @@
// PR c++/71210
// { dg-do compile }
// { dg-options "-O2" }
#include <typeinfo>
void f1 (const std::type_info&) __attribute__((noreturn));
struct S1 { ~S1 (); };
struct S2
{
virtual S1 f2 () const { f1 (typeid (*this)); }
S1 f3 () const { return f2 (); }
};
void f4 () { S2 a; a.f3 (); }

View File

@ -0,0 +1,23 @@
// PR c++/71210
// { dg-do compile }
// { dg-options "-O2" }
struct C { int a; int b; C (); ~C (); };
namespace
{
struct A
{
A () {}
virtual C bar (int) = 0;
C baz (int x) { return bar (x); }
};
}
A *a;
void
foo ()
{
C c = a->baz (0);
}