Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
82016458
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
82016458
编写于
12月 16, 2016
作者:
M
Mark-Simulacrum
提交者:
Mark Simulacrum
12月 20, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove DebugLoc.
上级
be981dce
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
38 addition
and
85 deletion
+38
-85
src/librustc_trans/adt.rs
src/librustc_trans/adt.rs
+0
-4
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+1
-4
src/librustc_trans/common.rs
src/librustc_trans/common.rs
+5
-0
src/librustc_trans/debuginfo/mod.rs
src/librustc_trans/debuginfo/mod.rs
+2
-17
src/librustc_trans/debuginfo/source_loc.rs
src/librustc_trans/debuginfo/source_loc.rs
+8
-19
src/librustc_trans/intrinsic.rs
src/librustc_trans/intrinsic.rs
+2
-11
src/librustc_trans/mir/block.rs
src/librustc_trans/mir/block.rs
+5
-8
src/librustc_trans/mir/mod.rs
src/librustc_trans/mir/mod.rs
+13
-19
src/librustc_trans/mir/statement.rs
src/librustc_trans/mir/statement.rs
+2
-3
未找到文件。
src/librustc_trans/adt.rs
浏览文件 @
82016458
...
...
@@ -49,7 +49,6 @@
use
rustc
::
ty
::
layout
;
use
rustc
::
ty
::{
self
,
Ty
,
AdtKind
};
use
common
::
*
;
use
debuginfo
::
DebugLoc
;
use
glue
;
use
base
;
use
machine
;
...
...
@@ -595,8 +594,6 @@ fn struct_field_ptr<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
return
bcx
.struct_gep
(
ptr_val
,
ix
);
}
let
dbloc
=
DebugLoc
::
None
;
// We need to get the pointer manually now.
// We do this by casting to a *i8, then offsetting it by the appropriate amount.
// We do this instead of, say, simply adjusting the pointer from the result of a GEP
...
...
@@ -627,7 +624,6 @@ fn struct_field_ptr<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
// (unaligned offset + (align - 1)) & -align
// Calculate offset
dbloc
.apply
(
bcx
.fcx
());
let
align_sub_1
=
bcx
.sub
(
align
,
C_uint
(
bcx
.ccx
(),
1u64
));
let
offset
=
bcx
.and
(
bcx
.add
(
unaligned_offset
,
align_sub_1
),
bcx
.neg
(
align
));
...
...
src/librustc_trans/base.rs
浏览文件 @
82016458
...
...
@@ -60,7 +60,7 @@
use
common
;
use
consts
;
use
context
::{
SharedCrateContext
,
CrateContextList
};
use
debuginfo
::{
self
,
DebugLoc
}
;
use
debuginfo
;
use
declare
;
use
machine
;
use
machine
::{
llalign_of_min
,
llsize_of
};
...
...
@@ -649,7 +649,6 @@ pub fn alloc_ty<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
}
pub
fn
alloca
(
cx
:
&
BlockAndBuilder
,
ty
:
Type
,
name
:
&
str
)
->
ValueRef
{
DebugLoc
::
None
.apply
(
cx
.fcx
());
cx
.fcx
()
.alloca
(
ty
,
name
)
}
...
...
@@ -658,8 +657,6 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
/// and builds the return block.
pub
fn
finish
(
&
'blk
self
,
ret_cx
:
&
BlockAndBuilder
<
'blk
,
'tcx
>
)
{
self
.build_return_block
(
ret_cx
);
DebugLoc
::
None
.apply
(
self
);
self
.cleanup
();
}
...
...
src/librustc_trans/common.rs
浏览文件 @
82016458
...
...
@@ -16,6 +16,7 @@
use
llvm
;
use
llvm
::{
ValueRef
,
BasicBlockRef
,
BuilderRef
,
ContextRef
,
TypeKind
};
use
llvm
::{
True
,
False
,
Bool
,
OperandBundleDef
,
get_param
};
use
llvm
::
debuginfo
::
DIScope
;
use
monomorphize
::
Instance
;
use
rustc
::
hir
::
def
::
Def
;
use
rustc
::
hir
::
def_id
::
DefId
;
...
...
@@ -578,6 +579,10 @@ pub fn new(llbb: BasicBlockRef, fcx: &'blk FunctionContext<'blk, 'tcx>) -> Self
}
}
pub
fn
set_source_location
(
&
self
,
scope
:
DIScope
,
sp
:
Span
)
{
debuginfo
::
set_source_location
(
self
.fcx
(),
self
,
scope
,
sp
)
}
pub
fn
at_start
<
F
,
R
>
(
&
self
,
f
:
F
)
->
R
where
F
:
FnOnce
(
&
BlockAndBuilder
<
'blk
,
'tcx
>
)
->
R
{
...
...
src/librustc_trans/debuginfo/mod.rs
浏览文件 @
82016458
...
...
@@ -27,7 +27,7 @@
use
rustc
::
ty
::
subst
::
Substs
;
use
abi
::
Abi
;
use
common
::{
CrateContext
,
FunctionContext
,
BlockAndBuilder
};
use
common
::{
CrateContext
,
BlockAndBuilder
};
use
monomorphize
::{
self
,
Instance
};
use
rustc
::
ty
::{
self
,
Ty
};
use
rustc
::
mir
;
...
...
@@ -55,6 +55,7 @@
pub
use
self
::
source_loc
::
start_emitting_source_locations
;
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
;
...
...
@@ -507,19 +508,3 @@ pub fn declare_local<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
_
=>
{
/* nothing to do */
}
}
}
#[derive(Copy,
Clone,
PartialEq,
Eq,
Debug)]
pub
enum
DebugLoc
{
ScopeAt
(
DIScope
,
Span
),
None
}
impl
DebugLoc
{
pub
fn
apply
(
self
,
fcx
:
&
FunctionContext
)
{
source_loc
::
set_source_location
(
fcx
,
None
,
self
);
}
pub
fn
apply_to_bcx
(
self
,
bcx
:
&
BlockAndBuilder
)
{
source_loc
::
set_source_location
(
bcx
.fcx
(),
Some
(
bcx
),
self
);
}
}
src/librustc_trans/debuginfo/source_loc.rs
浏览文件 @
82016458
...
...
@@ -11,8 +11,8 @@
use
self
::
InternalDebugLocation
::
*
;
use
super
::
utils
::{
debug_context
,
span_start
};
use
super
::
metadata
::
{
UNKNOWN_COLUMN_NUMBER
}
;
use
super
::
{
FunctionDebugContext
,
DebugLoc
}
;
use
super
::
metadata
::
UNKNOWN_COLUMN_NUMBER
;
use
super
::
FunctionDebugContext
;
use
llvm
;
use
llvm
::
debuginfo
::
DIScope
;
...
...
@@ -21,41 +21,30 @@
use
libc
::
c_uint
;
use
std
::
ptr
;
use
syntax_pos
::
Pos
;
use
syntax_pos
::
{
Span
,
Pos
}
;
/// Sets the current debug location at the beginning of the span.
///
/// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...).
pub
fn
set_source_location
(
fcx
:
&
FunctionContext
,
builder
:
Option
<&
Builder
>
,
debug_loc
:
DebugLoc
)
{
let
builder
=
builder
.map
(|
b
|
b
.llbuilder
);
pub
fn
set_source_location
(
fcx
:
&
FunctionContext
,
builder
:
&
Builder
,
scope
:
DIScope
,
span
:
Span
)
{
let
builder
=
builder
.llbuilder
;
let
function_debug_context
=
match
fcx
.debug_context
{
FunctionDebugContext
::
DebugInfoDisabled
=>
return
,
FunctionDebugContext
::
FunctionWithoutDebugInfo
=>
{
set_debug_location
(
fcx
.ccx
,
builder
,
UnknownLocation
);
set_debug_location
(
fcx
.ccx
,
Some
(
builder
)
,
UnknownLocation
);
return
;
}
FunctionDebugContext
::
RegularContext
(
ref
data
)
=>
data
};
let
dbg_loc
=
if
function_debug_context
.source_locations_enabled
.get
()
{
let
(
scope
,
span
)
=
match
debug_loc
{
DebugLoc
::
ScopeAt
(
scope
,
span
)
=>
(
scope
,
span
),
DebugLoc
::
None
=>
{
set_debug_location
(
fcx
.ccx
,
builder
,
UnknownLocation
);
return
;
}
};
debug!
(
"set_source_location: {}"
,
fcx
.ccx
.sess
()
.codemap
()
.span_to_string
(
span
));
debug!
(
"set_source_location: {}"
,
fcx
.ccx
.sess
()
.codemap
()
.span_to_string
(
span
));
let
loc
=
span_start
(
fcx
.ccx
,
span
);
InternalDebugLocation
::
new
(
scope
,
loc
.line
,
loc
.col
.to_usize
())
}
else
{
UnknownLocation
};
set_debug_location
(
fcx
.ccx
,
builder
,
dbg_loc
);
set_debug_location
(
fcx
.ccx
,
Some
(
builder
)
,
dbg_loc
);
}
/// Enables emitting source locations for the given functions.
...
...
src/librustc_trans/intrinsic.rs
浏览文件 @
82016458
...
...
@@ -18,7 +18,6 @@
use
adt
;
use
base
::
*
;
use
common
::
*
;
use
debuginfo
::
DebugLoc
;
use
declare
;
use
glue
;
use
type_of
;
...
...
@@ -31,7 +30,7 @@
use
syntax
::
symbol
::
Symbol
;
use
rustc
::
session
::
Session
;
use
syntax_pos
::
{
Span
,
DUMMY_SP
}
;
use
syntax_pos
::
Span
;
use
std
::
cmp
::
Ordering
;
use
std
::
iter
;
...
...
@@ -90,7 +89,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
fn_ty
:
&
FnType
,
llargs
:
&
[
ValueRef
],
llresult
:
ValueRef
,
call_debug_location
:
DebugLoc
)
{
span
:
Span
)
{
let
fcx
=
bcx
.fcx
();
let
ccx
=
fcx
.ccx
;
let
tcx
=
bcx
.tcx
();
...
...
@@ -105,14 +104,6 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
let
ret_ty
=
sig
.output
();
let
name
=
&*
tcx
.item_name
(
def_id
)
.as_str
();
let
span
=
match
call_debug_location
{
DebugLoc
::
ScopeAt
(
_
,
span
)
=>
span
,
DebugLoc
::
None
=>
{
span_bug!
(
fcx
.span
.unwrap_or
(
DUMMY_SP
),
"intrinsic `{}` called with missing span"
,
name
);
}
};
// These are the only intrinsic functions that diverge.
if
name
==
"abort"
{
let
llfn
=
ccx
.get_intrinsic
(
&
(
"llvm.trap"
));
...
...
src/librustc_trans/mir/block.rs
浏览文件 @
82016458
...
...
@@ -20,7 +20,6 @@
use
common
::{
self
,
BlockAndBuilder
,
Funclet
};
use
common
::{
C_bool
,
C_str_slice
,
C_struct
,
C_u32
,
C_undef
};
use
consts
;
use
debuginfo
::
DebugLoc
;
use
Disr
;
use
machine
::{
llalign_of_min
,
llbitsize_of_real
};
use
meth
;
...
...
@@ -115,9 +114,8 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock,
debug!
(
"trans_block: terminator: {:?}"
,
terminator
);
let
span
=
terminator
.source_info.span
;
let
debug_loc
=
self
.debug_loc
(
terminator
.source_info
);
debug_loc
.apply_to_bcx
(
&
bcx
);
debug_loc
.apply
(
bcx
.fcx
());
let
(
scope
,
debug_span
)
=
self
.debug_loc
(
terminator
.source_info
);
bcx
.set_source_location
(
scope
,
debug_span
);
match
terminator
.kind
{
mir
::
TerminatorKind
::
Resume
=>
{
if
let
Some
(
cleanup_pad
)
=
cleanup_pad
{
...
...
@@ -329,7 +327,7 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock,
// After this point, bcx is the block for the call to panic.
bcx
=
panic_block
;
debug_loc
.apply_to_bcx
(
&
bcx
);
bcx
.set_source_location
(
scope
,
debug_span
);
// Get the location information.
let
loc
=
bcx
.sess
()
.codemap
()
.lookup_char_pos
(
span
.lo
);
...
...
@@ -605,7 +603,7 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock,
bug!
(
"Cannot use direct operand with an intrinsic call"
)
};
trans_intrinsic_call
(
&
bcx
,
callee
.ty
,
&
fn_ty
,
&
llargs
,
dest
,
debug_
loc
);
trans_intrinsic_call
(
&
bcx
,
callee
.ty
,
&
fn_ty
,
&
llargs
,
dest
,
debug_
span
);
if
let
ReturnDest
::
IndirectOperand
(
dst
,
_
)
=
ret_dest
{
// Make a fake operand for store_return
...
...
@@ -645,7 +643,7 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock,
if
let
Some
((
_
,
target
))
=
*
destination
{
let
ret_bcx
=
self
.build_block
(
target
);
ret_bcx
.at_start
(|
ret_bcx
|
{
debug_loc
.apply_to_bcx
(
ret_bcx
);
bcx
.set_source_location
(
scope
,
debug_span
);
let
op
=
OperandRef
{
val
:
Immediate
(
invokeret
),
ty
:
sig
.output
(),
...
...
@@ -885,7 +883,6 @@ pub fn init_cpad(&mut self, bb: mir::BasicBlock,
}
CleanupKind
::
Funclet
=>
{
bcx
.set_personality_fn
(
self
.fcx
.eh_personality
());
DebugLoc
::
None
.apply_to_bcx
(
&
bcx
);
let
cleanup_pad
=
bcx
.cleanup_pad
(
None
,
&
[]);
funclets
[
bb
]
=
Funclet
::
msvc
(
cleanup_pad
);
}
...
...
src/librustc_trans/mir/mod.rs
浏览文件 @
82016458
...
...
@@ -10,16 +10,18 @@
use
libc
::
c_uint
;
use
llvm
::{
self
,
ValueRef
,
BasicBlockRef
};
use
llvm
::
debuginfo
::
DIScope
;
use
rustc
::
ty
;
use
rustc
::
mir
;
use
rustc
::
mir
::
tcx
::
LvalueTy
;
use
session
::
config
::
FullDebugInfo
;
use
base
;
use
common
::{
self
,
BlockAndBuilder
,
CrateContext
,
FunctionContext
,
C_null
,
Funclet
};
use
debuginfo
::{
self
,
declare_local
,
DebugLoc
,
VariableAccess
,
VariableKind
,
FunctionDebugContext
};
use
debuginfo
::{
self
,
declare_local
,
VariableAccess
,
VariableKind
,
FunctionDebugContext
};
use
machine
;
use
type_of
;
use
syntax_pos
::{
DUMMY_SP
,
NO_EXPANSION
,
COMMAND_LINE_EXPN
,
BytePos
};
use
syntax_pos
::{
DUMMY_SP
,
NO_EXPANSION
,
COMMAND_LINE_EXPN
,
BytePos
,
Span
};
use
syntax
::
symbol
::
keywords
;
use
std
::
cell
::
Ref
;
...
...
@@ -88,15 +90,12 @@ pub struct MirContext<'bcx, 'tcx:'bcx> {
}
impl
<
'blk
,
'tcx
>
MirContext
<
'blk
,
'tcx
>
{
pub
fn
debug_loc
(
&
mut
self
,
source_info
:
mir
::
SourceInfo
)
->
DebugLoc
{
pub
fn
debug_loc
(
&
mut
self
,
source_info
:
mir
::
SourceInfo
)
->
(
DIScope
,
Span
)
{
// Bail out if debug info emission is not enabled.
match
self
.fcx.debug_context
{
FunctionDebugContext
::
DebugInfoDisabled
|
FunctionDebugContext
::
FunctionWithoutDebugInfo
=>
{
// Can't return DebugLoc::None here because intrinsic::trans_intrinsic_call()
// relies on debug location to obtain span of the call site.
return
DebugLoc
::
ScopeAt
(
self
.scopes
[
source_info
.scope
]
.scope_metadata
,
source_info
.span
);
return
(
self
.scopes
[
source_info
.scope
]
.scope_metadata
,
source_info
.span
);
}
FunctionDebugContext
::
RegularContext
(
_
)
=>
{}
}
...
...
@@ -109,8 +108,8 @@ pub fn debug_loc(&mut self, source_info: mir::SourceInfo) -> DebugLoc {
self
.fcx.ccx
.sess
()
.opts.debugging_opts.debug_macros
{
let
scope_metadata
=
self
.scope_metadata_for_loc
(
source_info
.scope
,
source_info
.span.lo
);
DebugLoc
::
ScopeAt
(
scope_metadata
,
source_info
.span
)
source_info
.span.lo
);
(
scope_metadata
,
source_info
.span
)
}
else
{
let
cm
=
self
.fcx.ccx
.sess
()
.codemap
();
// Walk up the macro expansion chain until we reach a non-expanded span.
...
...
@@ -125,7 +124,7 @@ pub fn debug_loc(&mut self, source_info: mir::SourceInfo) -> DebugLoc {
}
let
scope_metadata
=
self
.scope_metadata_for_loc
(
source_info
.scope
,
span
.lo
);
// Use span of the outermost call site, while keeping the original lexical scope
DebugLoc
::
ScopeAt
(
scope_metadata
,
span
)
(
scope_metadata
,
span
)
}
}
...
...
@@ -236,14 +235,10 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
debug!
(
"alloc: {:?} ({}) -> lvalue"
,
local
,
name
);
let
lvalue
=
LvalueRef
::
alloca
(
&
bcx
,
ty
,
&
name
.as_str
());
if
dbg
{
let
dbg_loc
=
mircx
.debug_loc
(
source_info
);
if
let
DebugLoc
::
ScopeAt
(
scope
,
span
)
=
dbg_loc
{
declare_local
(
&
bcx
,
name
,
ty
,
scope
,
VariableAccess
::
DirectVariable
{
alloca
:
lvalue
.llval
},
VariableKind
::
LocalVariable
,
span
);
}
else
{
panic!
(
"Unexpected"
);
}
let
(
scope
,
span
)
=
mircx
.debug_loc
(
source_info
);
declare_local
(
&
bcx
,
name
,
ty
,
scope
,
VariableAccess
::
DirectVariable
{
alloca
:
lvalue
.llval
},
VariableKind
::
LocalVariable
,
span
);
}
LocalRef
::
Lvalue
(
lvalue
)
}
else
{
...
...
@@ -312,7 +307,6 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
}
}
DebugLoc
::
None
.apply
(
fcx
);
fcx
.cleanup
();
}
...
...
src/librustc_trans/mir/statement.rs
浏览文件 @
82016458
...
...
@@ -25,9 +25,8 @@ pub fn trans_statement(&mut self,
->
BlockAndBuilder
<
'bcx
,
'tcx
>
{
debug!
(
"trans_statement(statement={:?})"
,
statement
);
let
debug_loc
=
self
.debug_loc
(
statement
.source_info
);
debug_loc
.apply_to_bcx
(
&
bcx
);
debug_loc
.apply
(
bcx
.fcx
());
let
(
scope
,
span
)
=
self
.debug_loc
(
statement
.source_info
);
bcx
.set_source_location
(
scope
,
span
);
match
statement
.kind
{
mir
::
StatementKind
::
Assign
(
ref
lvalue
,
ref
rvalue
)
=>
{
if
let
mir
::
Lvalue
::
Local
(
index
)
=
*
lvalue
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录