Bug 34013 - callee-save register value sometimes corrupted when __stkchk called
Summary: callee-save register value sometimes corrupted when __stkchk called
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-07 11:40 UTC by Arthur Norman
Modified: 2008-01-30 11:34 UTC (History)
4 users (show)

See Also:
Host: i686-pc-cygwin
Target: x86_64-pc-mingw32
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed: 2008-01-30 10:04:58


Attachments
patch to gcc/config/i386/i386.c (550 bytes, patch)
2007-11-09 22:56 UTC, Arthur Norman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Norman 2007-11-07 11:40:49 UTC
A subversion gcc,  x86_64-pc-mingw32-gcc (GCC) 4.3.0 20071106 
(experimental),
built with
  $ ../configure --target=x86_64-pc-mingw32
built on cygwin running on Vista 64-bit.

I observe similar effects on a bunch of earlier versions too.

Then
x86_64-pc-mingw32-gcc -Wall -O2 cbug3.c -o cbug2 -DBAD=1 -save-temps
and NO warnings or other moans.  The cbug3.i file follows.

My full script goes

x86_64-pc-mingw32-gcc -Wall -O0 cbug3.c -o cbug0
x86_64-pc-mingw32-gcc -Wall -O2 cbug3.c -o cbug2 -DBAD=1 -save-temps

./cbug0
1 2 3 4 5 6 000000000022FE68 0
1 2 3 4 5 6 000000000022FE68 0
./cbug2
1 2 3 4 5 6 000000000022FE58 0
1 401508 3 4 5 6 000000000022FE58 0
 0: 0 0
 ...
and observe the difference made by -O2 rather than -O0 (-DBAD=1 does not 
change that part of the effect). A variable4 has been corrupted, and checking the .s file it lived in %r13.


An extract from said .s file shows
        movl    $8088, %eax
        movq    %rbx, -48(%rsp)
        movq    %rsi, -40(%rsp)
        movq    %rdi, -32(%rsp)
        movq    %rbp, -24(%rsp)
        movq    %r12, -16(%rsp)
        movq    %r13, -8(%rsp)
        call    ___chkstk
        ...

And I rather suspect that the "call" instruction there pushes a return 
address onto the stack clobbering the %r13 values that gcc had been 
attempting to save.


Here is the source code, NOT using any libraries (except __chkstk) and printf, but printf is just to report the failure and I have no reason to believe it is iomplicated. Soem messy code in the test stuff is to have procedures big enough that they do not get incorporated in-line and try to ensure all potential regiers usable for register variables are in active use.
==============

# 1 "cbug3.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "cbug3.c"
# 1 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 1 3
# 9 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 3
# 1 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 1 3
# 70 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
typedef int __int128 __attribute__ ((mode (TI)));
# 99 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
#pragma pack(push,_CRT_PACKING)

# 1 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/vadefs.h" 1 3
# 13 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/vadefs.h" 3
# 1 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 1 3
# 14 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/vadefs.h" 2 3



#pragma pack(push,_CRT_PACKING)







  typedef unsigned long long uintptr_t;
# 34 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/vadefs.h" 3
  typedef __builtin_va_list __gnuc_va_list;




  typedef __gnuc_va_list va_list;
# 76 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/vadefs.h" 3
#pragma pack(pop)
# 102 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 2 3
# 188 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
  typedef unsigned long long size_t;
# 197 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
  typedef long long ssize_t;
# 206 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
  typedef long long intptr_t;
# 225 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
  typedef long long ptrdiff_t;
# 234 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
  typedef unsigned short wchar_t;




  typedef unsigned short wint_t;
  typedef unsigned short wctype_t;
# 266 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
  typedef int errcode;
  typedef int errno_t;




  typedef long __time32_t;





  typedef long long __time64_t;
# 287 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
  typedef __time64_t time_t;
