summaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-05-20 11:58:49 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-05-20 11:58:49 +0000
commitb9a1dcd541be1d886b3f473c1c310d351bf91b6f (patch)
treef40d460b0d22bea9c8d8b3aaed1d75663960dafa /gcc/gimple-fold.c
parent45cdf8c6c9498e0badf8c5bca4458c5f5480ca53 (diff)
downloadgcc-b9a1dcd541be1d886b3f473c1c310d351bf91b6f.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236506 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index d3968e98620..858f4844426 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -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)
{