Skip to content

Commit 6cce3df

Browse files
committed
Revert "Add function to set the initial value of a global variable [PR96089]"
This reverts commit f2a6769.
1 parent 18d948a commit 6cce3df

10 files changed

+2
-150
lines changed

gcc/jit/docs/topics/compatibility.rst

-9
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,3 @@ thread-local storage model of a variable:
302302
section of a variable:
303303

304304
* :func:`gcc_jit_lvalue_set_link_section`
305-
306-
.. _LIBGCCJIT_ABI_19:
307-
308-
``LIBGCCJIT_ABI_19``
309-
-----------------------
310-
``LIBGCCJIT_ABI_19`` covers the addition of an API entrypoint to set the value
311-
of a global variable:
312-
313-
* :func:`gcc_jit_global_set_initializer_value`

gcc/jit/docs/topics/expressions.rst

-14
Original file line numberDiff line numberDiff line change
@@ -643,20 +643,6 @@ Global variables
643643
644644
#ifdef LIBGCCJIT_HAVE_gcc_jit_global_set_initializer
645645
646-
.. function:: void
647-
gcc_jit_global_set_initializer_value (gcc_jit_lvalue *global,\
648-
gcc_jit_rvalue *value)
649-
650-
Set an initializer for ``global`` using the specified value.
651-
``global`` must be the same type as ``value``.
652-
653-
This entrypoint was added in :ref:`LIBGCCJIT_ABI_19`; you can test for
654-
its presence using
655-
656-
.. code-block:: c
657-
658-
#ifdef LIBGCCJIT_HAVE_gcc_jit_global_set_initializer_value
659-
660646
Working with pointers, structs and unions
661647
-----------------------------------------
662648

gcc/jit/jit-playback.c

-18
Original file line numberDiff line numberDiff line change
@@ -702,24 +702,6 @@ new_global_initialized (location *loc,
702702
return global_finalize_lvalue (inner);
703703
}
704704

705-
playback::lvalue *
706-
playback::context::
707-
new_global_with_value (location *loc,
708-
enum gcc_jit_global_kind kind,
709-
type *type,
710-
playback::rvalue *value,
711-
const char *name)
712-
{
713-
tree inner = global_new_decl (loc, kind, type, name);
714-
715-
tree inner_type = type->as_tree ();
716-
tree initial = value->as_tree ();
717-
gcc_assert (TREE_CONSTANT (initial));
718-
DECL_INITIAL (inner) = initial;
719-
720-
return global_finalize_lvalue (inner);
721-
}
722-
723705
/* Implementation of the various
724706
gcc::jit::playback::context::new_rvalue_from_const <HOST_TYPE>
725707
methods.

gcc/jit/jit-playback.h

-7
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,6 @@ class context : public log_user
121121
const void *initializer,
122122
const char *name);
123123

124-
lvalue*
125-
new_global_with_value (location *loc,
126-
enum gcc_jit_global_kind kind,
127-
type *type,
128-
rvalue *value,
129-
const char *name);
130-
131124
template <typename HOST_TYPE>
132125
rvalue *
133126
new_rvalue_from_const (type *type,

gcc/jit/jit-recording.c

-16
Original file line numberDiff line numberDiff line change
@@ -4687,14 +4687,6 @@ recording::global::replay_into (replayer *r)
46874687
m_initializer,
46884688
playback_string (m_name));
46894689
}
4690-
else if (m_initializer_value)
4691-
{
4692-
global = r->new_global_with_value (playback_location (r, m_loc),
4693-
m_kind,
4694-
m_type->playback_type (),
4695-
m_initializer_value->playback_rvalue (),
4696-
playback_string (m_name));
4697-
}
46984690
else
46994691
{
47004692
global = r->new_global (playback_location (r, m_loc),
@@ -4834,14 +4826,6 @@ recording::global::write_reproducer (reproducer &r)
48344826
r.get_identifier_as_type (get_type ()),
48354827
m_name->get_debug_string ());
48364828

4837-
if (m_initializer_value)
4838-
{
4839-
r.write (" gcc_jit_global_set_initializer_value (%s, /* gcc_jit_lvalue *global */\n"
4840-
" %s/* gcc_jit_rvalue *value */);\n",
4841-
id,
4842-
r.get_identifier_as_rvalue (m_initializer_value));
4843-
}
4844-
48454829
if (m_link_section != NULL)
48464830
{
48474831
r.write (" gcc_jit_lvalue_set_link_section (%s, /* gcc_jit_lvalue *lvalue */\n"

gcc/jit/jit-recording.h

-8
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,6 @@ class global : public lvalue
13831383
m_name (name)
13841384
{
13851385
m_initializer = NULL;
1386-
m_initializer_value = NULL;
13871386
m_initializer_num_bytes = 0;
13881387
}
13891388
~global ()
@@ -1410,12 +1409,6 @@ class global : public lvalue
14101409
m_initializer_num_bytes = num_bytes;
14111410
}
14121411

1413-
void
1414-
set_initializer_value (rvalue* value)
1415-
{
1416-
m_initializer_value = value;
1417-
}
1418-
14191412
private:
14201413
string * make_debug_string () FINAL OVERRIDE { return m_name; }
14211414
template <typename T>
@@ -1430,7 +1423,6 @@ class global : public lvalue
14301423
enum gcc_jit_global_kind m_kind;
14311424
string *m_name;
14321425
void *m_initializer;
1433-
rvalue *m_initializer_value;
14341426
size_t m_initializer_num_bytes;
14351427
};
14361428

