This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: gcc svn trunk -vs- inlining tests


I am checking this in on the trunk and the 7.2 branch.

svn trunk gcc doesn't inline functions from the gdb.opt inlining tests
the way that the tests expect.  I think this is because GCC now knows
that main is only called once, but I am not positive.

This patch fixes the problem by applying the always_inline attribute to
the needed functions.  This is ok because the tests are only actually
run when they are compiled with a new-enough GCC (though this is not
known at compilation time -- hence the macros).  Jakub verified that
always_inline is old enough that we can rely on it.

Built and regtested on x86-64 (compile farm).  That tested the old
compiler.  I also ran the needed tests locally with both my system GCC
and svn trunk.

Tom

2010-07-27  Tom Tromey  <tromey@redhat.com>

	* gdb.opt/inline-cmds.c (ATTR): New define.
	(func1): Use it.
	(func2): Likewise.
	(func3): Likewise.
	(outer_inline1): Likewise.
	(outer_inline2): Likewise.
	* gdb.opt/inline-bt.c (ATTR): New define.
	(func1): Use it.
	(func2): Likewise.
	* gdb.opt/inline-locals.c (ATTR): New define.
	(func1): Use it.
	(func2): Likewise.

Index: gdb.opt/inline-bt.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.opt/inline-bt.c,v
retrieving revision 1.2
diff -u -r1.2 inline-bt.c
--- gdb.opt/inline-bt.c	1 Jan 2010 07:32:04 -0000	1.2
+++ gdb.opt/inline-bt.c	27 Jul 2010 18:01:05 -0000
@@ -13,18 +13,27 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This is only ever run if it is compiled with a new-enough GCC, but
+   we don't want the compilation to fail if compiled by some other
+   compiler.  */
+#ifdef __GNUC__
+#define ATTR __attribute__((always_inline))
+#else
+#define ATTR
+#endif
+
 int x, y;
 volatile int result;
 
 void bar(void);
 
-inline int func1(void)
+inline ATTR int func1(void)
 {
   bar ();
   return x * y;
 }
 
-inline int func2(void)
+inline ATTR int func2(void)
 {
   return x * func1 ();
 }
Index: gdb.opt/inline-bt.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.opt/inline-bt.exp,v
retrieving revision 1.2
diff -u -r1.2 inline-bt.exp
--- gdb.opt/inline-bt.exp	1 Jan 2010 07:32:04 -0000	1.2
+++ gdb.opt/inline-bt.exp	27 Jul 2010 18:01:05 -0000
@@ -22,7 +22,7 @@
 set binfile ${objdir}/${subdir}/${testfile}
 
 if  { [gdb_compile ${sources} ${binfile} \
-	   executable {debug optimize=-O2}] != "" } {
+	   executable {debug optimize=-O2 additional_flags=-Winline}] != "" } {
     untested inline-bt.exp
     return -1
 }
Index: gdb.opt/inline-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.opt/inline-cmds.c,v
retrieving revision 1.2
diff -u -r1.2 inline-cmds.c
--- gdb.opt/inline-cmds.c	1 Jan 2010 07:32:04 -0000	1.2
+++ gdb.opt/inline-cmds.c	27 Jul 2010 18:01:05 -0000
@@ -13,6 +13,15 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This is only ever run if it is compiled with a new-enough GCC, but
+   we don't want the compilation to fail if compiled by some other
+   compiler.  */
+#ifdef __GNUC__
+#define ATTR __attribute__((always_inline))
+#else
+#define ATTR
+#endif
+
 int x, y;
 volatile int result;
 
@@ -20,28 +29,28 @@
 void marker(void);
 void noinline(void);
 
-inline int func1(void)
+inline ATTR int func1(void)
 {
   bar ();
   return x * y;
 }
 
-inline int func2(void)
+inline ATTR int func2(void)
 {
   return x * func1 ();
 }
 
-inline void func3(void)
+inline ATTR void func3(void)
 {
   bar ();
 }
 
-inline void outer_inline1(void)
+inline ATTR void outer_inline1(void)
 {
   noinline ();
 }
 
-inline void outer_inline2(void)
+inline ATTR void outer_inline2(void)
 {
   outer_inline1 ();
 }
Index: gdb.opt/inline-locals.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.opt/inline-locals.c,v
retrieving revision 1.2
diff -u -r1.2 inline-locals.c
--- gdb.opt/inline-locals.c	1 Jan 2010 07:32:04 -0000	1.2
+++ gdb.opt/inline-locals.c	27 Jul 2010 18:01:05 -0000
@@ -13,13 +13,22 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This is only ever run if it is compiled with a new-enough GCC, but
+   we don't want the compilation to fail if compiled by some other
+   compiler.  */
+#ifdef __GNUC__
+#define ATTR __attribute__((always_inline))
+#else
+#define ATTR
+#endif
+
 int x, y;
 volatile int result;
 volatile int *array_p;
 
 void bar(void);
 
-inline int func1(int arg1)
+inline ATTR int func1(int arg1)
 {
   int array[64];
   array_p = array;
@@ -29,7 +38,7 @@
   return x * y + array_p[0] * arg1;
 }
 
-inline int func2(int arg2)
+inline ATTR int func2(int arg2)
 {
   return x * func1 (arg2);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]