Bug 50712 - [4.7 regression] invalid argument to gimple call
Summary: [4.7 regression] invalid argument to gimple call
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-13 05:21 UTC by Gerald Pfeifer
Modified: 2011-10-14 12:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-10-13 00:00:00


Attachments
File triggering the crash (73.30 KB, application/x-gzip)
2011-10-13 05:21 UTC, Gerald Pfeifer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gerald Pfeifer 2011-10-13 05:21:19 UTC
Created attachment 25480 [details]
File triggering the crash

Compiling the attached (which is from Wine) with -O2, I get

  file.c: In function 'MSVCRT_vfprintf_s':
  file.c:4026:1: error: invalid argument to gimple call valist
  # .MEM_3 = VDEF <.MEM_9(D)>
  ret_8 = MSVCRT_vfprintf_s.part.7 (file_2(D), format_5(D), valist);
  file.c:4026:1: internal compiler error: verify_gimple failed

This must have happened about three days ago.
Comment 1 Richard Biener 2011-10-13 09:31:06 UTC
Mine, reducing.
Comment 2 Richard Biener 2011-10-13 10:06:04 UTC
Reduced testcase (suspicious because of address-taking of a valist):

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);
}
Comment 3 Richard Biener 2011-10-13 10:10:50 UTC
More likely caused by adding checking to pass_split_functions.  It splits

MSVCRT_vfprintf_s (struct MSVCRT_FILE * file, const char * format, char * valist)
{
  int D.2058;

<bb 2>:
  if (file_2(D) == 0B)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  MSVCRT__invalid_parameter (0B, 0B, 0B, 0, 0);
  goto <bb 5>;

<bb 4>:
  D.2058_4 = pf_printf_a (&valist);

<bb 5>:
  # D.2058_1 = PHI <-1(3), D.2058_4(4)>
  return D.2058_1;

to

MSVCRT_vfprintf_s (struct MSVCRT_FILE * file, const char * format, char * valist)
{
  int D.2058;

<bb 2>:
  if (file_2(D) == 0B)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  D.2058_5 = MSVCRT_vfprintf_s.part.0 (file_2(D), format_3(D), valist);
  goto <bb 5>;

<bb 4>:
  D.2058_4 = pf_printf_a (&valist);

<bb 5>:
  # D.2058_1 = PHI <D.2058_5(3), D.2058_4(4)>
  return D.2058_1;

but fails to realize that for passing the address-taken parameter valist
it has to gimplify it.
Comment 4 Richard Biener 2011-10-13 10:44:12 UTC
I have a patch.
Comment 5 Richard Biener 2011-10-13 12:07:49 UTC
Author: rguenth
Date: Thu Oct 13 12:07:44 2011
New Revision: 179919

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179919
Log:
2011-10-13  Richard Guenther  <rguenther@suse.de>

	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.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr50712.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-split.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Richard Biener 2011-10-13 12:50:04 UTC
Fixed.
Comment 7 Richard Biener 2011-10-14 12:17:49 UTC
Author: rguenth
Date: Fri Oct 14 12:17:41 2011
New Revision: 179974

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179974
Log:
2011-10-14  Richard Guenther  <rguenther@suse.de>

	Backport from mainline
	2011-10-14  Richard Guenther  <rguenther@suse.de>

	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  <rguenther@suse.de>

	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.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/torture/pr50723.c
    branches/gcc-4_6-branch/gcc/testsuite/gcc.target/i386/pr50712.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/ipa-split.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog