rustc_codegen_ssa: remove unnecessary source_locations_enabled.
This commit is contained in:
parent
1385fc4c40
commit
bdb72e7b5a
6 changed files with 13 additions and 52 deletions
|
@ -51,7 +51,6 @@ mod utils;
|
|||
pub use self::create_scope_map::compute_mir_scopes;
|
||||
pub use self::metadata::create_global_var_metadata;
|
||||
pub use self::metadata::extend_scope_to_file;
|
||||
pub use self::source_loc::set_source_location;
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
const DW_TAG_auto_variable: c_uint = 0x100;
|
||||
|
@ -193,13 +192,14 @@ impl DebugInfoBuilderMethods for Builder<'a, 'll, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_source_location(
|
||||
&mut self,
|
||||
debug_context: &mut FunctionDebugContext<&'ll DIScope>,
|
||||
scope: &'ll DIScope,
|
||||
span: Span,
|
||||
) {
|
||||
set_source_location(debug_context, &self, scope, span)
|
||||
fn set_source_location(&mut self, scope: &'ll DIScope, span: Span) {
|
||||
debug!("set_source_location: {}", self.sess().source_map().span_to_string(span));
|
||||
|
||||
let dbg_loc = self.cx().create_debug_loc(scope, span);
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMSetCurrentDebugLocation(self.llbuilder, dbg_loc);
|
||||
}
|
||||
}
|
||||
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
|
||||
gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
|
||||
|
@ -333,7 +333,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
};
|
||||
let mut fn_debug_context = FunctionDebugContext {
|
||||
scopes: IndexVec::from_elem(null_scope, &mir.source_scopes),
|
||||
source_locations_enabled: false,
|
||||
defining_crate: def_id.krate,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,38 +1,14 @@
|
|||
use super::metadata::UNKNOWN_COLUMN_NUMBER;
|
||||
use super::utils::{debug_context, span_start};
|
||||
use rustc_codegen_ssa::mir::debuginfo::FunctionDebugContext;
|
||||
|
||||
use crate::builder::Builder;
|
||||
use crate::common::CodegenCx;
|
||||
use crate::llvm::debuginfo::DIScope;
|
||||
use crate::llvm::{self, Value};
|
||||
use log::debug;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
|
||||
use libc::c_uint;
|
||||
use rustc_span::{Pos, Span};
|
||||
|
||||
/// Sets the current debug location at the beginning of the span.
|
||||
///
|
||||
/// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...).
|
||||
pub fn set_source_location<D>(
|
||||
debug_context: &FunctionDebugContext<D>,
|
||||
bx: &Builder<'_, 'll, '_>,
|
||||
scope: &'ll DIScope,
|
||||
span: Span,
|
||||
) {
|
||||
let dbg_loc = if debug_context.source_locations_enabled {
|
||||
debug!("set_source_location: {}", bx.sess().source_map().span_to_string(span));
|
||||
Some(bx.cx().create_debug_loc(scope, span))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMSetCurrentDebugLocation(bx.llbuilder, dbg_loc);
|
||||
}
|
||||
}
|
||||
|
||||
impl CodegenCx<'ll, '_> {
|
||||
pub fn create_debug_loc(&self, scope: &'ll DIScope, span: Span) -> &'ll Value {
|
||||
let loc = span_start(self, span);
|
||||
|
|
|
@ -909,7 +909,7 @@ extern "C" {
|
|||
pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
|
||||
|
||||
// Metadata
|
||||
pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: Option<&'a Value>);
|
||||
pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
|
||||
|
||||
// Terminators
|
||||
pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
|
||||
|
|
|
@ -14,7 +14,6 @@ use super::{FunctionCx, LocalRef};
|
|||
|
||||
pub struct FunctionDebugContext<D> {
|
||||
pub scopes: IndexVec<mir::SourceScope, DebugScope<D>>,
|
||||
pub source_locations_enabled: bool,
|
||||
pub defining_crate: CrateNum,
|
||||
}
|
||||
|
||||
|
@ -53,11 +52,10 @@ impl<D> DebugScope<D> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
pub fn set_debug_loc(&mut self, bx: &mut Bx, source_info: mir::SourceInfo) {
|
||||
pub fn set_debug_loc(&self, bx: &mut Bx, source_info: mir::SourceInfo) {
|
||||
let (scope, span) = self.debug_loc(source_info);
|
||||
if let Some(debug_context) = &mut self.debug_context {
|
||||
// FIXME(eddyb) get rid of this unwrap somehow.
|
||||
bx.set_source_location(debug_context, scope.unwrap(), span);
|
||||
if let Some(scope) = scope {
|
||||
bx.set_source_location(scope, span);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -230,13 +230,6 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
bx.br(fx.blocks[mir::START_BLOCK]);
|
||||
}
|
||||
|
||||
// Up until here, IR instructions for this function have explicitly not been annotated with
|
||||
// source code location, so we don't step into call setup code. From here on, source location
|
||||
// emitting should be enabled.
|
||||
if let Some(debug_context) = &mut fx.debug_context {
|
||||
debug_context.source_locations_enabled = true;
|
||||
}
|
||||
|
||||
let rpo = traversal::reverse_postorder(&mir_body);
|
||||
let mut visited = BitSet::new_empty(mir_body.basic_blocks().len());
|
||||
|
||||
|
|
|
@ -57,12 +57,7 @@ pub trait DebugInfoBuilderMethods: BackendTypes {
|
|||
indirect_offsets: &[Size],
|
||||
span: Span,
|
||||
);
|
||||
fn set_source_location(
|
||||
&mut self,
|
||||
debug_context: &mut FunctionDebugContext<Self::DIScope>,
|
||||
scope: Self::DIScope,
|
||||
span: Span,
|
||||
);
|
||||
fn set_source_location(&mut self, scope: Self::DIScope, span: Span);
|
||||
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
|
||||
fn set_var_name(&mut self, value: Self::Value, name: &str);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue