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::create_scope_map::compute_mir_scopes;
|
||||||
pub use self::metadata::create_global_var_metadata;
|
pub use self::metadata::create_global_var_metadata;
|
||||||
pub use self::metadata::extend_scope_to_file;
|
pub use self::metadata::extend_scope_to_file;
|
||||||
pub use self::source_loc::set_source_location;
|
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
const DW_TAG_auto_variable: c_uint = 0x100;
|
const DW_TAG_auto_variable: c_uint = 0x100;
|
||||||
|
@ -193,13 +192,14 @@ impl DebugInfoBuilderMethods for Builder<'a, 'll, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_source_location(
|
fn set_source_location(&mut self, scope: &'ll DIScope, span: Span) {
|
||||||
&mut self,
|
debug!("set_source_location: {}", self.sess().source_map().span_to_string(span));
|
||||||
debug_context: &mut FunctionDebugContext<&'ll DIScope>,
|
|
||||||
scope: &'ll DIScope,
|
let dbg_loc = self.cx().create_debug_loc(scope, span);
|
||||||
span: Span,
|
|
||||||
) {
|
unsafe {
|
||||||
set_source_location(debug_context, &self, scope, span)
|
llvm::LLVMSetCurrentDebugLocation(self.llbuilder, dbg_loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
|
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
|
||||||
gdb::insert_reference_to_gdb_debug_scripts_section_global(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 {
|
let mut fn_debug_context = FunctionDebugContext {
|
||||||
scopes: IndexVec::from_elem(null_scope, &mir.source_scopes),
|
scopes: IndexVec::from_elem(null_scope, &mir.source_scopes),
|
||||||
source_locations_enabled: false,
|
|
||||||
defining_crate: def_id.krate,
|
defining_crate: def_id.krate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,38 +1,14 @@
|
||||||
use super::metadata::UNKNOWN_COLUMN_NUMBER;
|
use super::metadata::UNKNOWN_COLUMN_NUMBER;
|
||||||
use super::utils::{debug_context, span_start};
|
use super::utils::{debug_context, span_start};
|
||||||
use rustc_codegen_ssa::mir::debuginfo::FunctionDebugContext;
|
|
||||||
|
|
||||||
use crate::builder::Builder;
|
|
||||||
use crate::common::CodegenCx;
|
use crate::common::CodegenCx;
|
||||||
use crate::llvm::debuginfo::DIScope;
|
use crate::llvm::debuginfo::DIScope;
|
||||||
use crate::llvm::{self, Value};
|
use crate::llvm::{self, Value};
|
||||||
use log::debug;
|
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
|
|
||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use rustc_span::{Pos, Span};
|
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, '_> {
|
impl CodegenCx<'ll, '_> {
|
||||||
pub fn create_debug_loc(&self, scope: &'ll DIScope, span: Span) -> &'ll Value {
|
pub fn create_debug_loc(&self, scope: &'ll DIScope, span: Span) -> &'ll Value {
|
||||||
let loc = span_start(self, span);
|
let loc = span_start(self, span);
|
||||||
|
|
|
@ -909,7 +909,7 @@ extern "C" {
|
||||||
pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
|
pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: Option<&'a Value>);
|
pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
|
||||||
|
|
||||||
// Terminators
|
// Terminators
|
||||||
pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
|
pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
|
||||||
|
|
|
@ -14,7 +14,6 @@ use super::{FunctionCx, LocalRef};
|
||||||
|
|
||||||
pub struct FunctionDebugContext<D> {
|
pub struct FunctionDebugContext<D> {
|
||||||
pub scopes: IndexVec<mir::SourceScope, DebugScope<D>>,
|
pub scopes: IndexVec<mir::SourceScope, DebugScope<D>>,
|
||||||
pub source_locations_enabled: bool,
|
|
||||||
pub defining_crate: CrateNum,
|
pub defining_crate: CrateNum,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,11 +52,10 @@ impl<D> DebugScope<D> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
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);
|
let (scope, span) = self.debug_loc(source_info);
|
||||||
if let Some(debug_context) = &mut self.debug_context {
|
if let Some(scope) = scope {
|
||||||
// FIXME(eddyb) get rid of this unwrap somehow.
|
bx.set_source_location(scope, span);
|
||||||
bx.set_source_location(debug_context, scope.unwrap(), span);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,13 +230,6 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx.br(fx.blocks[mir::START_BLOCK]);
|
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 rpo = traversal::reverse_postorder(&mir_body);
|
||||||
let mut visited = BitSet::new_empty(mir_body.basic_blocks().len());
|
let mut visited = BitSet::new_empty(mir_body.basic_blocks().len());
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,7 @@ pub trait DebugInfoBuilderMethods: BackendTypes {
|
||||||
indirect_offsets: &[Size],
|
indirect_offsets: &[Size],
|
||||||
span: Span,
|
span: Span,
|
||||||
);
|
);
|
||||||
fn set_source_location(
|
fn set_source_location(&mut self, scope: Self::DIScope, span: Span);
|
||||||
&mut self,
|
|
||||||
debug_context: &mut FunctionDebugContext<Self::DIScope>,
|
|
||||||
scope: Self::DIScope,
|
|
||||||
span: Span,
|
|
||||||
);
|
|
||||||
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
|
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
|
||||||
fn set_var_name(&mut self, value: Self::Value, name: &str);
|
fn set_var_name(&mut self, value: Self::Value, name: &str);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue