Build gdb.opt/inline-*.exp tests at -O0, rely on __attribute__((always_inline))
authorPedro Alves <palves@redhat.com>
Tue, 19 Jul 2016 16:51:05 +0000 (17:51 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 19 Jul 2016 16:51:05 +0000 (17:51 +0100)
A test recently added to gdb.opt/inline-cmds.exp fails for
arm-none-eabi targets because -O2 leads to instructions to be
reordered widely.

I guess it might have made sense years ago to enable optimization in
these tests, but I fail to see the need for that nowadays.

Using -O0 while relying on __attribute__((always_inline)), which is
already used in the tests [1] [2], avoids this sort of trouble, while
still exercising the inlining-related use cases that are the focus of
these tests.

I think that nowadays we can safely assume that all compilers we care
about support __attribute__((always_inline)) or similar.

[1] - Except one spot that missed it.

[2] - Note that the .exp files make sure the frames that should have
      been inlined are indeed inlined, with "info frame".

gdb/testsuite/ChangeLog:
2016-07-19  Pedro Alves  <palves@redhat.com>

* gdb.opt/inline-break.exp: Remove optimize=-O2.
* gdb.opt/inline-bt.exp: Likewise.
* gdb.opt/inline-cmds.exp: Remove optimize=-O2 and add
additional_flags=-Winline.
* gdb.opt/inline-locals.exp: Likewise.
* gdb.opt/inline-markers.c (ATTR): Define.
(inlined_fn): Use it.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.opt/inline-break.exp
gdb/testsuite/gdb.opt/inline-bt.exp
gdb/testsuite/gdb.opt/inline-cmds.exp
gdb/testsuite/gdb.opt/inline-locals.exp
gdb/testsuite/gdb.opt/inline-markers.c

index c92264f6c0802b3a7398694d08f895e37d0732f7..fb1f3b12922a4d310515f43d67bc5a95ca9e142d 100644 (file)
@@ -1,3 +1,13 @@
+2016-07-19  Pedro Alves  <palves@redhat.com>
+
+       * gdb.opt/inline-break.exp: Remove optimize=-O2.
+       * gdb.opt/inline-bt.exp: Likewise.
+       * gdb.opt/inline-cmds.exp: Remove optimize=-O2 and add
+       additional_flags=-Winline.
+       * gdb.opt/inline-locals.exp: Likewise.
+       * gdb.opt/inline-markers.c (ATTR): Define.
+       (inlined_fn): Use it.
+
 2016-07-19  Yao Qi  <yao.qi@linaro.org>
 
        * gdb.gdb/selftest.exp: Remove checks on is_remote and isnative.
index b2aa22ea8969aff1f2d249a96a4c6dc31e4e619e..ac56b04da8d677a563996026e51449d7422feb6c 100644 (file)
@@ -20,7 +20,7 @@
 standard_testfile
 
 if { [prepare_for_testing $testfile.exp $testfile $srcfile \
-          {debug optimize=-O2 additional_flags=-Winline}] } {
+          {debug additional_flags=-Winline}] } {
     return -1
 }
 
index 63d76e21282d6de4e86ace9eeef3166cf8267fa3..13c69933a287e6e33f73fa7136967ec90c1378dc 100644 (file)
@@ -17,7 +17,7 @@ standard_testfile .c inline-markers.c
 
 if {[prepare_for_testing $testfile.exp $testfile \
         [list $srcfile $srcfile2] \
-        {debug optimize=-O2 additional_flags=-Winline}]} {
+        {debug additional_flags=-Winline}]} {
     return -1
 }
 
index 684f4dd0ea4a856df2b88046c4571945cab72921..6c84848f3e1daef4de88aeb2ffe97a1d4c582e81 100644 (file)
@@ -19,7 +19,7 @@ set MIFLAGS "-i=mi"
 standard_testfile .c inline-markers.c
 
 if {[prepare_for_testing $testfile.exp $testfile \
-        [list $srcfile $srcfile2] {debug optimize=-O2}]} {
+        [list $srcfile $srcfile2] {debug additional_flags=-Winline}]} {
     return -1
 }
 
index df2253aa026de27190be04f9370fca8acc0d4329..36f7ed2d74f54fc554eb64a0b6ee9c28f0b05f05 100644 (file)
@@ -16,7 +16,7 @@
 standard_testfile .c inline-markers.c
 
 if {[prepare_for_testing $testfile.exp $testfile \
-        [list $srcfile $srcfile2] {debug optimize=-O2}]} {
+        [list $srcfile $srcfile2] {debug additional_flags=-Winline}]} {
     return -1
 }
 
index cf92e79bb6c30f3821177a5b469a48ad7fe9e6c4..41f8a3822b7565960751132a0d6693b8155a408f 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#ifdef __GNUC__
+# define ATTR __attribute__((always_inline))
+#else
+# define ATTR
+#endif
+
 extern int x, y;
 extern volatile int z;
 
@@ -26,7 +32,7 @@ void marker(void)
   x += y - z; /* set breakpoint 2 here */
 }
 
-inline void inlined_fn(void)
+inline ATTR void inlined_fn(void)
 {
   x += y + z;
 }