(&self, def_id: DefId, _is_mutable: bool)
| 331 | } |
| 332 | |
| 333 | fn codegen_static(&self, def_id: DefId, _is_mutable: bool) { |
| 334 | let g = self.get_static(def_id); |
| 335 | |
| 336 | let alloc = match self.tcx.eval_static_initializer(def_id) { |
| 337 | Ok(alloc) => alloc, |
| 338 | // Error has already been reported |
| 339 | Err(_) => return, |
| 340 | }; |
| 341 | let value_ty = match self.lookup_type(g.ty) { |
| 342 | SpirvType::Pointer { pointee } => pointee, |
| 343 | other => self.tcx.sess.fatal(format!( |
| 344 | "global had non-pointer type {}", |
| 345 | other.debug(g.ty, self) |
| 346 | )), |
| 347 | }; |
| 348 | let v = self.create_const_alloc(alloc, value_ty); |
| 349 | assert_ty_eq!(self, value_ty, v.ty); |
| 350 | self.builder |
| 351 | .set_global_initializer(g.def_cx(self), v.def_cx(self)); |
| 352 | } |
| 353 | |
| 354 | /// Mark the given global value as "used", to prevent the compiler and linker from potentially |
| 355 | /// removing a static variable that may otherwise appear unused. |
nothing calls this directly
no test coverage detected