]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/122225 - fix return stmt verification
authorRichard Biener <rguenther@suse.de>
Fri, 10 Oct 2025 06:20:22 +0000 (08:20 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 10 Oct 2025 07:39:36 +0000 (09:39 +0200)
The following fixes return stmt type verification by properly looking
at DECL_RESULT to decide whether that's by reference, not trying to
figure that from the actual argument.

PR tree-optimization/122225
* tree-cfg.cc (verify_gimple_return): Look at DECL_RESULT
for DECL_BY_REFERENCE.

gcc/tree-cfg.cc

index 39aeb16f74e0e5a9aa6a7f896c4b698a78bfed7b..62513045c6f0b5436299ff33effba1b7c4f2608e 100644 (file)
@@ -4786,6 +4786,7 @@ verify_gimple_return (greturn *stmt)
 {
   tree op = gimple_return_retval (stmt);
   tree restype = TREE_TYPE (TREE_TYPE (cfun->decl));
+  tree resdecl = DECL_RESULT (cfun->decl);
 
   /* We cannot test for present return values as we do not fix up missing
      return values from the original source.  */
@@ -4800,12 +4801,7 @@ verify_gimple_return (greturn *stmt)
       return true;
     }
 
-  if ((TREE_CODE (op) == RESULT_DECL
-       && DECL_BY_REFERENCE (op))
-      || (TREE_CODE (op) == SSA_NAME
-         && SSA_NAME_VAR (op)
-         && TREE_CODE (SSA_NAME_VAR (op)) == RESULT_DECL
-         && DECL_BY_REFERENCE (SSA_NAME_VAR (op))))
+  if (resdecl && DECL_BY_REFERENCE (resdecl))
     op = TREE_TYPE (op);
 
   if (!useless_type_conversion_p (restype, TREE_TYPE (op)))