gcc/jit/libgccjit.c

-43
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,6 @@ struct gcc_jit_extended_asm : public gcc::jit::recording::extended_asm
277277
} \
278278
JIT_END_STMT
279279

280-
#define RETURN_IF_FAIL_PRINTF5(TEST_EXPR, CTXT, LOC, ERR_FMT, A0, A1, A2, A3, \
281-
A4) \
282-
JIT_BEGIN_STMT \
283-
if (!(TEST_EXPR)) \
284-
{ \
285-
jit_error ((CTXT), (LOC), "%s: " ERR_FMT, \
286-
__func__, (A0), (A1), (A2), (A3), (A4)); \
287-
return; \
288-
} \
289-
JIT_END_STMT
290-
291280
/* Check that BLOCK is non-NULL, and that it's OK to add statements to
292281
it. This will fail if BLOCK has already been terminated by some
293282
kind of jump or a return. */
@@ -1428,38 +1417,6 @@ gcc_jit_global_set_initializer (gcc_jit_lvalue *global,
14281417
return global;
14291418
}
14301419

1431-
/* Public entrypoint. See description in libgccjit.h.
1432-
1433-
After error-checking, the real work is done by the
1434-
gcc::jit::recording::global::set_initializer_value method, in
1435-
jit-recording.c. */
1436-
1437-
void
1438-
gcc_jit_global_set_initializer_value (gcc_jit_lvalue *global,
1439-
gcc_jit_rvalue *value)
1440-
{
1441-
RETURN_IF_FAIL (global, NULL, NULL, "NULL global");
1442-
RETURN_IF_FAIL (value, NULL, NULL, "NULL value");
1443-
RETURN_IF_FAIL_PRINTF1 (global->is_global (), NULL, NULL,
1444-
"lvalue \"%s\" not a global",
1445-
global->get_debug_string ());
1446-
1447-
RETURN_IF_FAIL_PRINTF5 (
1448-
compatible_types (global->get_type (),
1449-
value->get_type ()),
1450-
NULL, NULL,
1451-
"mismatching types for global \"%s\":"
1452-
" assignment to global %s (type: %s) from %s (type: %s)",
1453-
global->get_debug_string (),
1454-
global->get_debug_string (),
1455-
global->get_type ()->get_debug_string (),
1456-
value->get_debug_string (),
1457-
value->get_type ()->get_debug_string ());
1458-
1459-
reinterpret_cast <gcc::jit::recording::global *> (global)
1460-
->set_initializer_value (value);
1461-
}
1462-
14631420
/* Public entrypoint. See description in libgccjit.h.
14641421
14651422
After error-checking, this calls the trivial

gcc/jit/libgccjit.h

-13
Original file line numberDiff line numberDiff line change
@@ -848,19 +848,6 @@ gcc_jit_global_set_initializer (gcc_jit_lvalue *global,
848848
const void *blob,
849849
size_t num_bytes);
850850

851-
#define LIBGCCJIT_HAVE_gcc_jit_global_set_initializer_value
852-
853-
/* Set an initial value for a global, which must be a constant.
854-
855-
This API entrypoint was added in LIBGCCJIT_ABI_19; you can test for its
856-
presence using
857-
#ifdef LIBGCCJIT_HAVE_gcc_jit_global_set_initializer_value
858-
*/
859-
860-
extern void
861-
gcc_jit_global_set_initializer_value (gcc_jit_lvalue *global,
862-
gcc_jit_rvalue *value);
863-
864851
/* Upcasting. */
865852
extern gcc_jit_object *
866853
gcc_jit_lvalue_as_object (gcc_jit_lvalue *lvalue);

