From patchwork Fri Jul 1 12:05:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 13549 Received: (qmail 50130 invoked by alias); 1 Jul 2016 12:05:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 49505 invoked by uid 89); 1 Jul 2016 12:05:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=exercising, Except X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 01 Jul 2016 12:05:38 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D784804E3; Fri, 1 Jul 2016 12:05:37 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u61C5aV8019514; Fri, 1 Jul 2016 08:05:36 -0400 Subject: [PATCH] Build gdb.opt/inline-*.exp tests at -O0, rely on __attribute__((always_inline)) (was: Re: [PATCH v3 24/34] Push thread->control.command_interp to the struct thread_fsm) To: Thomas Preudhomme References: <1462538104-19109-25-git-send-email-palves@redhat.com> <8587009.ikB25uYBLk@e108577-lin> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <20144b4c-11ee-fc84-e3ad-b9992f14ce15@redhat.com> Date: Fri, 1 Jul 2016 13:05:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <8587009.ikB25uYBLk@e108577-lin> On 07/01/2016 12:02 PM, Thomas Preudhomme wrote: > The new tests added by this patch fail for arm-none-eabi targets because -O2 > leads to instructions to be reordered widely. In this case, the instruction > that follows the first one for line 64 is related to line 70 so the test is > failing. Shouldn't this test be compiled with -Og and probably also -finline- > small-functions -findirect-inlining -fpartial-inlining which relates to > inlining and are included in -O2. Or even just plain -O0. See the commit log below. WDYT? -------------- Subject: [PATCH] Build gdb.opt/inline-*.exp tests at -O0, rely on __attribute__((always_inline)) 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-01 Pedro Alves * 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/gdb.opt/inline-break.exp | 2 +- gdb/testsuite/gdb.opt/inline-bt.exp | 2 +- gdb/testsuite/gdb.opt/inline-cmds.exp | 2 +- gdb/testsuite/gdb.opt/inline-locals.exp | 2 +- gdb/testsuite/gdb.opt/inline-markers.c | 8 +++++++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.opt/inline-break.exp b/gdb/testsuite/gdb.opt/inline-break.exp index b2aa22e..ac56b04 100644 --- a/gdb/testsuite/gdb.opt/inline-break.exp +++ b/gdb/testsuite/gdb.opt/inline-break.exp @@ -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 } diff --git a/gdb/testsuite/gdb.opt/inline-bt.exp b/gdb/testsuite/gdb.opt/inline-bt.exp index 63d76e2..13c6993 100644 --- a/gdb/testsuite/gdb.opt/inline-bt.exp +++ b/gdb/testsuite/gdb.opt/inline-bt.exp @@ -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 } diff --git a/gdb/testsuite/gdb.opt/inline-cmds.exp b/gdb/testsuite/gdb.opt/inline-cmds.exp index 684f4dd..6c84848 100644 --- a/gdb/testsuite/gdb.opt/inline-cmds.exp +++ b/gdb/testsuite/gdb.opt/inline-cmds.exp @@ -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 } diff --git a/gdb/testsuite/gdb.opt/inline-locals.exp b/gdb/testsuite/gdb.opt/inline-locals.exp index df2253a..36f7ed2 100644 --- a/gdb/testsuite/gdb.opt/inline-locals.exp +++ b/gdb/testsuite/gdb.opt/inline-locals.exp @@ -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 } diff --git a/gdb/testsuite/gdb.opt/inline-markers.c b/gdb/testsuite/gdb.opt/inline-markers.c index cf92e79..41f8a38 100644 --- a/gdb/testsuite/gdb.opt/inline-markers.c +++ b/gdb/testsuite/gdb.opt/inline-markers.c @@ -13,6 +13,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#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; }