/* PR target/36533 */
|
/* PR target/36533 */
|
/* { dg-do run { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } } */
|
/* { dg-do run { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } } */
|
/* { dg-options "-Os" } */
|
/* { dg-options "-Os" } */
|
#include <string.h>
|
#include <string.h>
|
#include <sys/mman.h>
|
#include <sys/mman.h>
|
#ifndef MAP_ANONYMOUS
|
#ifndef MAP_ANONYMOUS
|
#define MAP_ANONYMOUS MAP_ANON
|
#define MAP_ANONYMOUS MAP_ANON
|
#endif
|
#endif
|
|
|
typedef struct S1
|
typedef struct S1
|
{
|
{
|
unsigned long s1;
|
unsigned long s1;
|
struct S1 *s2;
|
struct S1 *s2;
|
char *s3;
|
char *s3;
|
} S1;
|
} S1;
|
|
|
typedef struct
|
typedef struct
|
{
|
{
|
unsigned int s4;
|
unsigned int s4;
|
unsigned int s5;
|
unsigned int s5;
|
int s6;
|
int s6;
|
unsigned int *s7;
|
unsigned int *s7;
|
} S2;
|
} S2;
|
|
|
typedef struct
|
typedef struct
|
{
|
{
|
unsigned int s8;
|
unsigned int s8;
|
unsigned short s9;
|
unsigned short s9;
|
unsigned char s10;
|
unsigned char s10;
|
unsigned char s11;
|
unsigned char s11;
|
char s12[255];
|
char s12[255];
|
} S3;
|
} S3;
|
|
|
typedef struct
|
typedef struct
|
{
|
{
|
unsigned int s4;
|
unsigned int s4;
|
unsigned short s13;
|
unsigned short s13;
|
unsigned short s14;
|
unsigned short s14;
|
} S4;
|
} S4;
|
|
|
typedef struct
|
typedef struct
|
{
|
{
|
char s15[16];
|
char s15[16];
|
unsigned long s16;
|
unsigned long s16;
|
} S5;
|
} S5;
|
|
|
typedef struct
|
typedef struct
|
{
|
{
|
char s15[48];
|
char s15[48];
|
S5 *s17;
|
S5 *s17;
|
} S6;
|
} S6;
|
|
|
typedef struct
|
typedef struct
|
{
|
{
|
S1 *s18;
|
S1 *s18;
|
} S7;
|
} S7;
|
|
|
__attribute__((regparm (3), noinline)) int
|
__attribute__((regparm (3), noinline)) int
|
fn1 (const char *x, void *y, S1 *z)
|
fn1 (const char *x, void *y, S1 *z)
|
{
|
{
|
asm volatile ("" : : : "memory");
|
asm volatile ("" : : : "memory");
|
return *x + (y != 0);
|
return *x + (y != 0);
|
}
|
}
|
|
|
__attribute__((regparm (3), noinline)) int
|
__attribute__((regparm (3), noinline)) int
|
fn2 (const char *x, int y, S2 *z)
|
fn2 (const char *x, int y, S2 *z)
|
{
|
{
|
asm volatile ("" : : : "memory");
|
asm volatile ("" : : : "memory");
|
return 0;
|
return 0;
|
}
|
}
|
|
|
static inline __attribute__ ((always_inline)) unsigned int
|
static inline __attribute__ ((always_inline)) unsigned int
|
fn4 (unsigned short x)
|
fn4 (unsigned short x)
|
{
|
{
|
unsigned len = x;
|
unsigned len = x;
|
if (len == ((1 << 16) - 1))
|
if (len == ((1 << 16) - 1))
|
return 1 << 16;
|
return 1 << 16;
|
return len;
|
return len;
|
}
|
}
|
|
|
static inline __attribute__ ((always_inline)) S3 *
|
static inline __attribute__ ((always_inline)) S3 *
|
fn3 (S3 *p)
|
fn3 (S3 *p)
|
{
|
{
|
return (S3 *) ((char *) p + fn4 (p->s9));
|
return (S3 *) ((char *) p + fn4 (p->s9));
|
}
|
}
|
|
|
__attribute__((regparm (3), noinline)) int
|
__attribute__((regparm (3), noinline)) int
|
fn5 (void)
|
fn5 (void)
|
{
|
{
|
asm volatile ("" : : : "memory");
|
asm volatile ("" : : : "memory");
|
return 0;
|
return 0;
|
}
|
}
|
|
|
static inline __attribute__ ((always_inline)) int
|
static inline __attribute__ ((always_inline)) int
|
fn6 (S3 *w, int x, S2 *y, S4 *z)
|
fn6 (S3 *w, int x, S2 *y, S4 *z)
|
{
|
{
|
int a = 2;
|
int a = 2;
|
char *b = (char *) w;
|
char *b = (char *) w;
|
S2 c = *y;
|
S2 c = *y;
|
|
|
while ((char *) w < b + x - 2 * sizeof (S4))
|
while ((char *) w < b + x - 2 * sizeof (S4))
|
{
|
{
|
if (w->s10 && w->s8)
|
if (w->s10 && w->s8)
|
{
|
{
|
fn2 (w->s12, w->s10, &c);
|
fn2 (w->s12, w->s10, &c);
|
z--;
|
z--;
|
z->s4 = c.s4;
|
z->s4 = c.s4;
|
z->s13 = (unsigned short) ((char *) w - b);
|
z->s13 = (unsigned short) ((char *) w - b);
|
z->s14 = w->s9;
|
z->s14 = w->s9;
|
a++;
|
a++;
|
fn5 ();
|
fn5 ();
|
}
|
}
|
|
|
w = fn3 (w);
|
w = fn3 (w);
|
}
|
}
|
return a;
|
return a;
|
}
|
}
|
|
|
__attribute__((regparm (3), noinline)) unsigned int
|
__attribute__((regparm (3), noinline)) unsigned int
|
test (void *u, S6 *v, S1 **w, S7 *x, S2 *y, S1 *z)
|
test (void *u, S6 *v, S1 **w, S7 *x, S2 *y, S1 *z)
|
{
|
{
|
unsigned b = v->s17->s16;
|
unsigned b = v->s17->s16;
|
unsigned a;
|
unsigned a;
|
S4 *c;
|
S4 *c;
|
unsigned d, e, f, i;
|
unsigned d, e, f, i;
|
|
|
fn1 (__func__, u, x->s18);
|
fn1 (__func__, u, x->s18);
|
c = (S4 *) (z->s3 + b);
|
c = (S4 *) (z->s3 + b);
|
a = fn6 ((S3 *) (*w)->s3, b, y, c);
|
a = fn6 ((S3 *) (*w)->s3, b, y, c);
|
c -= a;
|
c -= a;
|
f = 0;
|
f = 0;
|
e = 2;
|
e = 2;
|
for (i = a - 1; ; i--)
|
for (i = a - 1; ; i--)
|
{
|
{
|
if (f + (unsigned short) (c[i].s14 / 2) > b / 2)
|
if (f + (unsigned short) (c[i].s14 / 2) > b / 2)
|
break;
|
break;
|
f += c[i].s14;
|
f += c[i].s14;
|
e++;
|
e++;
|
}
|
}
|
d = a - e;
|
d = a - e;
|
return c[d].s4;
|
return c[d].s4;
|
}
|
}
|
|
|
int main (void)
|
int main (void)
|
{
|
{
|
char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
|
char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
S1 wb, z, *w;
|
S1 wb, z, *w;
|
S6 v;
|
S6 v;
|
S7 x;
|
S7 x;
|
S2 y;
|
S2 y;
|
S5 vb;
|
S5 vb;
|
S4 s4;
|
S4 s4;
|
if (p == MAP_FAILED)
|
if (p == MAP_FAILED)
|
return 0;
|
return 0;
|
if (munmap (p + 65536, 65536) < 0)
|
if (munmap (p + 65536, 65536) < 0)
|
return 0;
|
return 0;
|
memset (&wb, 0, sizeof (wb));
|
memset (&wb, 0, sizeof (wb));
|
memset (&z, 0, sizeof (z));
|
memset (&z, 0, sizeof (z));
|
memset (&v, 0, sizeof (v));
|
memset (&v, 0, sizeof (v));
|
memset (&x, 0, sizeof (x));
|
memset (&x, 0, sizeof (x));
|
memset (&y, 0, sizeof (y));
|
memset (&y, 0, sizeof (y));
|
memset (&vb, 0, sizeof (vb));
|
memset (&vb, 0, sizeof (vb));
|
memset (&s4, 0, sizeof (s4));
|
memset (&s4, 0, sizeof (s4));
|
s4.s14 = 254;
|
s4.s14 = 254;
|
z.s3 = p + 65536 - 2 * sizeof (S4);
|
z.s3 = p + 65536 - 2 * sizeof (S4);
|
w = &wb;
|
w = &wb;
|
v.s17 = &vb;
|
v.s17 = &vb;
|
vb.s16 = 2 * sizeof (S4);
|
vb.s16 = 2 * sizeof (S4);
|
memcpy (z.s3, &s4, sizeof (s4));
|
memcpy (z.s3, &s4, sizeof (s4));
|
memcpy (z.s3 + sizeof (s4), &s4, sizeof (s4));
|
memcpy (z.s3 + sizeof (s4), &s4, sizeof (s4));
|
test ((void *) 0, &v, &w, &x, &y, &z);
|
test ((void *) 0, &v, &w, &x, &y, &z);
|
return 0;
|
return 0;
|
}
|
}
|
|
|