(
&self,
layout: TyAndLayout<'tcx>,
alloc: &Allocation,
offset: Size,
)
| 193 | } |
| 194 | |
| 195 | fn from_const_alloc( |
| 196 | &self, |
| 197 | layout: TyAndLayout<'tcx>, |
| 198 | alloc: &Allocation, |
| 199 | offset: Size, |
| 200 | ) -> PlaceRef<'tcx, &'ll Value> { |
| 201 | assert_eq!(alloc.align, layout.align.abi); |
| 202 | let llty = self.type_ptr_to(layout.llvm_type(self)); |
| 203 | let llval = if layout.size == Size::ZERO { |
| 204 | let llval = self.const_usize(alloc.align.bytes()); |
| 205 | unsafe { llvm::LLVMConstIntToPtr(llval, llty) } |
| 206 | } else { |
| 207 | let init = const_alloc_to_llvm(self, alloc); |
| 208 | let base_addr = self.static_addr_of(init, alloc.align, None); |
| 209 | |
| 210 | let llval = unsafe { |
| 211 | llvm::LLVMConstInBoundsGEP( |
| 212 | self.const_bitcast(base_addr, self.type_i8p()), |
| 213 | &self.const_usize(offset.bytes()), |
| 214 | 1, |
| 215 | ) |
| 216 | }; |
| 217 | self.const_bitcast(llval, llty) |
| 218 | }; |
| 219 | PlaceRef::new_sized(llval, layout) |
| 220 | } |
| 221 | |
| 222 | fn const_ptrcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value { |
| 223 | unsafe { llvm::LLVMConstPointerCast(val, ty) } |
nothing calls this directly
no test coverage detected