Commit f65cf2b7 by Martin Jambor Committed by Martin Jambor

re PR tree-optimization/45934 (g++.old-deja/g++.other/dtor5.C FAILs with -finline-small-functions)

2011-01-14  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/45934
	PR tree-optimization/46302
	* ipa-prop.c (type_change_info): New type.
	(stmt_may_be_vtbl_ptr_store): New function.
	(check_stmt_for_type_change): Likewise.
	(detect_type_change): Likewise.
	(detect_type_change_ssa): Likewise.
	(compute_complex_assign_jump_func): Check for dynamic type change.
	(compute_complex_ancestor_jump_func): Likewise.
	(compute_known_type_jump_func): Likewise.
	(compute_scalar_jump_functions): Likewise.
	(ipa_analyze_virtual_call_uses): Likewise.
	(ipa_analyze_node): Push and pop cfun, set current_function_decl.

	* testsuite/g++.dg/ipa/devirt-c-1.C: New test.
	* testsuite/g++.dg/ipa/devirt-c-2.C: Likewise.
	* testsuite/g++.dg/ipa/devirt-c-3.C: Likewise.
	* testsuite/g++.dg/ipa/devirt-c-4.C: Likewise.
	* testsuite/g++.dg/ipa/devirt-c-5.C: Likewise.
	* testsuite/g++.dg/ipa/devirt-c-6.C: Likewise.
	* testsuite/g++.dg/ipa/devirt-6.C: Likewise.
	* testsuite/g++.dg/ipa/devirt-d-1.C: Likewise.
	* testsuite/g++.dg/torture/pr45934.C: Likewise.