# 328 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
  struct threadlocaleinfostruct;
  struct threadmbcinfostruct;
  typedef struct threadlocaleinfostruct *pthreadlocinfo;
  typedef struct threadmbcinfostruct *pthreadmbcinfo;
  struct __lc_time_data;

  typedef struct localeinfo_struct {
    pthreadlocinfo locinfo;
    pthreadmbcinfo mbcinfo;
  } _locale_tstruct,*_locale_t;



  typedef struct tagLC_ID {
    unsigned short wLanguage;
    unsigned short wCountry;
    unsigned short wCodePage;
  } LC_ID,*LPLC_ID;




  typedef struct threadlocaleinfostruct {
    int refcount;
    unsigned int lc_codepage;
    unsigned int lc_collate_cp;
    unsigned long lc_handle[6];
    LC_ID lc_id[6];
    struct {
      char *locale;
      wchar_t *wlocale;
      int *refcount;
      int *wrefcount;
    } lc_category[6];
    int lc_clike;
    int mb_cur_max;
    int *lconv_intl_refcount;
    int *lconv_num_refcount;
    int *lconv_mon_refcount;
    struct lconv *lconv;
    int *ctype1_refcount;
    unsigned short *ctype1;
    const unsigned short *pctype;
    const unsigned char *pclmap;
    const unsigned char *pcumap;
    struct __lc_time_data *lc_time_curr;
  } threadlocinfo;
# 387 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/_mingw.h" 3
#pragma pack(pop)
# 10 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 2 3

#pragma pack(push,_CRT_PACKING)
# 24 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 3
  struct _iobuf {
    char *_ptr;
    int _cnt;
    char *_base;
    int _flag;
    int _file;
    int _charbuf;
    int _bufsiz;
    char *_tmpfname;
  };
  typedef struct _iobuf FILE;
# 76 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 3
  typedef long _off_t;

  typedef long off_t;





  typedef long long _off64_t;

  typedef long long off64_t;




  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) __iob_func(void);







  typedef long long fpos_t;
