This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PR81489, committed] Fix phi arg location in find_implicit_erroneous_behavior


Hi,

this patch moves the reading of a phi arg location to before the loop that modifies the phi, ensuring that we're not reading some random value.

PR found with a patch that does more strict checking in gimple_phi_arg.

Bootstrapped and reg-tested on x86_64.

Committed as obvious.

Thanks,
- Tom
Fix phi arg location in find_implicit_erroneous_behavior

2017-07-20  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/81489
	* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior): Move
	read of phi arg location to before loop that modifies phi.

---
 gcc/gimple-ssa-isolate-paths.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index 7ad39b4..fbc4105 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -442,6 +442,8 @@ find_implicit_erroneous_behavior (void)
 	      if (!integer_zerop (op))
 		continue;
 
+	      location_t phi_arg_loc = gimple_phi_arg_location (phi, i);
+
 	      /* We've got a NULL PHI argument.  Now see if the
  	         PHI's result is dereferenced within BB.  */
 	      FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs)
@@ -454,7 +456,7 @@ find_implicit_erroneous_behavior (void)
 
 		  location_t loc = gimple_location (use_stmt)
 		    ? gimple_location (use_stmt)
-		    : gimple_phi_arg_location (phi, i);
+		    : phi_arg_loc;
 
 		  if (stmt_uses_name_in_undefined_way (use_stmt, lhs, loc))
 		    {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]