Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 949d395

Browse files
committedAug 3, 2018
rustc_codegen_llvm: begin generalizing over backend values.
1 parent 76aeeef commit 949d395

File tree

9 files changed

+91
-65
lines changed

9 files changed

+91
-65
lines changed
 

‎src/librustc_codegen_llvm/abi.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,13 @@ impl LlvmType for CastTarget {
167167

168168
pub trait ArgTypeExt<'ll, 'tcx> {
169169
fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
170-
fn store(&self, bx: &Builder<'_, 'll, 'tcx>, val: &'ll Value, dst: PlaceRef<'ll, 'tcx>);
171-
fn store_fn_arg(&self, bx: &Builder<'_, 'll, 'tcx>, idx: &mut usize, dst: PlaceRef<'ll, 'tcx>);
170+
fn store(&self, bx: &Builder<'_, 'll, 'tcx>, val: &'ll Value, dst: PlaceRef<'tcx, &'ll Value>);
171+
fn store_fn_arg(
172+
&self,
173+
bx: &Builder<'_, 'll, 'tcx>,
174+
idx: &mut usize,
175+
dst: PlaceRef<'tcx, &'ll Value>,
176+
);
172177
}
173178

174179
impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
@@ -182,7 +187,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
182187
/// place for the original Rust type of this argument/return.
183188
/// Can be used for both storing formal arguments into Rust variables
184189
/// or results of call/invoke instructions into their destinations.
185-
fn store(&self, bx: &Builder<'_, 'll, 'tcx>, val: &'ll Value, dst: PlaceRef<'ll, 'tcx>) {
190+
fn store(&self, bx: &Builder<'_, 'll, 'tcx>, val: &'ll Value, dst: PlaceRef<'tcx, &'ll Value>) {
186191
if self.is_ignore() {
187192
return;
188193
}
@@ -235,7 +240,12 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
235240
}
236241
}
237242

238-
fn store_fn_arg(&self, bx: &Builder<'a, 'll, 'tcx>, idx: &mut usize, dst: PlaceRef<'ll, 'tcx>) {
243+
fn store_fn_arg(
244+
&self,
245+
bx: &Builder<'a, 'll, 'tcx>,
246+
idx: &mut usize,
247+
dst: PlaceRef<'tcx, &'ll Value>,
248+
) {
239249
let mut next = || {
240250
let val = llvm::get_param(bx.llfn(), *idx as c_uint);
241251
*idx += 1;

‎src/librustc_codegen_llvm/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use libc::{c_uint, c_char};
2828
pub fn codegen_inline_asm(
2929
bx: &Builder<'a, 'll, 'tcx>,
3030
ia: &hir::InlineAsm,
31-
outputs: Vec<PlaceRef<'ll, 'tcx>>,
31+
outputs: Vec<PlaceRef<'tcx, &'ll Value>>,
3232
mut inputs: Vec<&'ll Value>
3333
) {
3434
let mut ext_constraints = vec![];

‎src/librustc_codegen_llvm/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ pub fn unsize_thin_ptr(
275275
/// to a value of type `dst_ty` and store the result in `dst`
276276
pub fn coerce_unsized_into(
277277
bx: &Builder<'a, 'll, 'tcx>,
278-
src: PlaceRef<'ll, 'tcx>,
279-
dst: PlaceRef<'ll, 'tcx>
278+
src: PlaceRef<'tcx, &'ll Value>,
279+
dst: PlaceRef<'tcx, &'ll Value>
280280
) {
281281
let src_ty = src.layout.ty;
282282
let dst_ty = dst.layout.ty;

‎src/librustc_codegen_llvm/intrinsic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub fn codegen_intrinsic_call(
8989
bx: &Builder<'a, 'll, 'tcx>,
9090
callee_ty: Ty<'tcx>,
9191
fn_ty: &FnType<'tcx, Ty<'tcx>>,
92-
args: &[OperandRef<'ll, 'tcx>],
92+
args: &[OperandRef<'tcx, &'ll Value>],
9393
llresult: &'ll Value,
9494
span: Span,
9595
) {
@@ -592,7 +592,7 @@ pub fn codegen_intrinsic_call(
592592
fn modify_as_needed(
593593
bx: &Builder<'a, 'll, 'tcx>,
594594
t: &intrinsics::Type,
595-
arg: &OperandRef<'ll, 'tcx>,
595+
arg: &OperandRef<'tcx, &'ll Value>,
596596
) -> Vec<&'ll Value> {
597597
match *t {
598598
intrinsics::Type::Aggregate(true, ref contents) => {
@@ -985,7 +985,7 @@ fn generic_simd_intrinsic(
985985
bx: &Builder<'a, 'll, 'tcx>,
986986
name: &str,
987987
callee_ty: Ty<'tcx>,
988-
args: &[OperandRef<'ll, 'tcx>],
988+
args: &[OperandRef<'tcx, &'ll Value>],
989989
ret_ty: Ty<'tcx>,
990990
llret_ty: &'ll Type,
991991
span: Span
@@ -1166,7 +1166,7 @@ fn generic_simd_intrinsic(
11661166
in_len: usize,
11671167
bx: &Builder<'a, 'll, 'tcx>,
11681168
span: Span,
1169-
args: &[OperandRef<'ll, 'tcx>],
1169+
args: &[OperandRef<'tcx, &'ll Value>],
11701170
) -> Result<&'ll Value, ()> {
11711171
macro_rules! emit_error {
11721172
($msg: tt) => {

‎src/librustc_codegen_llvm/mir/block.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
115115
fn_ty: FnType<'tcx, Ty<'tcx>>,
116116
fn_ptr: &'ll Value,
117117
llargs: &[&'ll Value],
118-
destination: Option<(ReturnDest<'ll, 'tcx>, mir::BasicBlock)>,
118+
destination: Option<(ReturnDest<'tcx, &'ll Value>, mir::BasicBlock)>,
119119
cleanup: Option<mir::BasicBlock>
120120
| {
121121
if let Some(cleanup) = cleanup {
@@ -636,7 +636,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
636636

637637
fn codegen_argument(&mut self,
638638
bx: &Builder<'a, 'll, 'tcx>,
639-
op: OperandRef<'ll, 'tcx>,
639+
op: OperandRef<'tcx, &'ll Value>,
640640
llargs: &mut Vec<&'ll Value>,
641641
arg: &ArgType<'tcx, Ty<'tcx>>) {
642642
// Fill padding with undef value, where applicable.
@@ -736,7 +736,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
736736
}
737737
}
738738

739-
fn get_personality_slot(&mut self, bx: &Builder<'a, 'll, 'tcx>) -> PlaceRef<'ll, 'tcx> {
739+
fn get_personality_slot(&mut self, bx: &Builder<'a, 'll, 'tcx>) -> PlaceRef<'tcx, &'ll Value> {
740740
let cx = bx.cx;
741741
if let Some(slot) = self.personality_slot {
742742
slot
@@ -812,7 +812,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
812812
fn make_return_dest(&mut self, bx: &Builder<'a, 'll, 'tcx>,
813813
dest: &mir::Place<'tcx>, fn_ret: &ArgType<'tcx, Ty<'tcx>>,
814814
llargs: &mut Vec<&'ll Value>, is_intrinsic: bool)
815-
-> ReturnDest<'ll, 'tcx> {
815+
-> ReturnDest<'tcx, &'ll Value> {
816816
// If the return is ignored, we can just return a do-nothing ReturnDest
817817
if fn_ret.is_ignore() {
818818
return ReturnDest::Nothing;
@@ -894,7 +894,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
894894

895895
fn codegen_transmute_into(&mut self, bx: &Builder<'a, 'll, 'tcx>,
896896
src: &mir::Operand<'tcx>,
897-
dst: PlaceRef<'ll, 'tcx>) {
897+
dst: PlaceRef<'tcx, &'ll Value>) {
898898
let src = self.codegen_operand(bx, src);
899899
let llty = src.layout.llvm_type(bx.cx);
900900
let cast_ptr = bx.pointercast(dst.llval, llty.ptr_to());
@@ -906,7 +906,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
906906
// Stores the return value of a function call into it's final location.
907907
fn store_return(&mut self,
908908
bx: &Builder<'a, 'll, 'tcx>,
909-
dest: ReturnDest<'ll, 'tcx>,
909+
dest: ReturnDest<'tcx, &'ll Value>,
910910
ret_ty: &ArgType<'tcx, Ty<'tcx>>,
911911
llval: &'ll Value) {
912912
use self::ReturnDest::*;
@@ -937,13 +937,13 @@ impl FunctionCx<'a, 'll, 'tcx> {
937937
}
938938
}
939939

940-
enum ReturnDest<'ll, 'tcx> {
940+
enum ReturnDest<'tcx, V> {
941941
// Do nothing, the return value is indirect or ignored
942942
Nothing,
943943
// Store the return value to the pointer
944-
Store(PlaceRef<'ll, 'tcx>),
944+
Store(PlaceRef<'tcx, V>),
945945
// Stores an indirect return value to an operand local place
946-
IndirectOperand(PlaceRef<'ll, 'tcx>, mir::Local),
946+
IndirectOperand(PlaceRef<'tcx, V>, mir::Local),
947947
// Stores a direct return value to an operand local place
948948
DirectOperand(mir::Local)
949949
}

‎src/librustc_codegen_llvm/mir/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> {
6363
/// don't really care about it very much. Anyway, this value
6464
/// contains an alloca into which the personality is stored and
6565
/// then later loaded when generating the DIVERGE_BLOCK.
66-
personality_slot: Option<PlaceRef<'ll, 'tcx>>,
66+
personality_slot: Option<PlaceRef<'tcx, &'ll Value>>,
6767

6868
/// A `Block` for each MIR `BasicBlock`
6969
blocks: IndexVec<mir::BasicBlock, &'ll BasicBlock>,
@@ -97,7 +97,7 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> {
9797
///
9898
/// Avoiding allocs can also be important for certain intrinsics,
9999
/// notably `expect`.
100-
locals: IndexVec<mir::Local, LocalRef<'ll, 'tcx>>,
100+
locals: IndexVec<mir::Local, LocalRef<'tcx, &'ll Value>>,
101101

102102
/// Debug information for MIR scopes.
103103
scopes: IndexVec<mir::SourceScope, debuginfo::MirDebugScope<'ll>>,
@@ -178,13 +178,16 @@ impl FunctionCx<'a, 'll, 'tcx> {
178178
}
179179
}
180180

181-
enum LocalRef<'ll, 'tcx> {
182-
Place(PlaceRef<'ll, 'tcx>),
183-
Operand(Option<OperandRef<'ll, 'tcx>>),
181+
enum LocalRef<'tcx, V> {
182+
Place(PlaceRef<'tcx, V>),
183+
Operand(Option<OperandRef<'tcx, V>>),
184184
}
185185

186-
impl LocalRef<'ll, 'tcx> {
187-
fn new_operand(cx: &CodegenCx<'ll, 'tcx>, layout: TyLayout<'tcx>) -> LocalRef<'ll, 'tcx> {
186+
impl LocalRef<'tcx, &'ll Value> {
187+
fn new_operand(
188+
cx: &CodegenCx<'ll, 'tcx>,
189+
layout: TyLayout<'tcx>,
190+
) -> LocalRef<'tcx, &'ll Value> {
188191
if layout.is_zst() {
189192
// Zero-size temporaries aren't always initialized, which
190193
// doesn't matter because they don't contain data, but
@@ -418,7 +421,7 @@ fn arg_local_refs(
418421
fx: &FunctionCx<'a, 'll, 'tcx>,
419422
scopes: &IndexVec<mir::SourceScope, debuginfo::MirDebugScope<'ll>>,
420423
memory_locals: &BitArray<mir::Local>,
421-
) -> Vec<LocalRef<'ll, 'tcx>> {
424+
) -> Vec<LocalRef<'tcx, &'ll Value>> {
422425
let mir = fx.mir;
423426
let tcx = bx.tcx();
424427
let mut idx = 0;

‎src/librustc_codegen_llvm/mir/operand.rs

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ use super::place::PlaceRef;
3232
/// uniquely determined by the value's type, but is kept as a
3333
/// safety check.
3434
#[derive(Copy, Clone, Debug)]
35-
pub enum OperandValue<'ll> {
35+
pub enum OperandValue<V> {
3636
/// A reference to the actual operand. The data is guaranteed
3737
/// to be valid for the operand's lifetime.
38-
Ref(&'ll Value, Align),
38+
Ref(V, Align),
3939
/// A single LLVM value.
40-
Immediate(&'ll Value),
40+
Immediate(V),
4141
/// A pair of immediate LLVM values. Used by fat pointers too.
42-
Pair(&'ll Value, &'ll Value)
42+
Pair(V, V)
4343
}
4444

4545
/// An `OperandRef` is an "SSA" reference to a Rust value, along with
@@ -51,23 +51,23 @@ pub enum OperandValue<'ll> {
5151
/// directly is sure to cause problems -- use `OperandRef::store`
5252
/// instead.
5353
#[derive(Copy, Clone)]
54-
pub struct OperandRef<'ll, 'tcx> {
54+
pub struct OperandRef<'tcx, V> {
5555
// The value.
56-
pub val: OperandValue<'ll>,
56+
pub val: OperandValue<V>,
5757

5858
// The layout of value, based on its Rust type.
5959
pub layout: TyLayout<'tcx>,
6060
}
6161

62-
impl fmt::Debug for OperandRef<'ll, 'tcx> {
62+
impl fmt::Debug for OperandRef<'tcx, &'ll Value> {
6363
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6464
write!(f, "OperandRef({:?} @ {:?})", self.val, self.layout)
6565
}
6666
}
6767

68-
impl OperandRef<'ll, 'tcx> {
68+
impl OperandRef<'tcx, &'ll Value> {
6969
pub fn new_zst(cx: &CodegenCx<'ll, 'tcx>,
70-
layout: TyLayout<'tcx>) -> OperandRef<'ll, 'tcx> {
70+
layout: TyLayout<'tcx>) -> OperandRef<'tcx, &'ll Value> {
7171
assert!(layout.is_zst());
7272
OperandRef {
7373
val: OperandValue::Immediate(C_undef(layout.immediate_llvm_type(cx))),
@@ -77,7 +77,7 @@ impl OperandRef<'ll, 'tcx> {
7777

7878
pub fn from_const(bx: &Builder<'a, 'll, 'tcx>,
7979
val: &'tcx ty::Const<'tcx>)
80-
-> Result<OperandRef<'ll, 'tcx>, Lrc<ConstEvalErr<'tcx>>> {
80+
-> Result<OperandRef<'tcx, &'ll Value>, Lrc<ConstEvalErr<'tcx>>> {
8181
let layout = bx.cx.layout_of(val.ty);
8282

8383
if layout.is_zst() {
@@ -138,7 +138,7 @@ impl OperandRef<'ll, 'tcx> {
138138
}
139139
}
140140

141-
pub fn deref(self, cx: &CodegenCx<'ll, 'tcx>) -> PlaceRef<'ll, 'tcx> {
141+
pub fn deref(self, cx: &CodegenCx<'ll, 'tcx>) -> PlaceRef<'tcx, &'ll Value> {
142142
let projected_ty = self.layout.ty.builtin_deref(true)
143143
.unwrap_or_else(|| bug!("deref of non-pointer {:?}", self)).ty;
144144
let (llptr, llextra) = match self.val {
@@ -176,7 +176,7 @@ impl OperandRef<'ll, 'tcx> {
176176
pub fn from_immediate_or_packed_pair(bx: &Builder<'a, 'll, 'tcx>,
177177
llval: &'ll Value,
178178
layout: TyLayout<'tcx>)
179-
-> OperandRef<'ll, 'tcx> {
179+
-> OperandRef<'tcx, &'ll Value> {
180180
let val = if let layout::Abi::ScalarPair(ref a, ref b) = layout.abi {
181181
debug!("Operand::from_immediate_or_packed_pair: unpacking {:?} @ {:?}",
182182
llval, layout);
@@ -191,7 +191,11 @@ impl OperandRef<'ll, 'tcx> {
191191
OperandRef { val, layout }
192192
}
193193

194-
pub fn extract_field(&self, bx: &Builder<'a, 'll, 'tcx>, i: usize) -> OperandRef<'ll, 'tcx> {
194+
pub fn extract_field(
195+
&self,
196+
bx: &Builder<'a, 'll, 'tcx>,
197+
i: usize,
198+
) -> OperandRef<'tcx, &'ll Value> {
195199
let field = self.layout.field(bx.cx, i);
196200
let offset = self.layout.fields.offset(i);
197201

@@ -249,27 +253,32 @@ impl OperandRef<'ll, 'tcx> {
249253
}
250254
}
251255

252-
impl OperandValue<'ll> {
253-
pub fn store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'ll, 'tcx>) {
256+
impl OperandValue<&'ll Value> {
257+
pub fn store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'tcx, &'ll Value>) {
254258
self.store_with_flags(bx, dest, MemFlags::empty());
255259
}
256260

257-
pub fn volatile_store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'ll, 'tcx>) {
261+
pub fn volatile_store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'tcx, &'ll Value>) {
258262
self.store_with_flags(bx, dest, MemFlags::VOLATILE);
259263
}
260264

261-
pub fn unaligned_volatile_store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'ll, 'tcx>) {
265+
pub fn unaligned_volatile_store(
266+
self,
267+
bx: &Builder<'a, 'll, 'tcx>,
268+
dest: PlaceRef<'tcx,
269+
&'ll Value>,
270+
) {
262271
self.store_with_flags(bx, dest, MemFlags::VOLATILE | MemFlags::UNALIGNED);
263272
}
264273

265-
pub fn nontemporal_store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'ll, 'tcx>) {
274+
pub fn nontemporal_store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'tcx, &'ll Value>) {
266275
self.store_with_flags(bx, dest, MemFlags::NONTEMPORAL);
267276
}
268277

269278
fn store_with_flags(
270279
self,
271280
bx: &Builder<'a, 'll, 'tcx>,
272-
dest: PlaceRef<'ll, 'tcx>,
281+
dest: PlaceRef<'tcx, &'ll Value>,
273282
flags: MemFlags,
274283
) {
275284
debug!("OperandRef::store: operand={:?}, dest={:?}", self, dest);
@@ -302,7 +311,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
302311
fn maybe_codegen_consume_direct(&mut self,
303312
bx: &Builder<'a, 'll, 'tcx>,
304313
place: &mir::Place<'tcx>)
305-
-> Option<OperandRef<'ll, 'tcx>>
314+
-> Option<OperandRef<'tcx, &'ll Value>>
306315
{
307316
debug!("maybe_codegen_consume_direct(place={:?})", place);
308317

@@ -350,7 +359,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
350359
pub fn codegen_consume(&mut self,
351360
bx: &Builder<'a, 'll, 'tcx>,
352361
place: &mir::Place<'tcx>)
353-
-> OperandRef<'ll, 'tcx>
362+
-> OperandRef<'tcx, &'ll Value>
354363
{
355364
debug!("codegen_consume(place={:?})", place);
356365

@@ -374,7 +383,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
374383
pub fn codegen_operand(&mut self,
375384
bx: &Builder<'a, 'll, 'tcx>,
376385
operand: &mir::Operand<'tcx>)
377-
-> OperandRef<'ll, 'tcx>
386+
-> OperandRef<'tcx, &'ll Value>
378387
{
379388
debug!("codegen_operand(operand={:?})", operand);
380389

‎src/librustc_codegen_llvm/mir/place.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ use super::{FunctionCx, LocalRef};
2828
use super::operand::{OperandRef, OperandValue};
2929

3030
#[derive(Copy, Clone, Debug)]
31-
pub struct PlaceRef<'ll, 'tcx> {
31+
pub struct PlaceRef<'tcx, V> {
3232
/// Pointer to the contents of the place
33-
pub llval: &'ll Value,
33+
pub llval: V,
3434

3535
/// This place's extra data if it is unsized, or null
36-
pub llextra: Option<&'ll Value>,
36+
pub llextra: Option<V>,
3737

3838
/// Monomorphized type of this place, including variant information
3939
pub layout: TyLayout<'tcx>,
@@ -42,12 +42,12 @@ pub struct PlaceRef<'ll, 'tcx> {
4242
pub align: Align,
4343
}
4444

45-
impl PlaceRef<'ll, 'tcx> {
45+
impl PlaceRef<'tcx, &'ll Value> {
4646
pub fn new_sized(
4747
llval: &'ll Value,
4848
layout: TyLayout<'tcx>,
4949
align: Align,
50-
) -> PlaceRef<'ll, 'tcx> {
50+
) -> PlaceRef<'tcx, &'ll Value> {
5151
PlaceRef {
5252
llval,
5353
llextra: None,
@@ -61,7 +61,7 @@ impl PlaceRef<'ll, 'tcx> {
6161
layout: TyLayout<'tcx>,
6262
alloc: &mir::interpret::Allocation,
6363
offset: Size,
64-
) -> PlaceRef<'ll, 'tcx> {
64+
) -> PlaceRef<'tcx, &'ll Value> {
6565
let init = const_alloc_to_llvm(bx.cx, alloc);
6666
let base_addr = consts::addr_of(bx.cx, init, layout.align, "byte_str");
6767

@@ -75,7 +75,7 @@ impl PlaceRef<'ll, 'tcx> {
7575
}
7676

7777
pub fn alloca(bx: &Builder<'a, 'll, 'tcx>, layout: TyLayout<'tcx>, name: &str)
78-
-> PlaceRef<'ll, 'tcx> {
78+
-> PlaceRef<'tcx, &'ll Value> {
7979
debug!("alloca({:?}: {:?})", name, layout);
8080
let tmp = bx.alloca(layout.llvm_type(bx.cx), name, layout.align);
8181
Self::new_sized(tmp, layout, layout.align)
@@ -94,7 +94,7 @@ impl PlaceRef<'ll, 'tcx> {
9494
}
9595
}
9696

97-
pub fn load(&self, bx: &Builder<'a, 'll, 'tcx>) -> OperandRef<'ll, 'tcx> {
97+
pub fn load(&self, bx: &Builder<'a, 'll, 'tcx>) -> OperandRef<'tcx, &'ll Value> {
9898
debug!("PlaceRef::load: {:?}", self);
9999

100100
assert_eq!(self.llextra, None);
@@ -156,7 +156,11 @@ impl PlaceRef<'ll, 'tcx> {
156156
}
157157

158158
/// Access a field, at a point when the value's case is known.
159-
pub fn project_field(self, bx: &Builder<'a, 'll, 'tcx>, ix: usize) -> PlaceRef<'ll, 'tcx> {
159+
pub fn project_field(
160+
self,
161+
bx: &Builder<'a, 'll, 'tcx>,
162+
ix: usize,
163+
) -> PlaceRef<'tcx, &'ll Value> {
160164
let cx = bx.cx;
161165
let field = self.layout.field(cx, ix);
162166
let offset = self.layout.fields.offset(ix);
@@ -379,7 +383,7 @@ impl PlaceRef<'ll, 'tcx> {
379383
}
380384

381385
pub fn project_index(&self, bx: &Builder<'a, 'll, 'tcx>, llindex: &'ll Value)
382-
-> PlaceRef<'ll, 'tcx> {
386+
-> PlaceRef<'tcx, &'ll Value> {
383387
PlaceRef {
384388
llval: bx.inbounds_gep(self.llval, &[C_usize(bx.cx, 0), llindex]),
385389
llextra: None,
@@ -389,7 +393,7 @@ impl PlaceRef<'ll, 'tcx> {
389393
}
390394

391395
pub fn project_downcast(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: usize)
392-
-> PlaceRef<'ll, 'tcx> {
396+
-> PlaceRef<'tcx, &'ll Value> {
393397
let mut downcast = *self;
394398
downcast.layout = self.layout.for_variant(bx.cx, variant_index);
395399

@@ -413,7 +417,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
413417
pub fn codegen_place(&mut self,
414418
bx: &Builder<'a, 'll, 'tcx>,
415419
place: &mir::Place<'tcx>)
416-
-> PlaceRef<'ll, 'tcx> {
420+
-> PlaceRef<'tcx, &'ll Value> {
417421
debug!("codegen_place(place={:?})", place);
418422

419423
let cx = bx.cx;

‎src/librustc_codegen_llvm/mir/rvalue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use super::place::PlaceRef;
3535
impl FunctionCx<'a, 'll, 'tcx> {
3636
pub fn codegen_rvalue(&mut self,
3737
bx: Builder<'a, 'll, 'tcx>,
38-
dest: PlaceRef<'ll, 'tcx>,
38+
dest: PlaceRef<'tcx, &'ll Value>,
3939
rvalue: &mir::Rvalue<'tcx>)
4040
-> Builder<'a, 'll, 'tcx>
4141
{
@@ -178,7 +178,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
178178
pub fn codegen_rvalue_operand(&mut self,
179179
bx: Builder<'a, 'll, 'tcx>,
180180
rvalue: &mir::Rvalue<'tcx>)
181-
-> (Builder<'a, 'll, 'tcx>, OperandRef<'ll, 'tcx>)
181+
-> (Builder<'a, 'll, 'tcx>, OperandRef<'tcx, &'ll Value>)
182182
{
183183
assert!(self.rvalue_creates_operand(rvalue), "cannot codegen {:?} to operand", rvalue);
184184

@@ -652,7 +652,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
652652
op: mir::BinOp,
653653
lhs: &'ll Value,
654654
rhs: &'ll Value,
655-
input_ty: Ty<'tcx>) -> OperandValue<'ll> {
655+
input_ty: Ty<'tcx>) -> OperandValue<&'ll Value> {
656656
// This case can currently arise only from functions marked
657657
// with #[rustc_inherit_overflow_checks] and inlined from
658658
// another crate (mostly core::num generic/#[inline] fns),

0 commit comments

Comments
 (0)
Please sign in to comment.