Patchwork Add inliner related testcases

login
register
mail settings
Submitter Jan Hubicka
Date Nov. 10, 2010, 8:39 p.m.
Message ID <20101110203912.GA32454@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/70687/
State New
Headers show

Comments

Jan Hubicka - Nov. 10, 2010, 8:39 p.m.
Hi,
these PRs was fixed by ipa-reference work, but it is useful to have some testing coverage.

Honza

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 166555)
+++ ChangeLog	(working copy)
@@ -1,5 +1,12 @@ 
 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.
 
Index: gcc.dg/tree-ssa/pr33172.c
===================================================================
--- gcc.dg/tree-ssa/pr33172.c	(revision 0)
+++ gcc.dg/tree-ssa/pr33172.c	(revision 0)
@@ -0,0 +1,42 @@ 
+/* { 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" } } */
Index: g++.dg/tree-ssa/pr43411.C
===================================================================
--- g++.dg/tree-ssa/pr43411.C	(revision 0)
+++ g++.dg/tree-ssa/pr43411.C	(revision 0)
@@ -0,0 +1,29 @@ 
+/* { 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" } }