From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122903 invoked by alias); 11 Mar 2019 09:37:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 122895 invoked by uid 89); 11 Mar 2019 09:37:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-13.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=20190211 X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Mar 2019 09:37:09 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4B550AB91 for ; Mon, 11 Mar 2019 09:37:07 +0000 (UTC) Subject: Re: GCC 8 backports From: =?UTF-8?Q?Martin_Li=c5=a1ka?= To: GCC Patches References: <9a21556a-0c16-c31a-f188-a75077c36bfa@suse.cz> <32e46ac2-3865-1b46-93bf-5ada7f8ff4e2@suse.cz> <7387d688-1a77-db9e-7318-c5a8c214bf09@suse.cz> <1620d43c-b6f7-46d6-8222-abf3bc5b6be1@suse.cz> <1c3a5eef-56fb-bd88-c82d-8e0cb2d0f9cb@suse.cz> Message-ID: <59f9c249-8a2b-23d6-a66d-3d7c6ea0c250@suse.cz> Date: Mon, 11 Mar 2019 09:39:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 MIME-Version: 1.0 In-Reply-To: <1c3a5eef-56fb-bd88-c82d-8e0cb2d0f9cb@suse.cz> Content-Type: multipart/mixed; boundary="------------4DD6C165352883BE66D2F1AC" X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00475.txt.bz2 This is a multi-part message in MIME format. --------------4DD6C165352883BE66D2F1AC Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 64 Hi. I'm sending another patches that I've just tested. Martin --------------4DD6C165352883BE66D2F1AC Content-Type: text/x-patch; name="0004-Backport-r269558.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0004-Backport-r269558.patch" Content-length: 1158 >From 915af267eb22e5059737f4dbb6e9d48601bb0779 Mon Sep 17 00:00:00 2001 From: "ro@138bc75d-0d04-0410-961f-82ee72b054a4" Date: Sun, 10 Mar 2019 16:43:48 +0000 Subject: [PATCH 4/4] Backport r269558 gcc/testsuite/ChangeLog: 2019-03-10 Rainer Orth * gcc.target/i386/indirect-thunk-extern-7.c: Add -fjump-tables to dg-options. --- gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c index b7339745116..95c5cc176ae 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic -fjump-tables" } */ void func0 (void); void func1 (void); -- 2.21.0 --------------4DD6C165352883BE66D2F1AC Content-Type: text/x-patch; name="0003-Backport-r269492.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0003-Backport-r269492.patch" Content-length: 2650 >From 5a433aca1d83cfc8a270b02d89be5b3ed75a503c Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 8 Mar 2019 12:55:40 +0000 Subject: [PATCH 3/4] Backport r269492 gcc/ChangeLog: 2019-03-08 Martin Liska PR target/86952 * config/i386/i386.c (ix86_option_override_internal): Disable jump tables when retpolines are used. gcc/testsuite/ChangeLog: 2019-03-08 Martin Liska PR target/86952 * gcc.target/i386/indirect-thunk-7.c: Use jump tables to match scanned pattern. * gcc.target/i386/indirect-thunk-inline-7.c: Likewise. --- gcc/config/i386/i386.c | 6 ++++++ gcc/testsuite/gcc.target/i386/indirect-thunk-7.c | 2 +- gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a88a29b51e6..f1de97f73df 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4958,6 +4958,12 @@ ix86_option_override_internal (bool main_args_p, opts->x_param_values, opts_set->x_param_values); + /* PR86952: jump table usage with retpolines is slow. + The PR provides some numbers about the slowness. */ + if (ix86_indirect_branch != indirect_branch_keep + && !opts_set->x_flag_jump_tables) + opts->x_flag_jump_tables = 0; + return true; } diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c index 3c72036dbaf..53868f46558 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic -fjump-tables" } */ void func0 (void); void func1 (void); diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c index ea009245a58..e6f064959a1 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic -fjump-tables" } */ void func0 (void); void func1 (void); -- 2.21.0 --------------4DD6C165352883BE66D2F1AC Content-Type: text/x-patch; name="0002-Backport-r268981.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Backport-r268981.patch" Content-length: 1127 >From 4a20f76e3887229751ebd8352cc3c77a4e7c2b10 Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 18 Feb 2019 09:46:19 +0000 Subject: [PATCH 2/4] Backport r268981 libcpp/ChangeLog: 2019-02-18 Martin Liska PR c++/89383 * line-map.c (linemap_line_start): Use 1UL in order to not overflow. --- libcpp/line-map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcpp/line-map.c b/libcpp/line-map.c index 42aecd6993f..72fe2c0dcec 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -758,7 +758,8 @@ linemap_line_start (struct line_maps *set, linenum_type to_line, || ( /* We can't reuse the map if the line offset is sufficiently large to cause overflow when computing location_t values. */ (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map)) - >= (1U << (CHAR_BIT * sizeof (linenum_type) - column_bits))) + >= (((uint64_t) 1) + << (CHAR_BIT * sizeof (linenum_type) - column_bits))) || range_bits < map->m_range_bits) map = linemap_check_ordinary (const_cast -- 2.21.0 --------------4DD6C165352883BE66D2F1AC Content-Type: text/x-patch; name="0001-Backport-r268789.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Backport-r268789.patch" Content-length: 3134 >From fe9fa030d7ae1a4b4da4751b39bddc68395b1728 Mon Sep 17 00:00:00 2001 From: dmalcolm Date: Tue, 12 Feb 2019 01:09:31 +0000 Subject: [PATCH 1/4] Backport r268789 gcc/ChangeLog: 2019-02-11 David Malcolm PR lto/88147 * input.c (selftest::test_line_offset_overflow): New selftest. (selftest::input_c_tests): Call it. libcpp/ChangeLog: 2019-02-11 Martin Liska PR lto/88147 * line-map.c (linemap_line_start): Don't reuse the existing line map if the line offset is sufficiently large to cause overflow when computing location_t values. --- gcc/input.c | 30 ++++++++++++++++++++++++++++++ libcpp/line-map.c | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/gcc/input.c b/gcc/input.c index b6675768722..26c2bf21d52 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -3538,6 +3538,34 @@ for_each_line_table_case (void (*testcase) (const line_table_case &)) ASSERT_EQ (num_cases_tested, 2 * 12); } +/* Verify that when presented with a consecutive pair of locations with + a very large line offset, we don't attempt to consolidate them into + a single ordinary linemap where the line offsets within the line map + would lead to overflow (PR lto/88147). */ + +static void +test_line_offset_overflow () +{ + line_table_test ltt (line_table_case (5, 0)); + + linemap_add (line_table, LC_ENTER, false, "foo.c", 0); + linemap_line_start (line_table, 1, 100); + location_t loc_a = linemap_line_start (line_table, 2578, 255); + assert_loceq ("foo.c", 2578, 0, loc_a); + + const line_map_ordinary *ordmap_a = LINEMAPS_LAST_ORDINARY_MAP (line_table); + ASSERT_EQ (ordmap_a->m_column_and_range_bits, 13); + ASSERT_EQ (ordmap_a->m_range_bits, 5); + + location_t loc_b = linemap_line_start (line_table, 404198, 512); + assert_loceq ("foo.c", 404198, 0, loc_b); + + /* We should have started a new linemap, rather than attempting to store + a very large line offset. */ + const line_map_ordinary *ordmap_b = LINEMAPS_LAST_ORDINARY_MAP (line_table); + ASSERT_NE (ordmap_a, ordmap_b); +} + /* Run all of the selftests within this file. */ void @@ -3577,6 +3605,8 @@ input_c_tests () for_each_line_table_case (test_lexer_char_constants); test_reading_source_line (); + + test_line_offset_overflow (); } } // namespace selftest diff --git a/libcpp/line-map.c b/libcpp/line-map.c index a84084c99f0..42aecd6993f 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -755,6 +755,10 @@ linemap_line_start (struct line_maps *set, linenum_type to_line, if (line_delta < 0 || last_line != ORDINARY_MAP_STARTING_LINE_NUMBER (map) || SOURCE_COLUMN (map, highest) >= (1U << (column_bits - range_bits)) + || ( /* We can't reuse the map if the line offset is sufficiently + large to cause overflow when computing location_t values. */ + (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map)) + >= (1U << (CHAR_BIT * sizeof (linenum_type) - column_bits))) || range_bits < map->m_range_bits) map = linemap_check_ordinary (const_cast -- 2.21.0 --------------4DD6C165352883BE66D2F1AC--