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]

Re: [PATCH] strlenopt improvements


On Mon, Oct 24, 2011 at 07:15:14PM +0200, Andreas Krebbel wrote:
> +       if (dsi->prev != 0 && (chainsi = verify_related_strinfos (dsi)) != NULL)
> + 	{
> + 	  bool stmt_set_p = false;
> + 
> + 	  for (; chainsi && chainsi != dsi; chainsi = get_strinfo (chainsi->next))
> + 	    {
> + 	      /* When setting a stmt for delayed length computation
> + 		 prevent all strinfos through dsi from being
> + 		 invalidated.  */
> + 	      if (stmt_set_p)
> + 		chainsi->dont_invalidate = true;
> + 
> + 	      chainsi = unshare_strinfo (chainsi);
> + 	      chainsi->stmt = stmt;
> + 	      chainsi->length = NULL_TREE;
> + 	      chainsi->endptr = NULL_TREE;
> + 	      chainsi->dont_invalidate = true;
> + 	      stmt_set_p = true;
> + 	    }
> + 	}

Can you please explain this stmt_set_p stuff?  dont_invalidate should be
only set on strinfos that will be seen by the immediately following
maybe_invalidate call (at the end of handle_builtin_strcpy caller -
strlen_optimize_stmt).  If you set it on which unshare_strinfo is called,
if there is no unsharing, it is obviously fine, but if there is unsharing,
then dont_invalidate will be set on some strinfo that won't be seen by the
next may_invalidate.  It might trigger in some other basic block and might
cause wrong code.

Otherwise it looks good.

	Jakub


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