diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index b417f552f7d0ee8f0114d1bcf8dbdc1ba807a24b..9e9467e3645440f837b536c817857fe8ed133a92 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -172,7 +172,7 @@ fn store_fn_arg( &self, bx: &Builder<'_, 'll, 'tcx>, idx: &mut usize, - dst: PlaceRef<'tcx, &'ll Value>, + dst: PlaceRef<'tcx, &'ll Value>, ); } diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 9db4015013e28a7fa810ebf41ea6ebb776142ef8..927ad8aecd8440b50ab76e3ba574b0846988da47 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -26,12 +26,12 @@ // All Builders must have an llfn associated with them #[must_use] -pub struct Builder<'a, 'll: 'a, 'tcx: 'll> { +pub struct Builder<'a, 'll: 'a, 'tcx: 'll, V: 'll = &'ll Value> { pub llbuilder: &'ll mut llvm::Builder<'ll>, - pub cx: &'a CodegenCx<'ll, 'tcx>, + pub cx: &'a CodegenCx<'ll, 'tcx, V>, } -impl Drop for Builder<'a, 'll, 'tcx> { +impl Drop for Builder<'_, '_, '_, V> { fn drop(&mut self) { unsafe { llvm::LLVMDisposeBuilder(&mut *(self.llbuilder as *mut _)); diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index d6fd069071548cf2b259479923d44417ba215893..4c405150532bd221b9b9475ee7dd2b6d48f9327d 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -45,7 +45,7 @@ /// There is one `CodegenCx` per compilation unit. Each one has its own LLVM /// `llvm::Context` so that several compilation units may be optimized in parallel. /// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`. -pub struct CodegenCx<'a, 'tcx: 'a> { +pub struct CodegenCx<'a, 'tcx: 'a, V = &'a Value> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub check_overflow: bool, pub use_dll_storage_attrs: bool, @@ -57,12 +57,11 @@ pub struct CodegenCx<'a, 'tcx: 'a> { pub codegen_unit: Arc>, /// Cache instances of monomorphic and polymorphic items - pub instances: RefCell, &'a Value>>, + pub instances: RefCell, V>>, /// Cache generated vtables - pub vtables: RefCell, ty::PolyExistentialTraitRef<'tcx>), - &'a Value>>, + pub vtables: RefCell, ty::PolyExistentialTraitRef<'tcx>), V>>, /// Cache of constant strings, - pub const_cstr_cache: RefCell>, + pub const_cstr_cache: RefCell>, /// Reverse-direction for const ptrs cast from globals. /// Key is a Value holding a *T, @@ -72,20 +71,20 @@ pub struct CodegenCx<'a, 'tcx: 'a> { /// when we ptrcast, and we have to ptrcast during codegen /// of a [T] const because we form a slice, a (*T,usize) pair, not /// a pointer to an LLVM array type. Similar for trait objects. - pub const_unsized: RefCell>, + pub const_unsized: RefCell>, /// Cache of emitted const globals (value -> global) - pub const_globals: RefCell>, + pub const_globals: RefCell>, /// List of globals for static variables which need to be passed to the /// LLVM function ReplaceAllUsesWith (RAUW) when codegen is complete. /// (We have to make sure we don't invalidate any Values referring /// to constants.) - pub statics_to_rauw: RefCell>, + pub statics_to_rauw: RefCell>, /// Statics that will be placed in the llvm.used variable /// See http://llvm.org/docs/LangRef.html#the-llvm-used-global-variable for details - pub used_statics: RefCell>, + pub used_statics: RefCell>, pub lltypes: RefCell, Option), &'a Type>>, pub scalar_lltypes: RefCell, &'a Type>>, @@ -94,11 +93,11 @@ pub struct CodegenCx<'a, 'tcx: 'a> { pub dbg_cx: Option>, - eh_personality: Cell>, - eh_unwind_resume: Cell>, - pub rust_try_fn: Cell>, + eh_personality: Cell>, + eh_unwind_resume: Cell>, + pub rust_try_fn: Cell>, - intrinsics: RefCell>, + intrinsics: RefCell>, /// A counter that is used for generating local symbol names local_gen_sym_counter: Cell, diff --git a/src/librustc_codegen_llvm/mir/analyze.rs b/src/librustc_codegen_llvm/mir/analyze.rs index 2af772bd7ce22abaf9f3229c97c56c674324588d..14f48a4ab63dcd31c23dbe493371e1888c4ef5cb 100644 --- a/src/librustc_codegen_llvm/mir/analyze.rs +++ b/src/librustc_codegen_llvm/mir/analyze.rs @@ -21,8 +21,9 @@ use rustc::ty::layout::LayoutOf; use type_of::LayoutLlvmExt; use super::FunctionCx; +use value::Value; -pub fn non_ssa_locals(fx: &FunctionCx<'a, 'll, 'tcx>) -> BitSet { +pub fn non_ssa_locals(fx: &FunctionCx<'a, 'll, 'tcx, &'ll Value>) -> BitSet { let mir = fx.mir; let mut analyzer = LocalAnalyzer::new(fx); @@ -51,8 +52,8 @@ pub fn non_ssa_locals(fx: &FunctionCx<'a, 'll, 'tcx>) -> BitSet { analyzer.non_ssa_locals } -struct LocalAnalyzer<'mir, 'a: 'mir, 'll: 'a, 'tcx: 'll> { - fx: &'mir FunctionCx<'a, 'll, 'tcx>, +struct LocalAnalyzer<'mir, 'a: 'mir, 'll: 'a, 'tcx: 'll, V: 'll> { + fx: &'mir FunctionCx<'a, 'll, 'tcx, V>, dominators: Dominators, non_ssa_locals: BitSet, // The location of the first visited direct assignment to each @@ -60,8 +61,8 @@ struct LocalAnalyzer<'mir, 'a: 'mir, 'll: 'a, 'tcx: 'll> { first_assignment: IndexVec } -impl LocalAnalyzer<'mir, 'a, 'll, 'tcx> { - fn new(fx: &'mir FunctionCx<'a, 'll, 'tcx>) -> Self { +impl LocalAnalyzer<'mir, 'a, 'll, 'tcx, &'ll Value> { + fn new(fx: &'mir FunctionCx<'a, 'll, 'tcx, &'ll Value>) -> Self { let invalid_location = mir::BasicBlock::new(fx.mir.basic_blocks().len()).start_location(); let mut analyzer = LocalAnalyzer { @@ -102,7 +103,7 @@ fn assign(&mut self, local: mir::Local, location: Location) { } } -impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> { +impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx, &'ll Value> { fn visit_assign(&mut self, block: mir::BasicBlock, place: &mir::Place<'tcx>, diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs index aeca4f1469ffc0ef73e139853b9d715b97de9f05..aade88648641498bf4c8f164d45ca48c13fbf3c3 100644 --- a/src/librustc_codegen_llvm/mir/block.rs +++ b/src/librustc_codegen_llvm/mir/block.rs @@ -34,7 +34,7 @@ use super::operand::OperandRef; use super::operand::OperandValue::{Pair, Ref, Immediate}; -impl FunctionCx<'a, 'll, 'tcx> { +impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { pub fn codegen_block(&mut self, bb: mir::BasicBlock) { let mut bx = self.build_block(bb); let data = &self.mir[bb]; diff --git a/src/librustc_codegen_llvm/mir/constant.rs b/src/librustc_codegen_llvm/mir/constant.rs index 586a490774023f9f000a68b8c63da9eb2b4636c1..2c241d938e5436db54cba5b21cb86ee4788c0f65 100644 --- a/src/librustc_codegen_llvm/mir/constant.rs +++ b/src/librustc_codegen_llvm/mir/constant.rs @@ -139,7 +139,7 @@ pub fn codegen_static_initializer( Ok((const_alloc_to_llvm(cx, alloc), alloc)) } -impl FunctionCx<'a, 'll, 'tcx> { +impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { fn fully_evaluate( &mut self, bx: &Builder<'a, 'll, 'tcx>, diff --git a/src/librustc_codegen_llvm/mir/mod.rs b/src/librustc_codegen_llvm/mir/mod.rs index b96305e08e0f97f308ab5128c8ff9e0429c2fdd4..7eda7ea0b7d7476cc87fc6f63588ac0bd64ec710 100644 --- a/src/librustc_codegen_llvm/mir/mod.rs +++ b/src/librustc_codegen_llvm/mir/mod.rs @@ -44,14 +44,14 @@ use self::operand::{OperandRef, OperandValue}; /// Master context for codegenning from MIR. -pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> { +pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll, V> { instance: Instance<'tcx>, mir: &'a mir::Mir<'tcx>, debug_context: FunctionDebugContext<'ll>, - llfn: &'ll Value, + llfn: V, cx: &'a CodegenCx<'ll, 'tcx>, @@ -64,7 +64,7 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> { /// don't really care about it very much. Anyway, this value /// contains an alloca into which the personality is stored and /// then later loaded when generating the DIVERGE_BLOCK. - personality_slot: Option>, + personality_slot: Option>, /// A `Block` for each MIR `BasicBlock` blocks: IndexVec, @@ -73,7 +73,8 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> { cleanup_kinds: IndexVec, /// When targeting MSVC, this stores the cleanup info for each funclet - /// BB. This is initialized as we compute the funclets' head block in RPO. + /// BB. Thisrustup component add rustfmt-preview is initialized as we compute the funclets' + /// head block in RPO. funclets: &'a IndexVec>>, /// This stores the landing-pad block for a given BB, computed lazily on GNU @@ -98,7 +99,7 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> { /// /// Avoiding allocs can also be important for certain intrinsics, /// notably `expect`. - locals: IndexVec>, + locals: IndexVec>, /// Debug information for MIR scopes. scopes: IndexVec>, @@ -107,7 +108,7 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> { param_substs: &'tcx Substs<'tcx>, } -impl FunctionCx<'a, 'll, 'tcx> { +impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { pub fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx> { @@ -437,7 +438,7 @@ fn create_funclets( /// indirect. fn arg_local_refs( bx: &Builder<'a, 'll, 'tcx>, - fx: &FunctionCx<'a, 'll, 'tcx>, + fx: &FunctionCx<'a, 'll, 'tcx, &'ll Value>, scopes: &IndexVec>, memory_locals: &BitSet, ) -> Vec> { diff --git a/src/librustc_codegen_llvm/mir/operand.rs b/src/librustc_codegen_llvm/mir/operand.rs index c24f101177a10da47b7b840face2ee9fdd0cddf5..32609b06952beacf40a5093b0023bcf9be52e97a 100644 --- a/src/librustc_codegen_llvm/mir/operand.rs +++ b/src/librustc_codegen_llvm/mir/operand.rs @@ -16,7 +16,7 @@ use base; use common::{CodegenCx, C_undef, C_usize}; use builder::{Builder, MemFlags}; -use value::Value; +use value::{Value, ValueTrait}; use type_of::LayoutLlvmExt; use type_::Type; use glue; @@ -60,7 +60,7 @@ pub struct OperandRef<'tcx, V> { pub layout: TyLayout<'tcx>, } -impl fmt::Debug for OperandRef<'tcx, &'ll Value> { +impl fmt::Debug for OperandRef<'tcx, &'ll Value> where Value: ValueTrait { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "OperandRef({:?} @ {:?})", self.val, self.layout) } @@ -344,7 +344,7 @@ pub fn store_unsized( } } -impl FunctionCx<'a, 'll, 'tcx> { +impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { fn maybe_codegen_consume_direct(&mut self, bx: &Builder<'a, 'll, 'tcx>, place: &mir::Place<'tcx>) diff --git a/src/librustc_codegen_llvm/mir/place.rs b/src/librustc_codegen_llvm/mir/place.rs index 46108615562afcd382a4b8f76307c76e4dcdeb93..4dc9eeb5a9ff789c443e5d845525b88eb5c4b5f0 100644 --- a/src/librustc_codegen_llvm/mir/place.rs +++ b/src/librustc_codegen_llvm/mir/place.rs @@ -430,7 +430,7 @@ pub fn storage_dead(&self, bx: &Builder<'a, 'll, 'tcx>) { } } -impl FunctionCx<'a, 'll, 'tcx> { +impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { pub fn codegen_place(&mut self, bx: &Builder<'a, 'll, 'tcx>, place: &mir::Place<'tcx>) diff --git a/src/librustc_codegen_llvm/mir/rvalue.rs b/src/librustc_codegen_llvm/mir/rvalue.rs index 580931fdbb3c57d70ca9e155a44a8c43303e7e8a..af166fe501e7f38dafc55135090cbc57227212fa 100644 --- a/src/librustc_codegen_llvm/mir/rvalue.rs +++ b/src/librustc_codegen_llvm/mir/rvalue.rs @@ -32,7 +32,7 @@ use super::operand::{OperandRef, OperandValue}; use super::place::PlaceRef; -impl FunctionCx<'a, 'll, 'tcx> { +impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { pub fn codegen_rvalue(&mut self, bx: Builder<'a, 'll, 'tcx>, dest: PlaceRef<'tcx, &'ll Value>, diff --git a/src/librustc_codegen_llvm/mir/statement.rs b/src/librustc_codegen_llvm/mir/statement.rs index 8bda2c98594e500e7b3844d7648c56f4a22e016a..8fa5a8cc5510302fc44f95bb7d370b291f5c2bed 100644 --- a/src/librustc_codegen_llvm/mir/statement.rs +++ b/src/librustc_codegen_llvm/mir/statement.rs @@ -16,8 +16,9 @@ use super::FunctionCx; use super::LocalRef; use super::OperandValue; +use value::Value; -impl FunctionCx<'a, 'll, 'tcx> { +impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { pub fn codegen_statement(&mut self, bx: Builder<'a, 'll, 'tcx>, statement: &mir::Statement<'tcx>) diff --git a/src/librustc_codegen_llvm/value.rs b/src/librustc_codegen_llvm/value.rs index 4bf5b09baa6294ffbfd022bdb4bc8e5646f3cdfa..357cc8fbf80e8439f7b58b9b84761be42c303148 100644 --- a/src/librustc_codegen_llvm/value.rs +++ b/src/librustc_codegen_llvm/value.rs @@ -15,12 +15,16 @@ use std::fmt; use std::hash::{Hash, Hasher}; +pub trait ValueTrait: fmt::Debug {} + impl PartialEq for Value { fn eq(&self, other: &Self) -> bool { self as *const _ == other as *const _ } } +impl ValueTrait for Value {} + impl Eq for Value {} impl Hash for Value {