Skip to content

Commit 426316e

Browse files
authored
Merge pull request #53 from rust-lang/lvalue-remove
Add a way to remove a global
2 parents 2482856 + 2d4800c commit 426316e

File tree

7 files changed

+40
-10
lines changed

7 files changed

+40
-10
lines changed

gcc/jit/jit-playback.cc

+10-5
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,8 @@ global_new_decl (location *loc,
776776
enum global_var_flags flags,
777777
const std::vector<std::pair<gcc_jit_variable_attribute,
778778
std::string>> &attributes,
779-
bool readonly)
779+
bool readonly,
780+
bool removed)
780781
{
781782
gcc_assert (type);
782783
gcc_assert (name);
@@ -788,6 +789,8 @@ global_new_decl (location *loc,
788789
type_tree);
789790

790791
TREE_PUBLIC (inner) = (kind != GCC_JIT_GLOBAL_INTERNAL);
792+
if (removed)
793+
TREE_ASM_WRITTEN (inner) = 1;
791794

792795

793796
int will_be_init = flags & (GLOBAL_VAR_FLAGS_WILL_BE_RVAL_INIT |
@@ -869,10 +872,11 @@ new_global (location *loc,
869872
enum global_var_flags flags,
870873
const std::vector<std::pair<gcc_jit_variable_attribute,
871874
std::string>> &attributes,
872-
bool readonly)
875+
bool readonly,
876+
bool removed)
873877
{
874878
tree inner =
875-
global_new_decl (loc, kind, type, name, flags, attributes, readonly);
879+
global_new_decl (loc, kind, type, name, flags, attributes, readonly, removed);
876880

877881
return global_finalize_lvalue (inner);
878882
}
@@ -1020,9 +1024,10 @@ new_global_initialized (location *loc,
10201024
enum global_var_flags flags,
10211025
const std::vector<std::pair<gcc_jit_variable_attribute,
10221026
std::string>> &attributes,
1023-
bool readonly)
1027+
bool readonly,
1028+
bool removed)
10241029
{
1025-
tree inner = global_new_decl (loc, kind, type, name, flags, attributes, readonly);
1030+
tree inner = global_new_decl (loc, kind, type, name, flags, attributes, readonly, removed);
10261031

10271032
vec<constructor_elt, va_gc> *constructor_elements = NULL;
10281033

gcc/jit/jit-playback.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ class context : public log_user
137137
enum global_var_flags flags,
138138
const std::vector<std::pair<gcc_jit_variable_attribute,
139139
std::string>> &attributes,
140-
bool readonly);
140+
bool readonly,
141+
bool removed);
141142

142143
lvalue *
143144
new_global_initialized (location *loc,
@@ -152,7 +153,8 @@ class context : public log_user
152153
gcc_jit_variable_attribute,
153154
std::string>>
154155
&attributes,
155-
bool readonly);
156+
bool readonly,
157+
bool removed);
156158

157159
rvalue *
158160
new_ctor (location *log,
@@ -362,7 +364,8 @@ class context : public log_user
362364
enum global_var_flags flags,
363365
const std::vector<std::pair<gcc_jit_variable_attribute,
364366
std::string>> &attributes,
365-
bool readonly);
367+
bool readonly,
368+
bool removed);
366369
lvalue *
367370
global_finalize_lvalue (tree inner);
368371

gcc/jit/jit-recording.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -5407,14 +5407,16 @@ recording::global::replay_into (replayer *r)
54075407
playback_string (m_name),
54085408
m_flags,
54095409
m_string_attributes,
5410-
m_readonly)
5410+
m_readonly,
5411+
m_removed)
54115412
: r->new_global (playback_location (r, m_loc),
54125413
m_kind,
54135414
m_type->playback_type (),
54145415
playback_string (m_name),
54155416
m_flags,
54165417
m_string_attributes,
5417-
m_readonly);
5418+
m_readonly,
5419+
m_removed);
54185420

54195421
if (m_tls_model != GCC_JIT_TLS_MODEL_NONE)
54205422
global->set_tls_model (recording::tls_models[m_tls_model]);

gcc/jit/jit-recording.h

+6
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,11 @@ class lvalue : public rvalue
14551455
m_readonly = true;
14561456
}
14571457

1458+
void remove ()
1459+
{
1460+
m_removed = true;
1461+
}
1462+
14581463
virtual const char *access_as_lvalue (reproducer &r);
14591464
virtual bool is_global () const { return false; }
14601465
virtual bool is_local () const { return false; }
@@ -1472,6 +1477,7 @@ class lvalue : public rvalue
14721477
std::vector<std::pair<gcc_jit_variable_attribute,
14731478
std::string>> m_string_attributes;
14741479
bool m_readonly = false;
1480+
bool m_removed = false;
14751481
};
14761482

14771483
class param : public lvalue

gcc/jit/libgccjit.cc

+6
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,12 @@ gcc_jit_rvalue_get_type (gcc_jit_rvalue *rvalue)
20072007
return static_cast <gcc_jit_type *> (rvalue->get_type ());
20082008
}
20092009

2010+
void
2011+
gcc_jit_lvalue_remove (gcc_jit_lvalue *lvalue)
2012+
{
2013+
lvalue->remove ();
2014+
}
2015+
20102016
/* Verify that NUMERIC_TYPE is non-NULL, and that it is a "numeric"
20112017
type i.e. it satisfies gcc::jit::type::is_numeric (), such as the
20122018
result of gcc_jit_context_get_type (GCC_JIT_TYPE_INT). */

gcc/jit/libgccjit.h

+3
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,9 @@ gcc_jit_rvalue_as_object (gcc_jit_rvalue *rvalue);
10791079
extern gcc_jit_type *
10801080
gcc_jit_rvalue_get_type (gcc_jit_rvalue *rvalue);
10811081

1082+
extern void
1083+
gcc_jit_lvalue_remove (gcc_jit_lvalue *lvalue);
1084+
10821085
/* Integer constants. */
10831086
extern gcc_jit_rvalue *
10841087
gcc_jit_context_new_rvalue_from_int (gcc_jit_context *ctxt,

gcc/jit/libgccjit.map

+5
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,8 @@ LIBGCCJIT_ABI_40 {
362362
global:
363363
gcc_jit_type_is_floating_point;
364364
} LIBGCCJIT_ABI_39;
365+
366+
LIBGCCJIT_ABI_41 {
367+
global:
368+
gcc_jit_lvalue_remove;
369+
} LIBGCCJIT_ABI_40;

0 commit comments

Comments
 (0)