From ed7147268fbe45483b527399fd3d3b1a12ea0040 Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 14 Oct 2011 12:17:41 +0000 Subject: [PATCH] 2011-10-14 Richard Guenther Backport from mainline 2011-10-14 Richard Guenther PR tree-optimization/50723 * ipa-split.c (split_function): Use GSI_CONTINUE_LINKING. * gcc.dg/torture/pr50723.c: New testcase. 2011-10-13 Richard Guenther PR tree-optimization/50712 * ipa-split.c (split_function): Always re-gimplify parameters when they are not gimple vals before passing them. Properly check for type compatibility. * gcc.target/i386/pr50712.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@179974 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 15 +++++++++++++++ gcc/ipa-split.c | 24 +++++++++--------------- gcc/testsuite/ChangeLog | 11 +++++++++++ gcc/testsuite/gcc.dg/torture/pr50723.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr50712.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr50723.c create mode 100644 gcc/testsuite/gcc.target/i386/pr50712.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 76350c751ad..d06f12be69d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2011-10-14 Richard Guenther + + Backport from mainline + 2011-10-14 Richard Guenther + + PR tree-optimization/50723 + * ipa-split.c (split_function): Use GSI_CONTINUE_LINKING. + + 2011-10-13 Richard Guenther + + PR tree-optimization/50712 + * ipa-split.c (split_function): Always re-gimplify parameters + when they are not gimple vals before passing them. Properly + check for type compatibility. + 2011-10-12 Steve Ellcey PR target/49967 diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index 9a8b67897c9..ab3632c528b 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -956,7 +956,6 @@ split_function (struct split_point *split_point) tree retval = NULL, real_retval = NULL; bool split_part_return_p = false; gimple last_stmt = NULL; - bool conv_needed = false; unsigned int i; tree arg; @@ -999,12 +998,8 @@ split_function (struct split_point *split_point) else arg = parm; - if (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)) - != TYPE_MAIN_VARIANT (TREE_TYPE (arg))) - { - conv_needed = true; - arg = fold_convert (DECL_ARG_TYPE (parm), arg); - } + if (!useless_type_conversion_p (DECL_ARG_TYPE (parm), TREE_TYPE (arg))) + arg = fold_convert (DECL_ARG_TYPE (parm), arg); VEC_safe_push (tree, heap, args_to_pass, arg); } @@ -1112,14 +1107,13 @@ split_function (struct split_point *split_point) /* Produce the call statement. */ gsi = gsi_last_bb (call_bb); - if (conv_needed) - FOR_EACH_VEC_ELT (tree, args_to_pass, i, arg) - if (!is_gimple_val (arg)) - { - arg = force_gimple_operand_gsi (&gsi, arg, true, NULL_TREE, - false, GSI_NEW_STMT); - VEC_replace (tree, args_to_pass, i, arg); - } + FOR_EACH_VEC_ELT (tree, args_to_pass, i, arg) + if (!is_gimple_val (arg)) + { + arg = force_gimple_operand_gsi (&gsi, arg, true, NULL_TREE, + false, GSI_CONTINUE_LINKING); + VEC_replace (tree, args_to_pass, i, arg); + } call = gimple_build_call_vec (node->decl, args_to_pass); gimple_set_block (call, DECL_INITIAL (current_function_decl)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a78217e9cc..affaded7b82 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2011-10-14 Richard Guenther + + Backport from mainline + 2011-10-14 Richard Guenther + + * gcc.dg/torture/pr50723.c: New testcase. + + 2011-10-13 Richard Guenther + + * gcc.target/i386/pr50712.c: New testcase. + 2011-10-13 Jason Merrill PR c++/50618 diff --git a/gcc/testsuite/gcc.dg/torture/pr50723.c b/gcc/testsuite/gcc.dg/torture/pr50723.c new file mode 100644 index 00000000000..24e490fc618 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr50723.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +typedef short unsigned int wchar_t; +typedef unsigned int size_t; +int* _errno(void); +int WideCharToMultiByte (wchar_t *); +int __attribute__ ((__nonnull__ (1))) +__wcrtomb_cp (char *dst, wchar_t wc, const unsigned int cp, + const unsigned int mb_max) +{ + if (cp == 0) { + if (wc > 255) + (*_errno()) = 42; + return 1; + } + else + return WideCharToMultiByte (&wc); +} +void wcsrtombs (char *dst, const wchar_t *pwc, unsigned int cp, + unsigned int mb_max) +{ + if ((__wcrtomb_cp (dst, *pwc, cp, mb_max)) <= 0) + return; + if ((__wcrtomb_cp (dst, *pwc, cp, mb_max)) <= 0) + return; +} diff --git a/gcc/testsuite/gcc.target/i386/pr50712.c b/gcc/testsuite/gcc.target/i386/pr50712.c new file mode 100644 index 00000000000..f08a94453de --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr50712.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O2" } */ + +typedef __builtin_va_list __va_list; +typedef __va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; +struct MSVCRT__iobuf { }; +typedef struct MSVCRT__iobuf MSVCRT_FILE; +typedef union _printf_arg { } printf_arg; +MSVCRT_FILE MSVCRT__iob[20]; +int pf_print_a (va_list *); +int __attribute__((__cdecl__)) +MSVCRT_vfprintf_s(MSVCRT_FILE* file, const char *format, va_list valist) +{ + if(!((file != ((void *)0)) + || (MSVCRT__invalid_parameter(((void *)0), ((void *)0), + ((void *)0), 0, 0),0))) + return -1; + return pf_printf_a(&valist); +} +int __attribute__((__cdecl__)) +MSVCRT_vprintf_s(const char *format, va_list valist) +{ + return MSVCRT_vfprintf_s((MSVCRT__iob+1),format,valist); +} +int __attribute__((__cdecl__)) +MSVCRT_fprintf_s(MSVCRT_FILE* file, const char *format, ...) +{ + va_list valist; + va_start (valist, format); + return MSVCRT_vfprintf_s(file, format, valist); +} -- 2.11.0