Skip to content

Commit 376f4fe

Browse files
committed
All Builder methods now take &mut self instead of &self
1 parent 2a6412b commit 376f4fe

File tree

22 files changed

+570
-546
lines changed

22 files changed

+570
-546
lines changed

src/librustc_codegen_llvm/abi.rs

+18-15
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ pub trait ArgTypeExt<'ll, 'tcx> {
172172
fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx, &'ll Value>) -> &'ll Type;
173173
fn store(
174174
&self,
175-
bx: &Builder<'_, 'll, 'tcx, &'ll Value>,
175+
bx: &mut Builder<'_, 'll, 'tcx, &'ll Value>,
176176
val: &'ll Value,
177177
dst: PlaceRef<'tcx, &'ll Value>
178178
);
179179
fn store_fn_arg(
180180
&self,
181-
bx: &Builder<'_, 'll, 'tcx, &'ll Value>,
181+
bx: &mut Builder<'_, 'll, 'tcx, &'ll Value>,
182182
idx: &mut usize, dst: PlaceRef<'tcx, &'ll Value>
183183
);
184184
}
@@ -196,7 +196,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
196196
/// or results of call/invoke instructions into their destinations.
197197
fn store(
198198
&self,
199-
bx: &Builder<'_, 'll, 'tcx, &'ll Value>,
199+
bx: &mut Builder<'_, 'll, 'tcx, &'ll Value>,
200200
val: &'ll Value,
201201
dst: PlaceRef<'tcx, &'ll Value>
202202
) {
@@ -240,10 +240,13 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
240240
bx.store(val, llscratch, scratch_align);
241241

242242
// ...and then memcpy it to the intended destination.
243+
let llval_cast = bx.pointercast(dst.llval, cx.type_i8p());
244+
let llscratch_cast = bx.pointercast(llscratch, cx.type_i8p());
245+
let size = cx.const_usize(self.layout.size.bytes());
243246
bx.call_memcpy(
244-
bx.pointercast(dst.llval, cx.type_i8p()),
245-
bx.pointercast(llscratch, cx.type_i8p()),
246-
cx.const_usize(self.layout.size.bytes()),
247+
llval_cast,
248+
llscratch_cast,
249+
size,
247250
self.layout.align.min(scratch_align),
248251
MemFlags::empty()
249252
);
@@ -257,7 +260,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
257260

258261
fn store_fn_arg(
259262
&self,
260-
bx: &Builder<'a, 'll, 'tcx, &'ll Value>,
263+
bx: &mut Builder<'a, 'll, 'tcx, &'ll Value>,
261264
idx: &mut usize,
262265
dst: PlaceRef<'tcx, &'ll Value>
263266
) {
@@ -283,19 +286,19 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
283286

284287
impl<'a, 'll: 'a, 'tcx: 'll> ArgTypeMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx, &'ll Value> {
285288
fn store_fn_arg(
286-
&self,
289+
&mut self,
287290
ty: &ArgType<'tcx, Ty<'tcx>>,
288291
idx: &mut usize, dst: PlaceRef<'tcx, <Self::CodegenCx as Backend<'ll>>::Value>
289292
) {
290-
ty.store_fn_arg(&self, idx, dst)
293+
ty.store_fn_arg(self, idx, dst)
291294
}
292295
fn store_arg_ty(
293-
&self,
296+
&mut self,
294297
ty: &ArgType<'tcx, Ty<'tcx>>,
295298
val: &'ll Value,
296299
dst: PlaceRef<'tcx, &'ll Value>
297300
) {
298-
ty.store(&self, val, dst)
301+
ty.store(self, val, dst)
299302
}
300303
fn memory_ty(&self, ty: &ArgType<'tcx, Ty<'tcx>>) -> &'ll Type {
301304
ty.memory_ty(self.cx())
@@ -322,7 +325,7 @@ pub trait FnTypeExt<'tcx> {
322325
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx, &'ll Value>) -> &'ll Type;
323326
fn llvm_cconv(&self) -> llvm::CallConv;
324327
fn apply_attrs_llfn(&self, llfn: &'ll Value);
325-
fn apply_attrs_callsite(&self, bx: &Builder<'a, 'll, 'tcx, &'ll Value>, callsite: &'ll Value);
328+
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx, &'ll Value>, callsite: &'ll Value);
326329
}
327330

328331
impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
@@ -725,7 +728,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
725728
}
726729
}
727730

728-
fn apply_attrs_callsite(&self, bx: &Builder<'a, 'll, 'tcx, &'ll Value>, callsite: &'ll Value) {
731+
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx, &'ll Value>, callsite: &'ll Value) {
729732
let mut i = 0;
730733
let mut apply = |attrs: &ArgAttributes| {
731734
attrs.apply_callsite(llvm::AttributePlace::Argument(i), callsite);
@@ -796,10 +799,10 @@ impl AbiMethods<'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
796799

797800
impl AbiBuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx, &'ll Value> {
798801
fn apply_attrs_callsite(
799-
&self,
802+
&mut self,
800803
ty: &FnType<'tcx, Ty<'tcx>>,
801804
callsite: <Self::CodegenCx as Backend<'ll>>::Value
802805
) {
803-
ty.apply_attrs_callsite(&self, callsite)
806+
ty.apply_attrs_callsite(self, callsite)
804807
}
805808
}

src/librustc_codegen_llvm/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use libc::{c_uint, c_char};
2626

2727
impl AsmBuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx, &'ll Value> {
2828
fn codegen_inline_asm(
29-
&self,
29+
&mut self,
3030
ia: &hir::InlineAsm,
3131
outputs: Vec<PlaceRef<'tcx, &'ll Value>>,
3232
mut inputs: Vec<&'ll Value>

0 commit comments

Comments
 (0)