parameterize BitVector and BitMatrix by their index types
This commit is contained in:
parent
a54401ebcc
commit
145155dc96
16 changed files with 119 additions and 96 deletions
|
|
@ -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<SourceScope>,
|
||||
debug_context: &FunctionDebugContextData,
|
||||
scope: SourceScope,
|
||||
scopes: &mut IndexVec<SourceScope, MirDebugScope>) {
|
||||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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<mir::Local> {
|
||||
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<mir::BasicBlock>,
|
||||
non_ssa_locals: BitVector,
|
||||
non_ssa_locals: BitVector<mir::Local>,
|
||||
// The location of the first visited direct assignment to each
|
||||
// local, or an invalid location (out of bounds `block` index).
|
||||
first_assignment: IndexVec<mir::Local, Location>
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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<mir::SourceScope, debuginfo::MirDebugScope>,
|
||||
memory_locals: &BitVector)
|
||||
memory_locals: &BitVector<mir::Local>)
|
||||
-> Vec<LocalRef<'tcx>> {
|
||||
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue