Skip to content

Commit 46fa9ad

Browse files
committed
Directly use symbol_value and tls_value
global_value gets legalized to either of the two.
1 parent a3796c7 commit 46fa9ad

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/constant.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub(crate) fn codegen_const_value<'tcx>(
153153
if fx.clif_comments.enabled() {
154154
fx.add_comment(local_data_id, format!("{:?}", alloc_id));
155155
}
156-
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
156+
fx.bcx.ins().symbol_value(fx.pointer_type, local_data_id)
157157
}
158158
}
159159
GlobalAlloc::Function { instance, .. } => {
@@ -174,7 +174,7 @@ pub(crate) fn codegen_const_value<'tcx>(
174174
);
175175
let local_data_id =
176176
fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
177-
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
177+
fx.bcx.ins().symbol_value(fx.pointer_type, local_data_id)
178178
}
179179
GlobalAlloc::TypeId { .. } => {
180180
return CValue::const_val(
@@ -195,7 +195,16 @@ pub(crate) fn codegen_const_value<'tcx>(
195195
if fx.clif_comments.enabled() {
196196
fx.add_comment(local_data_id, format!("{:?}", def_id));
197197
}
198-
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
198+
if fx
199+
.tcx
200+
.codegen_fn_attrs(def_id)
201+
.flags
202+
.contains(CodegenFnAttrFlags::THREAD_LOCAL)
203+
{
204+
fx.bcx.ins().tls_value(fx.pointer_type, local_data_id)
205+
} else {
206+
fx.bcx.ins().symbol_value(fx.pointer_type, local_data_id)
207+
}
199208
}
200209
};
201210
let val = if offset.bytes() != 0 {
@@ -229,7 +238,7 @@ fn pointer_for_allocation<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, alloc_id: All
229238
if fx.clif_comments.enabled() {
230239
fx.add_comment(local_data_id, format!("{:?}", alloc_id));
231240
}
232-
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
241+
fx.bcx.ins().symbol_value(fx.pointer_type, local_data_id)
233242
}
234243

235244
fn data_id_for_alloc_id(

src/vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ pub(crate) fn get_vtable<'tcx>(
8484
if fx.clif_comments.enabled() {
8585
fx.add_comment(local_data_id, "vtable");
8686
}
87-
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
87+
fx.bcx.ins().symbol_value(fx.pointer_type, local_data_id)
8888
}

0 commit comments

Comments
 (0)