When the required discriminator value exceeds LLVM's limits, drop the debug info for the function instead of panicking.
The maximum discriminator value LLVM can currently encode is 2^12. If macro use results in more than 2^12 calls to the same function attributed to the same callsite, and those calls are MIR-inlined, we will require more than the maximum discriminator value to completely represent the debug information. Once we reach that point drop the debug info instead.
This commit is contained in:
parent
17410a7ba2
commit
fcbc3d97b8
1 changed files with 9 additions and 9 deletions
|
@ -113,15 +113,15 @@ fn make_mir_scope<'gcc, 'tcx>(
|
||||||
let scope_data = &mir.source_scopes[scope];
|
let scope_data = &mir.source_scopes[scope];
|
||||||
let parent_scope = if let Some(parent) = scope_data.parent_scope {
|
let parent_scope = if let Some(parent) = scope_data.parent_scope {
|
||||||
make_mir_scope(cx, _instance, mir, variables, debug_context, instantiated, parent);
|
make_mir_scope(cx, _instance, mir, variables, debug_context, instantiated, parent);
|
||||||
debug_context.scopes[parent]
|
debug_context.scopes[parent].unwrap()
|
||||||
} else {
|
} else {
|
||||||
// The root is the function itself.
|
// The root is the function itself.
|
||||||
let file = cx.sess().source_map().lookup_source_file(mir.span.lo());
|
let file = cx.sess().source_map().lookup_source_file(mir.span.lo());
|
||||||
debug_context.scopes[scope] = DebugScope {
|
debug_context.scopes[scope] = Some(DebugScope {
|
||||||
file_start_pos: file.start_pos,
|
file_start_pos: file.start_pos,
|
||||||
file_end_pos: file.end_position(),
|
file_end_pos: file.end_position(),
|
||||||
..debug_context.scopes[scope]
|
..debug_context.scopes[scope].unwrap()
|
||||||
};
|
});
|
||||||
instantiated.insert(scope);
|
instantiated.insert(scope);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -130,7 +130,7 @@ fn make_mir_scope<'gcc, 'tcx>(
|
||||||
if !vars.contains(scope) && scope_data.inlined.is_none() {
|
if !vars.contains(scope) && scope_data.inlined.is_none() {
|
||||||
// Do not create a DIScope if there are no variables defined in this
|
// Do not create a DIScope if there are no variables defined in this
|
||||||
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
|
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
|
||||||
debug_context.scopes[scope] = parent_scope;
|
debug_context.scopes[scope] = Some(parent_scope);
|
||||||
instantiated.insert(scope);
|
instantiated.insert(scope);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -157,12 +157,12 @@ fn make_mir_scope<'gcc, 'tcx>(
|
||||||
// TODO(tempdragon): dbg_scope: Add support for scope extension here.
|
// TODO(tempdragon): dbg_scope: Add support for scope extension here.
|
||||||
inlined_at.or(p_inlined_at);
|
inlined_at.or(p_inlined_at);
|
||||||
|
|
||||||
debug_context.scopes[scope] = DebugScope {
|
debug_context.scopes[scope] = Some(DebugScope {
|
||||||
dbg_scope,
|
dbg_scope,
|
||||||
inlined_at,
|
inlined_at,
|
||||||
file_start_pos: loc.file.start_pos,
|
file_start_pos: loc.file.start_pos,
|
||||||
file_end_pos: loc.file.end_position(),
|
file_end_pos: loc.file.end_position(),
|
||||||
};
|
});
|
||||||
instantiated.insert(scope);
|
instantiated.insert(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,12 +232,12 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize fn debug context (including scopes).
|
// Initialize fn debug context (including scopes).
|
||||||
let empty_scope = DebugScope {
|
let empty_scope = Some(DebugScope {
|
||||||
dbg_scope: self.dbg_scope_fn(instance, fn_abi, Some(llfn)),
|
dbg_scope: self.dbg_scope_fn(instance, fn_abi, Some(llfn)),
|
||||||
inlined_at: None,
|
inlined_at: None,
|
||||||
file_start_pos: BytePos(0),
|
file_start_pos: BytePos(0),
|
||||||
file_end_pos: BytePos(0),
|
file_end_pos: BytePos(0),
|
||||||
};
|
});
|
||||||
let mut fn_debug_context = FunctionDebugContext {
|
let mut fn_debug_context = FunctionDebugContext {
|
||||||
scopes: IndexVec::from_elem(empty_scope, mir.source_scopes.as_slice()),
|
scopes: IndexVec::from_elem(empty_scope, mir.source_scopes.as_slice()),
|
||||||
inlined_function_scopes: Default::default(),
|
inlined_function_scopes: Default::default(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue