From 145155dc96757002c7b2e9de8489416e2fdbbd57 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 22 Jul 2018 19:23:39 +0300 Subject: parameterize `BitVector` and `BitMatrix` by their index types --- src/librustc_codegen_llvm/debuginfo/create_scope_map.rs | 6 +++--- src/librustc_codegen_llvm/mir/analyze.rs | 6 +++--- src/librustc_codegen_llvm/mir/mod.rs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/librustc_codegen_llvm') diff --git a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs index 9ced0f5f4ec..fcde7f9bbc3 100644 --- a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs +++ b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs @@ -65,7 +65,7 @@ pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebu let mut has_variables = BitVector::new(mir.source_scopes.len()); for var in mir.vars_iter() { let decl = &mir.local_decls[var]; - has_variables.insert(decl.visibility_scope.index()); + has_variables.insert(decl.visibility_scope); } // Instantiate all scopes. @@ -79,7 +79,7 @@ pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebu fn make_mir_scope(cx: &CodegenCx, mir: &Mir, - has_variables: &BitVector, + has_variables: &BitVector, debug_context: &FunctionDebugContextData, scope: SourceScope, scopes: &mut IndexVec) { @@ -102,7 +102,7 @@ fn make_mir_scope(cx: &CodegenCx, return; }; - if !has_variables.contains(scope.index()) { + if !has_variables.contains(scope) { // Do not create a DIScope if there are no variables // defined in this MIR Scope, to avoid debuginfo bloat. diff --git a/src/librustc_codegen_llvm/mir/analyze.rs b/src/librustc_codegen_llvm/mir/analyze.rs index efd829c283f..e105baba8aa 100644 --- a/src/librustc_codegen_llvm/mir/analyze.rs +++ b/src/librustc_codegen_llvm/mir/analyze.rs @@ -22,7 +22,7 @@ use rustc::ty::layout::LayoutOf; use type_of::LayoutLlvmExt; use super::FunctionCx; -pub fn non_ssa_locals<'a, 'tcx>(fx: &FunctionCx<'a, 'tcx>) -> BitVector { +pub fn non_ssa_locals<'a, 'tcx>(fx: &FunctionCx<'a, 'tcx>) -> BitVector { let mir = fx.mir; let mut analyzer = LocalAnalyzer::new(fx); @@ -54,7 +54,7 @@ pub fn non_ssa_locals<'a, 'tcx>(fx: &FunctionCx<'a, 'tcx>) -> BitVector { struct LocalAnalyzer<'mir, 'a: 'mir, 'tcx: 'a> { fx: &'mir FunctionCx<'a, 'tcx>, dominators: Dominators, - non_ssa_locals: BitVector, + non_ssa_locals: BitVector, // The location of the first visited direct assignment to each // local, or an invalid location (out of bounds `block` index). first_assignment: IndexVec @@ -90,7 +90,7 @@ impl<'mir, 'a, 'tcx> LocalAnalyzer<'mir, 'a, 'tcx> { fn not_ssa(&mut self, local: mir::Local) { debug!("marking {:?} as non-SSA", local); - self.non_ssa_locals.insert(local.index()); + self.non_ssa_locals.insert(local); } fn assign(&mut self, local: mir::Local, location: Location) { diff --git a/src/librustc_codegen_llvm/mir/mod.rs b/src/librustc_codegen_llvm/mir/mod.rs index 608539dd3fa..312939408c6 100644 --- a/src/librustc_codegen_llvm/mir/mod.rs +++ b/src/librustc_codegen_llvm/mir/mod.rs @@ -268,7 +268,7 @@ pub fn codegen_mir<'a, 'tcx: 'a>( let debug_scope = fx.scopes[decl.visibility_scope]; let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == FullDebugInfo; - if !memory_locals.contains(local.index()) && !dbg { + if !memory_locals.contains(local) && !dbg { debug!("alloc: {:?} ({}) -> operand", local, name); return LocalRef::new_operand(bx.cx, layout); } @@ -291,7 +291,7 @@ pub fn codegen_mir<'a, 'tcx: 'a>( debug!("alloc: {:?} (return place) -> place", local); let llretptr = llvm::get_param(llfn, 0); LocalRef::Place(PlaceRef::new_sized(llretptr, layout, layout.align)) - } else if memory_locals.contains(local.index()) { + } else if memory_locals.contains(local) { debug!("alloc: {:?} -> place", local); LocalRef::Place(PlaceRef::alloca(&bx, layout, &format!("{:?}", local))) } else { @@ -415,7 +415,7 @@ fn create_funclets<'a, 'tcx>( fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>, fx: &FunctionCx<'a, 'tcx>, scopes: &IndexVec, - memory_locals: &BitVector) + memory_locals: &BitVector) -> Vec> { let mir = fx.mir; let tcx = bx.tcx(); @@ -487,7 +487,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>, llarg_idx += 1; } - if arg_scope.is_none() && !memory_locals.contains(local.index()) { + if arg_scope.is_none() && !memory_locals.contains(local) { // We don't have to cast or keep the argument in the alloca. // FIXME(eddyb): We should figure out how to use llvm.dbg.value instead // of putting everything in allocas just so we can use llvm.dbg.declare. -- cgit 1.4.1-3-g733a5