aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit
diff options
context:
space:
mode:
authorAndreaCorallo <andrea.corallo@arm.com>2020-03-07 17:39:30 +0000
committerAndrea Corallo <andrea.corallo@arm.com>2020-03-23 19:00:26 +0100
commit0cd55f9d3afdc8d9220ef0cb20db61a3b86b4c8a (patch)
tree93b5fadec679f920b0ab51460907d73dcd699687 /gcc/jit
parent962406639c0ca9f0d948c843ad2a1ca5b17806da (diff)
downloadgcc-0cd55f9d3afdc8d9220ef0cb20db61a3b86b4c8a.zip
gcc-0cd55f9d3afdc8d9220ef0cb20db61a3b86b4c8a.tar.gz
gcc-0cd55f9d3afdc8d9220ef0cb20db61a3b86b4c8a.tar.bz2
libgccjit: handle long literals in playback::context::new_string_literal
gcc/jit/ChangeLog 2020-03-23 Andrea Corallo <andrea.corallo@arm.com> * jit-playback.h (gcc::jit::playback::context m_recording_ctxt): Remove m_char_array_type_node field. * jit-playback.c (playback::context::context) Remove m_char_array_type_node from member initializer list. (playback::context::new_string_literal) Fix logic to handle string length > 200. gcc/testsuite/ChangeLog 2020-03-23 Andrea Corallo <andrea.corallo@arm.com> * jit.dg/all-non-failing-tests.h: Add test-long-string-literal.c. * jit.dg/test-long-string-literal.c: New testcase.
Diffstat (limited to 'gcc/jit')
-rw-r--r--gcc/jit/ChangeLog11
-rw-r--r--gcc/jit/jit-playback.c16
-rw-r--r--gcc/jit/jit-playback.h1
3 files changed, 19 insertions, 9 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog
index b6f888f..5d39b7b 100644
--- a/gcc/jit/ChangeLog
+++ b/gcc/jit/ChangeLog
@@ -1,3 +1,14 @@
+2020-03-23 Andrea Corallo <andrea.corallo@arm.com>
+
+ * jit-playback.h
+ (gcc::jit::playback::context m_recording_ctxt): Remove
+ m_char_array_type_node field.
+ * jit-playback.c
+ (playback::context::context) Remove m_char_array_type_node from member
+ initializer list.
+ (playback::context::new_string_literal) Fix logic to handle string
+ length > 200.
+
2020-01-01 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index da68700..d2c8bb4 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -88,7 +88,6 @@ playback::context::context (recording::context *ctxt)
: log_user (ctxt->get_logger ()),
m_recording_ctxt (ctxt),
m_tempdir (NULL),
- m_char_array_type_node (NULL),
m_const_char_ptr (NULL)
{
JIT_LOG_SCOPE (get_logger ());
@@ -670,9 +669,14 @@ playback::rvalue *
playback::context::
new_string_literal (const char *value)
{
- tree t_str = build_string (strlen (value), value);
- gcc_assert (m_char_array_type_node);
- TREE_TYPE (t_str) = m_char_array_type_node;
+ /* Compare with c-family/c-common.c: fix_string_type. */
+ size_t len = strlen (value);
+ tree i_type = build_index_type (size_int (len));
+ tree a_type = build_array_type (char_type_node, i_type);
+ /* build_string len parameter must include NUL terminator when
+ building C strings. */
+ tree t_str = build_string (len + 1, value);
+ TREE_TYPE (t_str) = a_type;
/* Convert to (const char*), loosely based on
c/c-typeck.c: array_to_pointer_conversion,
@@ -2701,10 +2705,6 @@ playback::context::
replay ()
{
JIT_LOG_SCOPE (get_logger ());
- /* Adapted from c-common.c:c_common_nodes_and_builtins. */
- tree array_domain_type = build_index_type (size_int (200));
- m_char_array_type_node
- = build_array_type (char_type_node, array_domain_type);
m_const_char_ptr
= build_pointer_type (build_qualified_type (char_type_node,
diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h
index 904cc16..074434a 100644
--- a/gcc/jit/jit-playback.h
+++ b/gcc/jit/jit-playback.h
@@ -322,7 +322,6 @@ private:
auto_vec<function *> m_functions;
auto_vec<tree> m_globals;
- tree m_char_array_type_node;
tree m_const_char_ptr;
/* Source location handling. */