Computes the address space for a static.
(&self, instance: Instance<'tcx>)
| 265 | impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { |
| 266 | /// Computes the address space for a static. |
| 267 | pub fn static_addrspace(&self, instance: Instance<'tcx>) -> AddressSpace { |
| 268 | let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all()); |
| 269 | let is_mutable = self.tcx().is_mutable_static(instance.def_id()); |
| 270 | let attrs = self.tcx.get_attrs(instance.def_id()); |
| 271 | let nvvm_attrs = NvvmAttributes::parse(self, attrs); |
| 272 | |
| 273 | if let Some(addr) = nvvm_attrs.addrspace { |
| 274 | return AddressSpace(addr as u32); |
| 275 | } |
| 276 | |
| 277 | if !is_mutable && self.type_is_freeze(ty) { |
| 278 | AddressSpace(4) |
| 279 | } else { |
| 280 | AddressSpace::DATA |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | /// Declare a global value, returns the existing value if it was already declared. |
| 285 | pub fn declare_global( |
no test coverage detected