Skip to content

Commit bdb72e7

Browse files
committed
rustc_codegen_ssa: remove unnecessary source_locations_enabled.
1 parent 1385fc4 commit bdb72e7

File tree

6 files changed

+13
-52
lines changed

6 files changed

+13
-52
lines changed

src/librustc_codegen_llvm/debuginfo/mod.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ mod utils;
5151
pub use self::create_scope_map::compute_mir_scopes;
5252
pub use self::metadata::create_global_var_metadata;
5353
pub use self::metadata::extend_scope_to_file;
54-
pub use self::source_loc::set_source_location;
5554

5655
#[allow(non_upper_case_globals)]
5756
const DW_TAG_auto_variable: c_uint = 0x100;
@@ -193,13 +192,14 @@ impl DebugInfoBuilderMethods for Builder<'a, 'll, 'tcx> {
193192
}
194193
}
195194

196-
fn set_source_location(
197-
&mut self,
198-
debug_context: &mut FunctionDebugContext<&'ll DIScope>,
199-
scope: &'ll DIScope,
200-
span: Span,
201-
) {
202-
set_source_location(debug_context, &self, scope, span)
195+
fn set_source_location(&mut self, scope: &'ll DIScope, span: Span) {
196+
debug!("set_source_location: {}", self.sess().source_map().span_to_string(span));
197+
198+
let dbg_loc = self.cx().create_debug_loc(scope, span);
199+
200+
unsafe {
201+
llvm::LLVMSetCurrentDebugLocation(self.llbuilder, dbg_loc);
202+
}
203203
}
204204
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
205205
gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
@@ -333,7 +333,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
333333
};
334334
let mut fn_debug_context = FunctionDebugContext {
335335
scopes: IndexVec::from_elem(null_scope, &mir.source_scopes),
336-
source_locations_enabled: false,
337336
defining_crate: def_id.krate,
338337
};
339338

src/librustc_codegen_llvm/debuginfo/source_loc.rs

-24
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,14 @@
11
use super::metadata::UNKNOWN_COLUMN_NUMBER;
22
use super::utils::{debug_context, span_start};
3-
use rustc_codegen_ssa::mir::debuginfo::FunctionDebugContext;
43

5-
use crate::builder::Builder;
64
use crate::common::CodegenCx;
75
use crate::llvm::debuginfo::DIScope;
86
use crate::llvm::{self, Value};
9-
use log::debug;
107
use rustc_codegen_ssa::traits::*;
118

129
use libc::c_uint;
1310
use rustc_span::{Pos, Span};
1411

15-
/// Sets the current debug location at the beginning of the span.
16-
///
17-
/// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...).
18-
pub fn set_source_location<D>(
19-
debug_context: &FunctionDebugContext<D>,
20-
bx: &Builder<'_, 'll, '_>,
21-
scope: &'ll DIScope,
22-
span: Span,
23-
) {
24-
let dbg_loc = if debug_context.source_locations_enabled {
25-
debug!("set_source_location: {}", bx.sess().source_map().span_to_string(span));
26-
Some(bx.cx().create_debug_loc(scope, span))
27-
} else {
28-
None
29-
};
30-
31-
unsafe {
32-
llvm::LLVMSetCurrentDebugLocation(bx.llbuilder, dbg_loc);
33-
}
34-
}
35-
3612
impl CodegenCx<'ll, '_> {
3713
pub fn create_debug_loc(&self, scope: &'ll DIScope, span: Span) -> &'ll Value {
3814
let loc = span_start(self, span);

src/librustc_codegen_llvm/llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ extern "C" {
909909
pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
910910

911911
// Metadata
912-
pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: Option<&'a Value>);
912+
pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
913913

914914
// Terminators
915915
pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;

src/librustc_codegen_ssa/mir/debuginfo.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use super::{FunctionCx, LocalRef};
1414

1515
pub struct FunctionDebugContext<D> {
1616
pub scopes: IndexVec<mir::SourceScope, DebugScope<D>>,
17-
pub source_locations_enabled: bool,
1817
pub defining_crate: CrateNum,
1918
}
2019

@@ -53,11 +52,10 @@ impl<D> DebugScope<D> {
5352
}
5453

5554
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
56-
pub fn set_debug_loc(&mut self, bx: &mut Bx, source_info: mir::SourceInfo) {
55+
pub fn set_debug_loc(&self, bx: &mut Bx, source_info: mir::SourceInfo) {
5756
let (scope, span) = self.debug_loc(source_info);
58-
if let Some(debug_context) = &mut self.debug_context {
59-
// FIXME(eddyb) get rid of this unwrap somehow.
60-
bx.set_source_location(debug_context, scope.unwrap(), span);
57+
if let Some(scope) = scope {
58+
bx.set_source_location(scope, span);
6159
}
6260
}
6361

src/librustc_codegen_ssa/mir/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,6 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
230230
bx.br(fx.blocks[mir::START_BLOCK]);
231231
}
232232

233-
// Up until here, IR instructions for this function have explicitly not been annotated with
234-
// source code location, so we don't step into call setup code. From here on, source location
235-
// emitting should be enabled.
236-
if let Some(debug_context) = &mut fx.debug_context {
237-
debug_context.source_locations_enabled = true;
238-
}
239-
240233
let rpo = traversal::reverse_postorder(&mir_body);
241234
let mut visited = BitSet::new_empty(mir_body.basic_blocks().len());
242235

src/librustc_codegen_ssa/traits/debuginfo.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@ pub trait DebugInfoBuilderMethods: BackendTypes {
5757
indirect_offsets: &[Size],
5858
span: Span,
5959
);
60-
fn set_source_location(
61-
&mut self,
62-
debug_context: &mut FunctionDebugContext<Self::DIScope>,
63-
scope: Self::DIScope,
64-
span: Span,
65-
);
60+
fn set_source_location(&mut self, scope: Self::DIScope, span: Span);
6661
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
6762
fn set_var_name(&mut self, value: Self::Value, name: &str);
6863
}

0 commit comments

Comments
 (0)