summaryrefslogtreecommitdiff
path: root/src/librustc_codegen_llvm/debuginfo/source_loc.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-03-19 11:41:41 +0000
committerbors <bors@rust-lang.org>2020-03-19 11:41:41 +0000
commitcf35136850a7698c0da0a76785c1552ed88e1cfd (patch)
treec694b90a17f58fd2680ff3f51859d80b86933728 /src/librustc_codegen_llvm/debuginfo/source_loc.rs
parent6724d584b8e3b5fa5e06466d1e900cdd60953707 (diff)
parent40dea87fbdf2ce943bfe245f0a13d7821831a88b (diff)
downloadrust-try.tar.gz
Auto merge of #68965 - eddyb:mir-inline-scope, r=<try>try
rustc_mir: track inlined callees in SourceScopeData. We now record which MIR scopes are the roots of *other* (inlined) functions's scope trees, which allows us to generate the correct debuginfo in codegen, similar to what LLVM inlining generates. This PR makes the `ui` test `backtrace-debuginfo` pass, if the MIR inliner is turned on by default. Also, `#[track_caller]` is now correct in the face of MIR inlining (cc @anp). r? @rust-lang/wg-mir-opt
Diffstat (limited to 'src/librustc_codegen_llvm/debuginfo/source_loc.rs')
-rw-r--r--src/librustc_codegen_llvm/debuginfo/source_loc.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/source_loc.rs b/src/librustc_codegen_llvm/debuginfo/source_loc.rs
deleted file mode 100644
index 66ae9d72c3e..00000000000
--- a/src/librustc_codegen_llvm/debuginfo/source_loc.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-use super::metadata::{UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER};
-use super::utils::debug_context;
-
-use crate::common::CodegenCx;
-use crate::llvm::debuginfo::DIScope;
-use crate::llvm::{self, Value};
-use rustc_codegen_ssa::traits::*;
-
-use rustc_data_structures::sync::Lrc;
-use rustc_span::{BytePos, Pos, SourceFile, SourceFileAndLine, Span};
-
-/// A source code location used to generate debug information.
-pub struct DebugLoc {
- /// Information about the original source file.
- pub file: Lrc<SourceFile>,
- /// The (1-based) line number.
- pub line: Option<u32>,
- /// The (1-based) column number.
- pub col: Option<u32>,
-}
-
-impl CodegenCx<'ll, '_> {
- /// Looks up debug source information about a `BytePos`.
- pub fn lookup_debug_loc(&self, pos: BytePos) -> DebugLoc {
- let (file, line, col) = match self.sess().source_map().lookup_line(pos) {
- Ok(SourceFileAndLine { sf: file, line }) => {
- let line_pos = file.line_begin_pos(pos);
-
- // Use 1-based indexing.
- let line = (line + 1) as u32;
- let col = (pos - line_pos).to_u32() + 1;
-
- (file, Some(line), Some(col))
- }
- Err(file) => (file, None, None),
- };
-
- // For MSVC, omit the column number.
- // Otherwise, emit it. This mimics clang behaviour.
- // See discussion in https://github.com/rust-lang/rust/issues/42921
- if self.sess().target.target.options.is_like_msvc {
- DebugLoc { file, line, col: None }
- } else {
- DebugLoc { file, line, col }
- }
- }
-
- pub fn create_debug_loc(&self, scope: &'ll DIScope, span: Span) -> &'ll Value {
- let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
-
- unsafe {
- llvm::LLVMRustDIBuilderCreateDebugLocation(
- debug_context(self).llcontext,
- line.unwrap_or(UNKNOWN_LINE_NUMBER),
- col.unwrap_or(UNKNOWN_COLUMN_NUMBER),
- scope,
- None,
- )
- }
- }
-}