# 136 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 3
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _filbuf(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _flsbuf(int _Ch,FILE *_File);



  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) _fsopen(const char *_Filename,const char *_Mode,int _ShFlag);

  __attribute__ ((dllimport)) void __attribute__((__cdecl__)) clearerr(FILE *_File);
  __attribute__ ((dllimport)) errno_t __attribute__((__cdecl__)) clearerr_s(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fclose(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fcloseall(void);



  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) _fdopen(int _FileHandle,const char *_Mode);

  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) feof(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) ferror(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fflush(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fgetc(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fgetchar(void);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fgetpos(FILE *_File ,fpos_t *_Pos);
  __attribute__ ((dllimport)) char *__attribute__((__cdecl__)) fgets(char *_Buf,int _MaxCount,FILE *_File);



  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fileno(FILE *_File);

  __attribute__ ((dllimport)) char *__attribute__((__cdecl__)) _tempnam(const char *_DirName,const char *_FilePrefix);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _flushall(void);
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) fopen(const char *_Filename,const char *_Mode);
  FILE *fopen64(const char *filename,const char *mode);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fprintf(FILE *_File,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fprintf_s(FILE *_File,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fputc(int _Ch,FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fputchar(int _Ch);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fputs(const char *_Str,FILE *_File);
  __attribute__ ((dllimport)) size_t __attribute__((__cdecl__)) fread(void *_DstBuf,size_t _ElementSize,size_t _Count,FILE *_File);
  __attribute__ ((dllimport)) size_t __attribute__((__cdecl__)) fread_s(void *_DstBuf,size_t _DstSize,size_t _ElementSize,size_t _Count,FILE *_File);
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) freopen(const char *_Filename,const char *_Mode,FILE *_File);
              int __attribute__((__cdecl__)) fscanf(FILE *_File,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fscanf_l(FILE *_File,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fscanf_s_l(FILE *_File,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fsetpos(FILE *_File,const fpos_t *_Pos);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fseek(FILE *_File,long _Offset,int _Origin);
   int fseeko64(FILE* stream, _off64_t offset, int whence);
  __attribute__ ((dllimport)) long __attribute__((__cdecl__)) ftell(FILE *_File);
  _off64_t ftello64(FILE * stream);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fseeki64(FILE *_File,long long _Offset,int _Origin);
  __attribute__ ((dllimport)) long long __attribute__((__cdecl__)) _ftelli64(FILE *_File);
  __attribute__ ((dllimport)) size_t __attribute__((__cdecl__)) fwrite(const void *_Str,size_t _Size,size_t _Count,FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) getc(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) getchar(void);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _getmaxstdio(void);
  __attribute__ ((dllimport)) char *__attribute__((__cdecl__)) gets(char *_Buffer);
  int __attribute__((__cdecl__)) _getw(FILE *_File);


  __attribute__ ((dllimport)) void __attribute__((__cdecl__)) perror(const char *_ErrMsg);

  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _pclose(FILE *_File);
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) _popen(const char *_Command,const char *_Mode);




  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) printf(const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) printf_s(const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) putc(int _Ch,FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) putchar(int _Ch);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) puts(const char *_Str);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _putw(int _Word,FILE *_File);


  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) remove(const char *_Filename);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) rename(const char *_OldFilename,const char *_NewFilename);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _unlink(const char *_Filename);

  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) unlink(const char *_Filename);


  __attribute__ ((dllimport)) void __attribute__((__cdecl__)) rewind(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _rmtmp(void);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) scanf(const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scanf_l(const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scanf_s_l(const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) void __attribute__((__cdecl__)) setbuf(FILE *_File,char *_Buffer);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _setmaxstdio(int _Max);
  __attribute__ ((dllimport)) unsigned int __attribute__((__cdecl__)) _set_output_format(unsigned int _Format);
  __attribute__ ((dllimport)) unsigned int __attribute__((__cdecl__)) _get_output_format(void);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) setvbuf(FILE *_File,char *_Buf,int _Mode,size_t _Size);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snprintf_s(char *_DstBuf,size_t _DstSize,size_t _MaxCount,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) sprintf_s(char *_DstBuf,size_t _DstSize,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scprintf(const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) sscanf(const char *_Src,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _sscanf_l(const char *_Src,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _sscanf_s_l(const char *_Src,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snscanf(const char *_Src,size_t _MaxCount,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snscanf_l(const char *_Src,size_t _MaxCount,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snscanf_s(const char *_Src,size_t _MaxCount,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snscanf_s_l(const char *_Src,size_t _MaxCount,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) tmpfile(void);
  __attribute__ ((dllimport)) char *__attribute__((__cdecl__)) tmpnam(char *_Buffer);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) ungetc(int _Ch,FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vfprintf(FILE *_File,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vfprintf_s(FILE *_File,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vprintf(const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vprintf_s(const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vsnprintf(char *_DstBuf,size_t _MaxCount,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vsnprintf_s(char *_DstBuf,size_t _DstSize,size_t _MaxCount,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnprintf_s(char *_DstBuf,size_t _DstSize,size_t _MaxCount,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snprintf(char *_Dest,size_t _Count,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnprintf(char *_Dest,size_t _Count,const char *_Format,va_list _Args);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vsprintf_s(char *_DstBuf,size_t _Size,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) sprintf(char *_Dest,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vsprintf(char *_Dest,const char *_Format,va_list _Args);

  int __attribute__((__cdecl__)) snprintf(char* s, size_t n, const char* format, ...);
  extern __inline__ int __attribute__((__cdecl__)) vsnprintf (char* s, size_t n, const char* format,va_list arg) {
    return _vsnprintf ( s, n, format, arg);
  }
  int __attribute__((__cdecl__)) vscanf(const char * Format, va_list argp);
  int __attribute__((__cdecl__)) vfscanf (FILE * fp, const char * Format,va_list argp);
  int __attribute__((__cdecl__)) vsscanf (const char * _Str,const char * Format,va_list argp);

  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vscprintf(const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snprintf_c(char *_DstBuf,size_t _MaxCount,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnprintf_c(char *_DstBuf,size_t _MaxCount,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fprintf_p(FILE *_File,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _printf_p(const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _sprintf_p(char *_Dst,size_t _MaxCount,const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vfprintf_p(FILE *_File,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vprintf_p(const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsprintf_p(char *_Dst,size_t _MaxCount,const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scprintf_p(const char *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vscprintf_p(const char *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _set_printf_count_output(int _Value);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _get_printf_count_output();
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _printf_l(const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _printf_p_l(const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _printf_s_l(const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vprintf_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vprintf_p_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vprintf_s_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fprintf_l(FILE *_File,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fprintf_p_l(FILE *_File,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fprintf_s_l(FILE *_File,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vfprintf_l(FILE *_File,const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vfprintf_p_l(FILE *_File,const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vfprintf_s_l(FILE *_File,const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _sprintf_l(char *_DstBuf,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _sprintf_p_l(char *_DstBuf,size_t _MaxCount,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _sprintf_s_l(char *_DstBuf,size_t _DstSize,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsprintf_l(char *_DstBuf,const char *_Format,_locale_t,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsprintf_p_l(char *_DstBuf,size_t _MaxCount,const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsprintf_s_l(char *_DstBuf,size_t _DstSize,const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scprintf_l(const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scprintf_p_l(const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vscprintf_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vscprintf_p_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snprintf_l(char *_DstBuf,size_t _MaxCount,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snprintf_c_l(char *_DstBuf,size_t _MaxCount,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snprintf_s_l(char *_DstBuf,size_t _DstSize,size_t _MaxCount,const char *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnprintf_l(char *_DstBuf,size_t _MaxCount,const char *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnprintf_c_l(char *_DstBuf,size_t _MaxCount,const char *,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnprintf_s_l(char *_DstBuf,size_t _DstSize,size_t _MaxCount,const char *_Format,_locale_t _Locale,va_list _ArgList);
# 312 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 3
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode,int _ShFlag);

  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) fgetwc(FILE *_File);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) _fgetwchar(void);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) fputwc(wchar_t _Ch,FILE *_File);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) _fputwchar(wchar_t _Ch);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) getwc(FILE *_File);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) getwchar(void);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) putwc(wchar_t _Ch,FILE *_File);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) putwchar(wchar_t _Ch);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) ungetwc(wint_t _Ch,FILE *_File);
  __attribute__ ((dllimport)) wchar_t *__attribute__((__cdecl__)) fgetws(wchar_t *_Dst,int _SizeInWords,FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fputws(const wchar_t *_Str,FILE *_File);
  __attribute__ ((dllimport)) wchar_t *__attribute__((__cdecl__)) _getws_s(wchar_t *_Str,size_t _SizeInWords);
  __attribute__ ((dllimport)) wchar_t *__attribute__((__cdecl__)) _getws(wchar_t *_String);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _putws(const wchar_t *_Str);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fwprintf(FILE *_File,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fwprintf_s(FILE *_File,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) wprintf(const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) wprintf_s(const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scwprintf(const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vfwprintf(FILE *_File,const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vfwprintf_s(FILE *_File,const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vwprintf(const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vwprintf_s(const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) swprintf_s(wchar_t *_Dst,size_t _SizeInWords,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) vswprintf_s(wchar_t *_Dst,size_t _SizeInWords,const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _swprintf_c(wchar_t *_DstBuf,size_t _SizeInWords,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vswprintf_c(wchar_t *_DstBuf,size_t _SizeInWords,const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snwprintf_s(wchar_t *_DstBuf,size_t _DstSizeInWords,size_t _MaxCount,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnwprintf_s(wchar_t *_DstBuf,size_t _DstSizeInWords,size_t _MaxCount,const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snwprintf(wchar_t *_Dest,size_t _Count,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnwprintf(wchar_t *_Dest,size_t _Count,const wchar_t *_Format,va_list _Args);

  int __attribute__((__cdecl__)) snwprintf (wchar_t* s, size_t n, const wchar_t* format, ...);
  extern __inline__ int __attribute__((__cdecl__)) vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, va_list arg) { return _vsnwprintf(s,n,format,arg); }
  int __attribute__((__cdecl__)) vwscanf (const wchar_t *, va_list);
  int __attribute__((__cdecl__)) vfwscanf (FILE *,const wchar_t *,va_list);
  int __attribute__((__cdecl__)) vswscanf (const wchar_t *,const wchar_t *,va_list);

  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fwprintf_p(FILE *_File,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _wprintf_p(const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vfwprintf_p(FILE *_File,const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vwprintf_p(const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _swprintf_p(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vswprintf_p(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scwprintf_p(const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vscwprintf_p(const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _wprintf_l(const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _wprintf_p_l(const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _wprintf_s_l(const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vwprintf_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vwprintf_p_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vwprintf_s_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fwprintf_l(FILE *_File,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fwprintf_p_l(FILE *_File,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fwprintf_s_l(FILE *_File,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vfwprintf_l(FILE *_File,const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vfwprintf_p_l(FILE *_File,const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vfwprintf_s_l(FILE *_File,const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _swprintf_c_l(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _swprintf_p_l(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _swprintf_s_l(wchar_t *_DstBuf,size_t _DstSize,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vswprintf_c_l(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vswprintf_p_l(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vswprintf_s_l(wchar_t *_DstBuf,size_t _DstSize,const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scwprintf_l(const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _scwprintf_p_l(const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vscwprintf_p_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snwprintf_l(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snwprintf_s_l(wchar_t *_DstBuf,size_t _DstSize,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnwprintf_l(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vsnwprintf_s_l(wchar_t *_DstBuf,size_t _DstSize,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _swprintf(wchar_t *_Dest,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vswprintf(wchar_t *_Dest,const wchar_t *_Format,va_list _Args);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) __swprintf_l(wchar_t *_Dest,const wchar_t *_Format,_locale_t _Plocinfo,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) __vswprintf_l(wchar_t *_Dest,const wchar_t *_Format,_locale_t _Plocinfo,va_list _Args);
# 403 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 3
  __attribute__ ((dllimport)) wchar_t *__attribute__((__cdecl__)) _wtempnam(const wchar_t *_Directory,const wchar_t *_FilePrefix);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vscwprintf(const wchar_t *_Format,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _vscwprintf_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fwscanf(FILE *_File,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fwscanf_l(FILE *_File,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fwscanf_s_l(FILE *_File,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) swscanf(const wchar_t *_Src,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _swscanf_l(const wchar_t *_Src,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _swscanf_s_l(const wchar_t *_Src,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snwscanf(const wchar_t *_Src,size_t _MaxCount,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snwscanf_l(const wchar_t *_Src,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snwscanf_s(const wchar_t *_Src,size_t _MaxCount,const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _snwscanf_s_l(const wchar_t *_Src,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) wscanf(const wchar_t *_Format,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _wscanf_l(const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _wscanf_s_l(const wchar_t *_Format,_locale_t _Locale,...);
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) _wfdopen(int _FileHandle ,const wchar_t *_Mode);
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) _wfopen(const wchar_t *_Filename,const wchar_t *_Mode);
  __attribute__ ((dllimport)) errno_t __attribute__((__cdecl__)) _wfopen_s(FILE **_File,const wchar_t *_Filename,const wchar_t *_Mode);
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) _wfreopen(const wchar_t *_Filename,const wchar_t *_Mode,FILE *_OldFile);
  __attribute__ ((dllimport)) errno_t __attribute__((__cdecl__)) _wfreopen_s(FILE **_File,const wchar_t *_Filename,const wchar_t *_Mode,FILE *_OldFile);


  __attribute__ ((dllimport)) void __attribute__((__cdecl__)) _wperror(const wchar_t *_ErrMsg);

  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) _wpopen(const wchar_t *_Command,const wchar_t *_Mode);



  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _wremove(const wchar_t *_Filename);
  __attribute__ ((dllimport)) errno_t __attribute__((__cdecl__)) _wtmpnam_s(wchar_t *_DstBuf,size_t _SizeInWords);
  __attribute__ ((dllimport)) wchar_t *__attribute__((__cdecl__)) _wtmpnam(wchar_t *_Buffer);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) _fgetwc_nolock(FILE *_File);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) _fputwc_nolock(wchar_t _Ch,FILE *_File);
  __attribute__ ((dllimport)) wint_t __attribute__((__cdecl__)) _ungetwc_nolock(wint_t _Ch,FILE *_File);
# 469 "/usr/local/lib/gcc/x86_64-pc-mingw32/4.3.0/../../../../x86_64-pc-mingw32/include/stdio.h" 3
  __attribute__ ((dllimport)) void __attribute__((__cdecl__)) _lock_file(FILE *_File);
  __attribute__ ((dllimport)) void __attribute__((__cdecl__)) _unlock_file(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fclose_nolock(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fflush_nolock(FILE *_File);
  __attribute__ ((dllimport)) size_t __attribute__((__cdecl__)) _fread_nolock(void *_DstBuf,size_t _ElementSize,size_t _Count,FILE *_File);
  __attribute__ ((dllimport)) size_t __attribute__((__cdecl__)) _fread_nolock_s(void *_DstBuf,size_t _DstSize,size_t _ElementSize,size_t _Count,FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fseek_nolock(FILE *_File,long _Offset,int _Origin);
  __attribute__ ((dllimport)) long __attribute__((__cdecl__)) _ftell_nolock(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _fseeki64_nolock(FILE *_File,long long _Offset,int _Origin);
  __attribute__ ((dllimport)) long long __attribute__((__cdecl__)) _ftelli64_nolock(FILE *_File);
  __attribute__ ((dllimport)) size_t __attribute__((__cdecl__)) _fwrite_nolock(const void *_DstBuf,size_t _Size,size_t _Count,FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) _ungetc_nolock(int _Ch,FILE *_File);





  __attribute__ ((dllimport)) char *__attribute__((__cdecl__)) tempnam(const char *_Directory,const char *_FilePrefix);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fcloseall(void);
  __attribute__ ((dllimport)) FILE *__attribute__((__cdecl__)) fdopen(int _FileHandle,const char *_Format);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fgetchar(void);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fileno(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) flushall(void);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) fputchar(int _Ch);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) getw(FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) putw(int _Ch,FILE *_File);
  __attribute__ ((dllimport)) int __attribute__((__cdecl__)) rmtmp(void);






#pragma pack(pop)
# 2 "cbug3.c" 2



long long int save[200];
long long int savesp[200];

static volatile long long int n = 0;

inline long long int mess()
{
    long long int r = n*(n-1)*(n-1)*(n-3);
    n++;
    return r ^ 0x12345678;
}

void use_array(char *p)
{
    long long int i;
    for (i=0; i<8000; i++) *p++ = mess() & 0xff;
}

long long int may_mess_up(void)
{
    char arr[8000];
    register long long int a, b, c, d, e, f;
    a = n++;
    b = n++;
    c = n++;
    d = n++;
    e = n++;
    f = n++;
    use_array(arr);
    c = mess();
    e = mess();
    return a+b+c+d+e+f;
}

int main(int argc, char *argv[])
{
    register long long int a, b, c, d, e, f;
    long long int i = n++;
    a = n++;
    b = n++;
    c = n++;
    d = n++;
    e = n++;
    f = n++;
    printf("%llx %llx %llx %llx %llx %llx %p %llx\n", a, b, c, d, e, f, &i, i);
    fflush((&__iob_func()[1]));
    may_mess_up();
    printf("%llx %llx %llx %llx %llx %llx %p %llx\n", a, b, c, d, e, f, &i, i);

    for (i=0; i<200; i++) printf("%2lld: %llx %llx\n", i, save[i], savesp[i]);

    return 0;
}
============================================
Comment 1 Arthur Norman 2007-11-09 22:56:04 UTC
Created attachment 14522 [details]
patch to gcc/config/i386/i386.c

This tries to avoid saving regs before allocating the stack frame if the frame will be bigh enough to need probes (whihc will be a call to __stkchk) when the save_regs_using_mov option has been selected. With this you will not save the one cycle in the prologue if your frame is large, but maybe you get the right answers? My patch does this for all i386 targets and that may not be necessary since the problem that bugs me only arises if TARGET_STACK_PROBE leads to generation of a call instruction.
Comment 2 nightstrike 2007-12-11 16:10:25 UTC
This is impeding development of the x86_64-pc-mingw32 toolchain.  Is there any way to gain help on this from the gcc community?
Comment 3 Kai Tietz 2007-12-13 08:50:08 UTC
I tested this and confirm the problem. I did a regression test of this patch for x86_64-linux and x86_64-mingw32 and it was successful.
Comment 4 Kai Tietz 2008-01-02 10:48:44 UTC
Subject: Bug 34013

Author: ktietz
Date: Wed Jan  2 10:46:17 2008
New Revision: 131255

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131255
Log:
(ix86_expand_prologue): Save red-zone while stack probing.
 PR 34013.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c

Comment 5 Francois-Xavier Coudert 2008-01-30 10:04:58 UTC
(In reply to comment #4)
> Author: ktietz
> Date: Wed Jan  2 10:46:17 2008
> New Revision: 131255

Kai, did the patch fully fix the issue? If so, could you close this PR?
Comment 6 Kai Tietz 2008-01-30 11:34:27 UTC
The issue is solved.