summaryrefslogtreecommitdiff
path: root/gcc/jit
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-07-01 12:50:50 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2015-07-01 12:50:50 +0000
commite09abfa408597ec644621b6318d735eb0a2d299d (patch)
treec3c7765d81997c4efc52f8fad6f56a8d17eb693c /gcc/jit
parente807aeaae32697a203928a7900426d011c98dedc (diff)
downloadgcc-e09abfa408597ec644621b6318d735eb0a2d299d.tar.gz
PR jit/66700: set TREE_ADDRESSABLE when building an ADDR_EXPR
gcc/jit/ChangeLog: PR jit/66700 * jit-playback.c (jit_mark_addressable): New function. (gcc::jit::playback::lvalue::get_address): Call jit_mark_addressable on the underlying tree. gcc/testsuite/ChangeLog: PR jit/66700 * jit.dg/all-non-failing-tests.h: Add test-pr66700-observing-write-through-ptr.c. * jit.dg/test-pr66700-observing-write-through-ptr.c: New testcase. From-SVN: r225248
Diffstat (limited to 'gcc/jit')
-rw-r--r--gcc/jit/ChangeLog7
-rw-r--r--gcc/jit/jit-playback.c42
2 files changed, 49 insertions, 0 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog
index 8a893707f06..baa7b832b6f 100644
--- a/gcc/jit/ChangeLog
+++ b/gcc/jit/ChangeLog
@@ -1,5 +1,12 @@
2015-07-01 David Malcolm <dmalcolm@redhat.com>
+ PR jit/66700
+ * jit-playback.c (jit_mark_addressable): New function.
+ (gcc::jit::playback::lvalue::get_address): Call
+ jit_mark_addressable on the underlying tree.
+
+2015-07-01 David Malcolm <dmalcolm@redhat.com>
+
* docs/topics/types.rst (gcc_jit_context_new_union_type): Add
documentation.
* docs/_build/texinfo/libgccjit.texi: Regenerate.
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index c9d7c8c607a..1fe1091f7d3 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -1164,6 +1164,47 @@ dereference (location *loc)
return new lvalue (get_context (), datum);
}
+/* Mark EXP saying that we need to be able to take the
+ address of it; it should not be allocated in a register.
+ Compare with e.g. c/c-typeck.c: c_mark_addressable. */
+
+static void
+jit_mark_addressable (tree exp)
+{
+ tree x = exp;
+
+ while (1)
+ switch (TREE_CODE (x))
+ {
+ case COMPONENT_REF:
+ /* (we don't yet support bitfields) */
+ /* fallthrough */
+ case ADDR_EXPR:
+ case ARRAY_REF:
+ case REALPART_EXPR:
+ case IMAGPART_EXPR:
+ x = TREE_OPERAND (x, 0);
+ break;
+
+ case COMPOUND_LITERAL_EXPR:
+ case CONSTRUCTOR:
+ TREE_ADDRESSABLE (x) = 1;
+ return;
+
+ case VAR_DECL:
+ case CONST_DECL:
+ case PARM_DECL:
+ case RESULT_DECL:
+ /* (we don't have a concept of a "register" declaration) */
+ /* fallthrough */
+ case FUNCTION_DECL:
+ TREE_ADDRESSABLE (x) = 1;
+ /* fallthrough */
+ default:
+ return;
+ }
+}
+
/* Construct a playback::rvalue instance (wrapping a tree) for an
address-lookup. */
@@ -1177,6 +1218,7 @@ get_address (location *loc)
tree ptr = build1 (ADDR_EXPR, t_ptrtype, t_lvalue);
if (loc)
get_context ()->set_tree_location (ptr, loc);
+ jit_mark_addressable (t_lvalue);
return new rvalue (get_context (), ptr);
}