diff options
| author | yvt <i@yvt.jp> | 2022-05-02 11:00:07 +0900 |
|---|---|---|
| committer | yvt <i@yvt.jp> | 2022-05-03 13:53:10 +0900 |
| commit | 351c68367425c4e292394ae5c7137b6e45de0916 (patch) | |
| tree | 7b18a94a8f77089a5c95c2bd380797a975b5e414 | |
| parent | a225f0a66b83b79e62d679568675adea284bfe21 (diff) | |
| download | rust-351c68367425c4e292394ae5c7137b6e45de0916.tar.gz rust-351c68367425c4e292394ae5c7137b6e45de0916.zip | |
Use the given pointee type in `<Builder as BuilderMethods>::load`
This commit updates this method implementation to return an `RValue` of the given pointee type. While this parameter does not seem to have much significance at the moment, it will likely become important as cg_llvm and cg_ssa migrate to LLVM opaque pointers and get rid of pointercasts.
| -rw-r--r-- | src/builder.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/builder.rs b/src/builder.rs index 4cc5eef9dad..9a5cf785a1f 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -652,18 +652,17 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { unimplemented!(); } - fn load(&mut self, _pointee_ty: Type<'gcc>, ptr: RValue<'gcc>, _align: Align) -> RValue<'gcc> { - // TODO(antoyo): use ty. + fn load(&mut self, pointee_ty: Type<'gcc>, ptr: RValue<'gcc>, _align: Align) -> RValue<'gcc> { let block = self.llbb(); let function = block.get_function(); // NOTE: instead of returning the dereference here, we have to assign it to a variable in // the current basic block. Otherwise, it could be used in another basic block, causing a // dereference after a drop, for instance. // TODO(antoyo): handle align of the load instruction. + let ptr = self.context.new_cast(None, ptr, pointee_ty.make_pointer()); let deref = ptr.dereference(None).to_rvalue(); - let value_type = deref.get_type(); unsafe { RETURN_VALUE_COUNT += 1 }; - let loaded_value = function.new_local(None, value_type, &format!("loadedValue{}", unsafe { RETURN_VALUE_COUNT })); + let loaded_value = function.new_local(None, pointee_ty, &format!("loadedValue{}", unsafe { RETURN_VALUE_COUNT })); block.add_assignment(None, loaded_value, deref); loaded_value.to_rvalue() } |
