From: "Martin Liška" <mliska@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: GCC 7 backport
Date: Mon, 11 Mar 2019 11:23:00 -0000 [thread overview]
Message-ID: <ef0e5698-97f6-7718-28cd-eabd4128e5b6@suse.cz> (raw)
In-Reply-To: <c2b85d8a-4eb2-facc-37c0-79d03b26d51a@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 62 bytes --]
Hi.
Another 2 patches that I've just tested.
Thanks,
Martin
[-- Attachment #2: 0002-Backport-r268981.patch --]
[-- Type: text/x-patch, Size: 1126 bytes --]
From a4ec4d12444bc2fed3fbf559d6cae4618caab7c8 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 18 Feb 2019 09:46:19 +0000
Subject: [PATCH 2/2] Backport r268981
libcpp/ChangeLog:
2019-02-18 Martin Liska <mliska@suse.cz>
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 5827f303b6d..ddcb0111f4b 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -756,7 +756,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 <line_map *>
--
2.21.0
[-- Attachment #3: 0001-Backport-r268789.patch --]
[-- Type: text/x-patch, Size: 3133 bytes --]
From c4a45a0f56b8eb91295260332989382180418506 Mon Sep 17 00:00:00 2001
From: dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 12 Feb 2019 01:09:31 +0000
Subject: [PATCH 1/2] Backport r268789
gcc/ChangeLog:
2019-02-11 David Malcolm <dmalcolm@redhat.com>
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 <mliska@suse.cz>
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 80718100d0c..6412d70f4e2 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -3480,6 +3480,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
@@ -3518,6 +3546,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 949489eb1a1..5827f303b6d 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -753,6 +753,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 <line_map *>
--
2.21.0
next prev parent reply other threads:[~2019-03-11 11:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 9:45 Martin Liška
2018-08-16 10:18 ` Martin Liška
2019-02-15 10:58 ` Martin Liška
2019-03-11 11:23 ` Martin Liška [this message]
2019-03-28 8:56 ` Martin Liška
2019-04-11 9:00 ` Martin Liška
2019-05-28 11:58 ` Martin Liška
2019-07-22 11:05 ` Martin Liška
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef0e5698-97f6-7718-28cd-eabd4128e5b6@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).