From-SVN: r168825
parent dc0d2dae
2011-01-14 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/45934
PR tree-optimization/46302
* ipa-prop.c (type_change_info): New type.
(stmt_may_be_vtbl_ptr_store): New function.
(check_stmt_for_type_change): Likewise.
(detect_type_change): Likewise.
(detect_type_change_ssa): Likewise.
(compute_complex_assign_jump_func): Check for dynamic type change.
(compute_complex_ancestor_jump_func): Likewise.
(compute_known_type_jump_func): Likewise.
(compute_scalar_jump_functions): Likewise.
(ipa_analyze_virtual_call_uses): Likewise.
(ipa_analyze_node): Push and pop cfun, set current_function_decl.
2011-01-14 Joseph Myers <joseph@codesourcery.com>
* config/i386/i386.h (CC1_CPU_SPEC_1): Don't handle -msse5.
......
2011-01-14 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/45934
PR tree-optimization/46302
* g++.dg/ipa/devirt-c-1.C: New test.
* g++.dg/ipa/devirt-c-2.C: Likewise.
* g++.dg/ipa/devirt-c-3.C: Likewise.
* g++.dg/ipa/devirt-c-4.C: Likewise.
* g++.dg/ipa/devirt-c-5.C: Likewise.
* g++.dg/ipa/devirt-c-6.C: Likewise.
* g++.dg/ipa/devirt-6.C: Likewise.
* g++.dg/ipa/devirt-d-1.C: Likewise.
* g++.dg/torture/pr45934.C: Likewise.
2011-01-14 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/variadic105.C: New.
......
/* Verify that we either do not do any devirtualization or correctly
spot that foo changes the dynamic type of the passed object. */
/* { dg-do run } */
/* { dg-options "-O3" } */
extern "C" void abort (void);
extern "C" void *malloc(__SIZE_TYPE__);
inline void* operator new(__SIZE_TYPE__, void* __p) throw() { return __p;}
int x;
class A {
public:
virtual ~A() { }
};
class B : public A {
public:
virtual ~B() { if (x == 1) abort (); x = 1; }
};
void __attribute__((noinline,noclone)) foo (void *p)
{
B *b = reinterpret_cast<B *>(p);
b->~B();
new (p) A;
}
int main()
{
void *p = __builtin_malloc (sizeof (B));
new (p) B;
foo(p);
reinterpret_cast<A *>(p)->~A();
return 0;
}
/* Verify that ipa-cp correctly detects the dynamic type of an object
under construction when doing devirtualization. */
/* { dg-do run } */
/* { dg-options "-O3 -fno-early-inlining -fno-inline" } */
extern "C" void abort (void);
class A
{
public:
int data;
A();
virtual int foo (int i);
};
class B : public A
{
public:
virtual int foo (int i);
};
class C : public A
{
public:
virtual int foo (int i);
};
int A::foo (int i)
{
return i + 1;
}
int B::foo (int i)
{
return i + 2;
}
int C::foo (int i)
{
return i + 3;
}
static int middleman (class A *obj, int i)
{
return obj->foo (i);
}
int __attribute__ ((noinline,noclone)) get_input(void)
{
return 1;
}
A::A ()
{
if (middleman (this, get_input ()) != 2)
abort ();
}
static void bah ()
{
class B b;
}
int main (int argc, char *argv[])
{
int i;
for (i = 0; i < 10; i++)
bah ();
return 0;
}
/* Verify that ipa-cp correctly detects the dynamic type of an object
under construction when doing devirtualization. */
/* { dg-do run } */
/* { dg-options "-O3 -fno-early-inlining -fno-inline" } */
extern "C" void abort (void);
class Distraction
{
public:
float f;
double d;
Distraction ()
{
f = 8.3;
d = 10.2;
}
virtual float bar (float z);
};
class A
{
public:
int data;
A();
virtual int foo (int i);
};
class B : public Distraction, public A
{
public:
virtual int foo (int i);
};
float Distraction::bar (float z)
{
f += z;
return f/2;
}
int A::foo (int i)
{
return i + 1;
}
int B::foo (int i)
{
return i + 2;
}
int __attribute__ ((noinline,noclone)) get_input(void)
{
return 1;
}
static int middleman (class A *obj, int i)
{
return obj->foo (i);
}
A::A()
{
if (middleman (this, get_input ()) != 2)
abort ();
}
static void bah ()
{
class B b;
}
int main (int argc, char *argv[])
{
int i;
for (i = 0; i < 10; i++)
bah ();
return 0;
}
/* Verify that ipa-cp correctly detects the dynamic type of an object
under construction when doing devirtualization. */
/* { dg-do run } */
/* { dg-options "-O3 -fno-inline" } */
extern "C" void abort (void);
class Distraction
{
public:
float f;
double d;
Distraction ()
{
f = 8.3;
d = 10.2;
}
virtual float bar (float z);
};
class A
{
public:
int data;
A();
virtual int foo (int i);
};
class B : public Distraction, public A
{
public:
virtual int foo (int i);
};
float Distraction::bar (float z)
{
f += z;
return f/2;
}
int A::foo (int i)
{
return i + 1;
}
int B::foo (int i)
{
return i + 2;
}
int __attribute__ ((noinline,noclone)) get_input(void)
{
return 1;
}
static int __attribute__ ((noinline))
middleman (class A *obj, int i)
{
return obj->foo (i);
}
inline __attribute__ ((always_inline)) A::A()
{
if (middleman (this, get_input ()) != 2)
abort ();
}
static void bah ()
{
class B b;
}
int main (int argc, char *argv[])
{
int i;
for (i = 0; i < 10; i++)
bah ();
return 0;
}
/* Verify that ipa-cp correctly detects the dynamic type of an object
under construction when doing devirtualization. */
/* { dg-do run } */
/* { dg-options "-O3 -fno-inline" } */
extern "C" void abort (void);
class Distraction
{
public:
float f;
double d;
Distraction ()
{
f = 8.3;
d = 10.2;
}
virtual float bar (float z);
};
class A
{
public:
int data;
A();
virtual int foo (int i);
};
class B : public Distraction, public A
{
public:
B();
virtual int foo (int i);
};
class C : public B
{
public:
virtual int foo (int i);
};
float Distraction::bar (float z)
{
f += z;
return f/2;
}
int A::foo (int i)
{
return i + 1;
}
int B::foo (int i)
{
return i + 2;
}
int C::foo (int i)
{
return i + 3;
}
int __attribute__ ((noinline,noclone)) get_input(void)
{
return 1;
}
static int __attribute__ ((noinline))
middleman (class A *obj, int i)
{
return obj->foo (i);
}
static void __attribute__ ((noinline))
sth2 (A *a)
{
if (a->foo (get_input ()) != 3)
abort ();
}
inline void __attribute__ ((always_inline)) sth1 (B *b)
{
sth2 (b);
}
inline __attribute__ ((always_inline)) A::A()
{
if (middleman (this, get_input ()) != 2)
abort ();
}
B::B() : Distraction(), A()
{
sth1 (this);
}
static void bah ()
{
class C c;
}
int main (int argc, char *argv[])
{
int i;
for (i = 0; i < 10; i++)
bah ();
return 0;
}
/* Verify that ipa-cp correctly detects the dynamic type of an object
under construction when doing devirtualization. */
/* { dg-do run } */
/* { dg-options "-O3 -fno-early-inlining -fno-inline" } */
extern "C" void abort (void);
class B;
class A
{
public:
int data;
A();
A(B *b);
virtual int foo (int i);
};
class B : public A
{
public:
virtual int foo (int i);
};
class C : public A
{
public:
virtual int foo (int i);
};
int A::foo (int i)
{
return i + 1;
}
int B::foo (int i)
{
return i + 2;
}
int C::foo (int i)
{
return i + 3;
}
static int middleman (class A *obj, int i)
{
return obj->foo (i);
}
int __attribute__ ((noinline,noclone)) get_input(void)
{
return 1;
}
A::A ()
{
}
A::A (B *b)
{
if (middleman (b, get_input ()) != 3)
abort ();
}
static void bah ()
{
B b;
A a(&b);
}
int main (int argc, char *argv[])
{
int i;
for (i = 0; i < 10; i++)
bah ();
return 0;
}
/* Verify that ipa-cp correctly detects the dynamic type of an object
under construction when doing devirtualization. */
/* { dg-do run } */
/* { dg-options "-O3 -fno-inline" } */
extern "C" void abort (void);
class A
{
public:
int data;
A();
virtual int foo (int i);
};
class B : public A
{
public:
virtual int foo (int i);
};
class C : public A
{
public:
virtual int foo (int i);
};
int A::foo (int i)
{
return i + 1;
}
int B::foo (int i)
{
return i + 2;
}
int C::foo (int i)
{
return i + 3;
}
static inline int __attribute__ ((always_inline))
middleman (class A *obj, int i)
{
return obj->foo (i);
}
int __attribute__ ((noinline,noclone)) get_input(void)
{
return 1;
}
__attribute__ ((noinline)) A::A ()
{
if (middleman (this, get_input ()) != 2)
abort ();
}
static void bah ()
{
class B b;
}
int main (int argc, char *argv[])
{
int i;
for (i = 0; i < 10; i++)
bah ();
return 0;
}
/* Verify that ipa-cp correctly detects the dynamic type of an object
under destruction when doing devirtualization. */
/* { dg-do run } */
/* { dg-options "-O3 -fno-early-inlining -fno-inline" } */
extern "C" void abort (void);
class A
{
public:
int data;
~A();
virtual int foo (int i);
};
class B : public A
{
public:
virtual int foo (int i);
};
class C : public A
{
public:
virtual int foo (int i);
};
int A::foo (int i)
{
return i + 1;
}
int B::foo (int i)
{
return i + 2;
}
int C::foo (int i)
{
return i + 3;
}
static int middleman (class A *obj, int i)
{
return obj->foo (i);
}
int __attribute__ ((noinline,noclone)) get_input(void)
{
return 1;
}
A::~A ()
{
if (middleman (this, get_input ()) != 2)
abort ();
}
static void bah ()
{
class B b;
}
int main (int argc, char *argv[])
{
int i;
for (i = 0; i < 10; i++)
bah ();
return 0;
}
/* { dg-do run } */
extern "C" void abort ();
struct B *b;
struct B
{
virtual void f () { }
~B() { b->f(); }
};
struct D : public B
{
virtual void f () { abort (); }
};
int main ()
{
D d;
b = &d;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment