Skip to content

Commit 794ecd9

Browse files
committed
[WIP] Make some debug info methods take &mut FunctionDebugContext
declare_local still takes &FunctionDebugContext, because of borrowck errors
1 parent ab8f152 commit 794ecd9

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/librustc_codegen_llvm/debuginfo/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
216216

217217
fn set_source_location(
218218
&mut self,
219-
debug_context: &FunctionDebugContext<&'ll DISubprogram>,
219+
debug_context: &mut FunctionDebugContext<&'ll DISubprogram>,
220220
scope: Option<&'ll DIScope>,
221221
span: Span,
222222
) {
@@ -519,7 +519,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
519519
fn create_mir_scopes(
520520
&self,
521521
mir: &mir::Mir<'_>,
522-
debug_context: &FunctionDebugContext<&'ll DISubprogram>,
522+
debug_context: &mut FunctionDebugContext<&'ll DISubprogram>,
523523
) -> IndexVec<mir::SourceScope, MirDebugScope<&'ll DIScope>> {
524524
create_scope_map::create_mir_scopes(self, mir, debug_context)
525525
}

src/librustc_codegen_ssa/mir/mod.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
104104
source_info: mir::SourceInfo
105105
) {
106106
let (scope, span) = self.debug_loc(source_info);
107-
bx.set_source_location(&self.debug_context, scope, span);
107+
bx.set_source_location(&mut self.debug_context, scope, span);
108108
}
109109

110110
pub fn debug_loc(&self, source_info: mir::SourceInfo) -> (Option<Bx::DIScope>, Span) {
@@ -203,7 +203,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
203203

204204
let fn_ty = cx.new_fn_type(sig, &[]);
205205
debug!("fn_ty: {:?}", fn_ty);
206-
let debug_context =
206+
let mut debug_context =
207207
cx.create_function_debug_context(instance, sig, llfn, mir);
208208
let mut bx = Bx::new_block(cx, llfn, "start");
209209

@@ -225,7 +225,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
225225
}).collect();
226226

227227
// Compute debuginfo scopes from MIR scopes.
228-
let scopes = cx.create_mir_scopes(mir, &debug_context);
228+
let scopes = cx.create_mir_scopes(mir, &mut debug_context);
229229
let (landing_pads, funclets) = create_funclets(mir, &mut bx, &cleanup_kinds, &block_bxs);
230230

231231
let mut fx = FunctionCx {
@@ -253,7 +253,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
253253
// FIXME(dlrobertson): This is ugly. Find a better way of getting the `PlaceRef` or
254254
// `LocalRef` from `arg_local_refs`
255255
let mut va_list_ref = None;
256-
let args = arg_local_refs(&mut bx, &fx, &fx.scopes, &memory_locals, &mut va_list_ref);
256+
let args = arg_local_refs(&mut bx, &fx, &memory_locals, &mut va_list_ref);
257257
fx.va_list_ref = va_list_ref;
258258

259259
let mut allocate_local = |local| {
@@ -430,10 +430,6 @@ fn create_funclets<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
430430
fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
431431
bx: &mut Bx,
432432
fx: &FunctionCx<'a, 'tcx, Bx>,
433-
scopes: &IndexVec<
434-
mir::SourceScope,
435-
debuginfo::MirDebugScope<Bx::DIScope>
436-
>,
437433
memory_locals: &BitSet<mir::Local>,
438434
va_list_ref: &mut Option<PlaceRef<'tcx, Bx::Value>>,
439435
) -> Vec<LocalRef<'tcx, Bx::Value>> {
@@ -443,7 +439,7 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
443439
let mut llarg_idx = fx.fn_ty.ret.is_indirect() as usize;
444440

445441
// Get the argument scope, if it exists and if we need it.
446-
let arg_scope = scopes[mir::OUTERMOST_SOURCE_SCOPE];
442+
let arg_scope = fx.scopes[mir::OUTERMOST_SOURCE_SCOPE];
447443
let arg_scope = if bx.sess().opts.debuginfo == DebugInfo::Full {
448444
arg_scope.scope_metadata
449445
} else {

src/librustc_codegen_ssa/traits/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub trait DebugInfoMethods<'tcx>: BackendTypes {
2828
fn create_mir_scopes(
2929
&self,
3030
mir: &mir::Mir<'_>,
31-
debug_context: &FunctionDebugContext<Self::DIScope>,
31+
debug_context: &mut FunctionDebugContext<Self::DIScope>,
3232
) -> IndexVec<mir::SourceScope, MirDebugScope<Self::DIScope>>;
3333
fn extend_scope_to_file(
3434
&self,
@@ -53,7 +53,7 @@ pub trait DebugInfoBuilderMethods<'tcx>: BackendTypes {
5353
);
5454
fn set_source_location(
5555
&mut self,
56-
debug_context: &FunctionDebugContext<Self::DIScope>,
56+
debug_context: &mut FunctionDebugContext<Self::DIScope>,
5757
scope: Option<Self::DIScope>,
5858
span: Span,
5959
);

0 commit comments

Comments
 (0)