This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PING^1: [PATCH] Set start_location to 0 if we ran out of line map space
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, David Malcolm <dmalcolm at redhat dot com>, Tom Tromey <tromey at redhat dot com>
- Date: Wed, 22 Aug 2018 12:48:26 -0700
- Subject: PING^1: [PATCH] Set start_location to 0 if we ran out of line map space
PING.
---------- Forwarded message ----------
From: H.J. Lu <hjl.tools@gmail.com>
Date: Wed, Aug 15, 2018 at 4:33 AM
Subject: [PATCH] Set start_location to 0 if we ran out of line map space
To: gcc-patches@gcc.gnu.org
With profiledbootstrap and --with-build-config=bootstrap-lto, linemap_add
may create a macro map when we run out of line map space. This patch
changes start_location to UNKNOWN_LOCATION (0) in this case.
Tested with profiledbootstrap and --with-build-config=bootstrap-lto on
Linux/x86-64.
PR bootstrap/86872
* line-map.c (pure_location_p): Return true if linemap_lookup
returns NULL.
(linemap_add): Set start_location to 0 if we run out of line map
space.
---
libcpp/line-map.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 555cd129a9c..cafe42273eb 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -304,6 +304,8 @@ pure_location_p (line_maps *set, source_location loc)
return false;
const line_map *map = linemap_lookup (set, loc);
+ if (map == NULL)
+ return true;
const line_map_ordinary *ordmap = linemap_check_ordinary (map);
if (loc & ((1U << ordmap->m_range_bits) - 1))
@@ -492,6 +494,11 @@ linemap_add (struct line_maps *set, enum lc_reason reason,
}
linemap_assert (reason != LC_ENTER_MACRO);
+
+ if (start_location >= LINE_MAP_MAX_LOCATION)
+ /* We ran out of line map space. */
+ start_location = 0;
+
line_map_ordinary *map
= linemap_check_ordinary (new_linemap (set, start_location));
map->reason = reason;
--
2.17.1
--
H.J.