@@ -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
235244fn data_id_for_alloc_id (
0 commit comments