Commit edb29996 by Jan Hubicka Committed by Jan Hubicka

re PR rtl-optimization/33172 (Optimizer fails to elid away unreferenced static function)


	PR tree-optimize/33172
	PR tree-optimize/43411
	* gcc.dg/tree-ssa/pr33172.c: New testcase.
	* g++.dg/tree-ssa/pr43411.C: New testcase.

From-SVN: r166557
parent b6173d50
2010-11-10 Jan Hubicka <jh@suse.cz>
PR tree-optimize/33172
PR tree-optimize/43411
* gcc.dg/tree-ssa/pr33172.c: New testcase.
* g++.dg/tree-ssa/pr43411.C: New testcase.
2010-11-10 Jan Hubicka <jh@suse.cz>
PR tree-optimize/46228
* g++.dg/tree-ssa/pr46228.C: New testcase.
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
class P { public: virtual int val() { return 123; } };
class Psub : public P { };
extern int sink1, sink2;
void test() {
Psub p;
P &pRef = p;
sink1 = p.val();
sink2 = pRef.val();
}
inline int v(P &p) { return p.val(); }
void testInlineP() {
P p;
sink1 = v(p);
}
void testInlinePsub() {
Psub p;
sink1 = v(p);
}
// { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } }
// { dg-final { cleanup-tree-dump "optimized" } }
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
struct abc {
void (*abc_call)(void);
};
/*
* Use only any one of the three definitions below at a time:
*
* 1. nothing optimized away. Good.
* 2. call_func() _not_ optimized away, but struct xyz is. gcc disappoints.
* 3. both call_func() and struct xyz optimized away. Nice.
*/
/* 1 */
/*extern int do_register(struct abc *xyz);*/
/* 2 */
static inline int do_register(struct abc *xyz)
{
return 0;
}
/* 3 */
/*#define do_register(xyz) do { (void)(xyz); } while (0)*/
static void call_func(void)
{
}
static struct abc xyz = {
.abc_call = call_func,
};
void func(void)
{
do_register(&xyz);
}
/* { dg-final { scan-tree-dump-not "call_func" "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
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