gcc/jit/libgccjit.map

+2-7
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,10 @@ LIBGCCJIT_ABI_18 {
238238
} LIBGCCJIT_ABI_17;
239239

240240
LIBGCCJIT_ABI_19 {
241-
global:
242-
gcc_jit_global_set_initializer_value;
241+
gcc_jit_context_new_bitcast;
243242
} LIBGCCJIT_ABI_18;
244243

245244
LIBGCCJIT_ABI_20 {
246-
gcc_jit_context_new_bitcast;
247-
} LIBGCCJIT_ABI_19;
248-
249-
LIBGCCJIT_ABI_21 {
250245
global:
251246
gcc_jit_lvalue_set_register_name;
252-
} LIBGCCJIT_ABI_20;
247+
} LIBGCCJIT_ABI_19;

gcc/testsuite/jit.dg/test-global-set-initializer.c

-15
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ create_code (gcc_jit_context *ctxt, void *user_data)
2121
signed char bin_blob1[] = { 0xc, 0xa, 0xf, 0xf, 0xe };
2222
unsigned bin_blob2[] = { 0x3, 0x2, 0x1, 0x0, 0x1, 0x2, 0x3 };
2323
unsigned char bin_blob3[4096]...
24-
unsigned int integer = 42;
2524
*/
2625
gcc_jit_type *unsigned_char_type =
2726
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_UNSIGNED_CHAR);
@@ -57,16 +56,6 @@ create_code (gcc_jit_context *ctxt, void *user_data)
5756
sizeof (test_blob3)),
5857
"bin_blob3");
5958
gcc_jit_global_set_initializer (glob, test_blob3, sizeof (test_blob3));
60-
61-
gcc_jit_rvalue *forty_two = gcc_jit_context_new_rvalue_from_int (
62-
ctxt, unsigned_type, 42);
63-
64-
glob =
65-
gcc_jit_context_new_global (
66-
ctxt, NULL, GCC_JIT_GLOBAL_EXPORTED,
67-
unsigned_type,
68-
"integer");
69-
gcc_jit_global_set_initializer_value (glob, forty_two);
7059
}
7160

7261
void
@@ -86,8 +75,4 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
8675
CHECK_NON_NULL (glob);
8776
CHECK_VALUE (memcmp (test_blob3, glob, sizeof (test_blob3)), 0);
8877

89-
glob = gcc_jit_result_get_global (result, "integer");
90-
CHECK_NON_NULL (glob);
91-
int *value = glob;
92-
CHECK_VALUE (*value, 42);
9378
}

0 commit comments

Comments
 (0)