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]

[PATCH] Fix multiply evaluated arguments of builtin math functions (PR middle-end/18951)


Hi!

Although expand_builtin_mathfn etc. call save_expr, it is not using always
the returned tree:

      narg = save_expr (arg);
      if (narg != arg)
        {
          arglist = build_tree_list (NULL_TREE, arg);
          exp = build_function_call_expr (fndecl, arglist);
        }

      op0 = expand_expr (arg, subtarget, VOIDmode, 0);

The (potential) SAVE_EXPR is passed to expand_call in
expand_errno_check or if expand_unop fails expand_call below this, but
op0 = expand_expr uses the original argument, so it will be expanded
multiple times.

On HEAD I can't reproduce this, because with tree-SSA there aren't
side-effects when we reach this routine, still I think it should be fixed
there too.

Ok for HEAD/3.4?

	Jakub

Attachment: T34
Description: Text document

Attachment: THEAD
Description: Text document


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