Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6fac0a1a
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,发现更多精彩内容 >>
提交
6fac0a1a
编写于
12月 19, 2016
作者:
M
Mark Simulacrum
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change *.fcx.ccx to *.ccx
上级
15c9e5e3
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
34 addition
and
41 deletion
+34
-41
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+2
-2
src/librustc_trans/cleanup.rs
src/librustc_trans/cleanup.rs
+1
-3
src/librustc_trans/common.rs
src/librustc_trans/common.rs
+2
-5
src/librustc_trans/glue.rs
src/librustc_trans/glue.rs
+7
-9
src/librustc_trans/mir/analyze.rs
src/librustc_trans/mir/analyze.rs
+11
-11
src/librustc_trans/mir/block.rs
src/librustc_trans/mir/block.rs
+1
-1
src/librustc_trans/mir/lvalue.rs
src/librustc_trans/mir/lvalue.rs
+2
-2
src/librustc_trans/mir/mod.rs
src/librustc_trans/mir/mod.rs
+8
-8
未找到文件。
src/librustc_trans/base.rs
浏览文件 @
6fac0a1a
...
...
@@ -424,7 +424,7 @@ pub fn load_ty<'a, 'tcx>(b: &Builder<'a, 'tcx>, ptr: ValueRef, t: Ty<'tcx>) -> V
pub
fn
store_ty
<
'a
,
'tcx
>
(
cx
:
&
BlockAndBuilder
<
'a
,
'tcx
>
,
v
:
ValueRef
,
dst
:
ValueRef
,
t
:
Ty
<
'tcx
>
)
{
debug!
(
"store_ty: {:?} : {:?} <- {:?}"
,
Value
(
dst
),
t
,
Value
(
v
));
if
common
::
type_is_fat_ptr
(
cx
.ccx
()
,
t
)
{
if
common
::
type_is_fat_ptr
(
cx
.ccx
,
t
)
{
let
lladdr
=
cx
.extract_value
(
v
,
abi
::
FAT_PTR_ADDR
);
let
llextra
=
cx
.extract_value
(
v
,
abi
::
FAT_PTR_EXTRA
);
store_fat_ptr
(
cx
,
lladdr
,
llextra
,
dst
,
t
);
...
...
@@ -656,7 +656,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
if
let
Some
(
cast_ty
)
=
fcx
.fn_ty.ret.cast
{
let
load
=
bcx
.load
(
bcx
.pointercast
(
dest
,
cast_ty
.ptr_to
()));
let
llalign
=
llalign_of_min
(
fcx
.
ccx
,
fcx
.fn_ty.ret.ty
);
let
llalign
=
llalign_of_min
(
ccx
,
fcx
.fn_ty.ret.ty
);
unsafe
{
llvm
::
LLVMSetAlignment
(
load
,
llalign
);
}
...
...
src/librustc_trans/cleanup.rs
浏览文件 @
6fac0a1a
...
...
@@ -175,9 +175,7 @@ fn get_landing_pad<'a>(fcx: &FunctionContext<'a, 'tcx>, drop_val: &DropValue<'tc
// The landing pad return type (the type being propagated). Not sure
// what this represents but it's determined by the personality
// function and this is what the EH proposal example uses.
let
llretty
=
Type
::
struct_
(
fcx
.ccx
,
&
[
Type
::
i8p
(
fcx
.ccx
),
Type
::
i32
(
fcx
.ccx
)],
false
);
let
llretty
=
Type
::
struct_
(
fcx
.ccx
,
&
[
Type
::
i8p
(
fcx
.ccx
),
Type
::
i32
(
fcx
.ccx
)],
false
);
// The only landing pad clause will be 'cleanup'
let
llretval
=
pad_bcx
.landing_pad
(
llretty
,
llpersonality
,
1
,
pad_bcx
.fcx
()
.llfn
);
...
...
src/librustc_trans/common.rs
浏览文件 @
6fac0a1a
...
...
@@ -421,17 +421,14 @@ pub fn at_start<F, R>(&self, f: F) -> R
r
}
pub
fn
ccx
(
&
self
)
->
&
'a
CrateContext
<
'a
,
'tcx
>
{
self
.fcx.ccx
}
pub
fn
fcx
(
&
self
)
->
&
'a
FunctionContext
<
'a
,
'tcx
>
{
self
.fcx
}
pub
fn
tcx
(
&
self
)
->
TyCtxt
<
'a
,
'tcx
,
'tcx
>
{
self
.
fcx.
ccx
.tcx
()
self
.ccx
.tcx
()
}
pub
fn
sess
(
&
self
)
->
&
'a
Session
{
self
.
fcx.
ccx
.sess
()
self
.ccx
.sess
()
}
pub
fn
llbb
(
&
self
)
->
BasicBlockRef
{
...
...
src/librustc_trans/glue.rs
浏览文件 @
6fac0a1a
...
...
@@ -474,7 +474,7 @@ fn iter_variant<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>,
}
}
let
value
=
if
cx
.ccx
()
.shared
()
.type_is_sized
(
t
)
{
let
value
=
if
cx
.ccx
.shared
()
.type_is_sized
(
t
)
{
adt
::
MaybeSizedValue
::
sized
(
av
)
}
else
{
// FIXME(#36457) -- we should pass unsized values as two arguments
...
...
@@ -493,7 +493,7 @@ fn iter_variant<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>,
}
ty
::
TyArray
(
_
,
n
)
=>
{
let
base
=
get_dataptr
(
&
cx
,
value
.value
);
let
len
=
C_uint
(
cx
.ccx
()
,
n
);
let
len
=
C_uint
(
cx
.ccx
,
n
);
let
unit_ty
=
t
.sequence_element_type
(
cx
.tcx
());
cx
=
tvec
::
slice_for_each
(
&
cx
,
base
,
unit_ty
,
len
,
|
bb
,
vv
|
drop_ty
(
bb
,
vv
,
unit_ty
));
}
...
...
@@ -514,7 +514,7 @@ fn iter_variant<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>,
for
(
i
,
&
Field
(
_
,
field_ty
))
in
fields
.iter
()
.enumerate
()
{
let
llfld_a
=
adt
::
trans_field_ptr
(
&
cx
,
t
,
value
,
Disr
::
from
(
discr
),
i
);
let
val
=
if
cx
.ccx
()
.shared
()
.type_is_sized
(
field_ty
)
{
let
val
=
if
cx
.ccx
.shared
()
.type_is_sized
(
field_ty
)
{
llfld_a
}
else
{
// FIXME(#36457) -- we should pass unsized values as two arguments
...
...
@@ -530,8 +530,6 @@ fn iter_variant<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>,
bug!
(
"Union in `glue::drop_structural_ty`"
);
}
AdtKind
::
Enum
=>
{
let
fcx
=
cx
.fcx
();
let
ccx
=
fcx
.ccx
;
let
n_variants
=
adt
.variants
.len
();
// NB: we must hit the discriminant first so that structural
...
...
@@ -562,15 +560,15 @@ fn iter_variant<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>,
// from the outer function, and any other use case will only
// call this for an already-valid enum in which case the `ret
// void` will never be hit.
let
ret_void_cx
=
fcx
.build_new_block
(
"enum-iter-ret-void"
);
let
ret_void_cx
=
cx
.fcx
()
.build_new_block
(
"enum-iter-ret-void"
);
ret_void_cx
.ret_void
();
let
llswitch
=
cx
.switch
(
lldiscrim_a
,
ret_void_cx
.llbb
(),
n_variants
);
let
next_cx
=
fcx
.build_new_block
(
"enum-iter-next"
);
let
next_cx
=
cx
.fcx
()
.build_new_block
(
"enum-iter-next"
);
for
variant
in
&
adt
.variants
{
let
variant_cx_name
=
format!
(
"enum-iter-variant-{}"
,
&
variant
.disr_val
.to_string
());
let
variant_cx
=
fcx
.build_new_block
(
&
variant_cx_name
);
let
variant_cx
=
cx
.fcx
()
.build_new_block
(
&
variant_cx_name
);
let
case_val
=
adt
::
trans_case
(
&
cx
,
t
,
Disr
::
from
(
variant
.disr_val
));
variant_cx
.add_case
(
llswitch
,
case_val
,
variant_cx
.llbb
());
iter_variant
(
&
variant_cx
,
t
,
value
,
variant
,
substs
);
...
...
@@ -578,7 +576,7 @@ fn iter_variant<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>,
}
cx
=
next_cx
;
}
_
=>
ccx
.sess
()
.unimpl
(
"value from adt::trans_switch in drop_structural_ty"
),
_
=>
c
x
.c
cx
.sess
()
.unimpl
(
"value from adt::trans_switch in drop_structural_ty"
),
}
}
},
...
...
src/librustc_trans/mir/analyze.rs
浏览文件 @
6fac0a1a
...
...
@@ -33,13 +33,13 @@ pub fn lvalue_locals<'a, 'tcx>(mircx: &MirContext<'a, 'tcx>) -> BitVector {
ty
.is_unique
()
||
ty
.is_region_ptr
()
||
ty
.is_simd
()
||
common
::
type_is_zero_size
(
mircx
.
fcx.
ccx
,
ty
)
common
::
type_is_zero_size
(
mircx
.ccx
,
ty
)
{
// These sorts of types are immediates that we can store
// in an ValueRef without an alloca.
assert
!
(
common
::
type_is_immediate
(
mircx
.
fcx.
ccx
,
ty
)
||
common
::
type_is_fat_ptr
(
mircx
.
fcx.
ccx
,
ty
));
}
else
if
common
::
type_is_imm_pair
(
mircx
.
fcx.
ccx
,
ty
)
{
assert
!
(
common
::
type_is_immediate
(
mircx
.ccx
,
ty
)
||
common
::
type_is_fat_ptr
(
mircx
.ccx
,
ty
));
}
else
if
common
::
type_is_imm_pair
(
mircx
.ccx
,
ty
)
{
// We allow pairs and uses of any of their 2 fields.
}
else
{
// These sorts of types require an alloca. Note that
...
...
@@ -112,7 +112,7 @@ fn visit_terminator_kind(&mut self,
literal
:
mir
::
Literal
::
Item
{
def_id
,
..
},
..
}),
ref
args
,
..
}
if
Some
(
def_id
)
==
self
.cx.
fcx.
ccx
.tcx
()
.lang_items
.box_free_fn
()
=>
{
}
if
Some
(
def_id
)
==
self
.cx.ccx
.tcx
()
.lang_items
.box_free_fn
()
=>
{
// box_free(x) shares with `drop x` the property that it
// is not guaranteed to be statically dominated by the
// definition of x, so x must always be in an alloca.
...
...
@@ -135,10 +135,10 @@ fn visit_lvalue(&mut self,
// Allow uses of projections of immediate pair fields.
if
let
mir
::
Lvalue
::
Projection
(
ref
proj
)
=
*
lvalue
{
if
let
mir
::
Lvalue
::
Local
(
_
)
=
proj
.base
{
let
ty
=
proj
.base
.ty
(
self
.cx.mir
,
self
.cx.
fcx.
ccx
.tcx
());
let
ty
=
proj
.base
.ty
(
self
.cx.mir
,
self
.cx.ccx
.tcx
());
let
ty
=
self
.cx
.monomorphize
(
&
ty
.to_ty
(
self
.cx.
fcx.
ccx
.tcx
()));
if
common
::
type_is_imm_pair
(
self
.cx.
fcx.
ccx
,
ty
)
{
let
ty
=
self
.cx
.monomorphize
(
&
ty
.to_ty
(
self
.cx.ccx
.tcx
()));
if
common
::
type_is_imm_pair
(
self
.cx.ccx
,
ty
)
{
if
let
mir
::
ProjectionElem
::
Field
(
..
)
=
proj
.elem
{
if
let
LvalueContext
::
Consume
=
context
{
return
;
...
...
@@ -166,11 +166,11 @@ fn visit_lvalue(&mut self,
}
LvalueContext
::
Drop
=>
{
let
ty
=
lvalue
.ty
(
self
.cx.mir
,
self
.cx.
fcx.
ccx
.tcx
());
let
ty
=
self
.cx
.monomorphize
(
&
ty
.to_ty
(
self
.cx.
fcx.
ccx
.tcx
()));
let
ty
=
lvalue
.ty
(
self
.cx.mir
,
self
.cx.ccx
.tcx
());
let
ty
=
self
.cx
.monomorphize
(
&
ty
.to_ty
(
self
.cx.ccx
.tcx
()));
// Only need the lvalue if we're actually dropping it.
if
self
.cx.
fcx.
ccx
.shared
()
.type_needs_drop
(
ty
)
{
if
self
.cx.ccx
.shared
()
.type_needs_drop
(
ty
)
{
self
.mark_as_lvalue
(
index
);
}
}
...
...
src/librustc_trans/mir/block.rs
浏览文件 @
6fac0a1a
...
...
@@ -838,7 +838,7 @@ fn landing_pad_to(&mut self, target_bb: mir::BasicBlock) -> BasicBlockRef {
return
block
;
}
if
base
::
wants_msvc_seh
(
self
.
fcx.
ccx
.sess
())
{
if
base
::
wants_msvc_seh
(
self
.ccx
.sess
())
{
return
self
.blocks
[
target_bb
];
}
...
...
src/librustc_trans/mir/lvalue.rs
浏览文件 @
6fac0a1a
...
...
@@ -140,7 +140,7 @@ pub fn trans_lvalue(&mut self,
LvalueTy
::
Downcast
{
adt_def
:
_
,
substs
:
_
,
variant_index
:
v
}
=>
v
,
};
let
discr
=
discr
as
u64
;
let
is_sized
=
self
.
fcx.
ccx
.shared
()
.type_is_sized
(
projected_ty
.to_ty
(
tcx
));
let
is_sized
=
self
.ccx
.shared
()
.type_is_sized
(
projected_ty
.to_ty
(
tcx
));
let
base
=
if
is_sized
{
adt
::
MaybeSizedValue
::
sized
(
tr_base
.llval
)
}
else
{
...
...
@@ -272,7 +272,7 @@ fn prepare_index(&mut self,
}
pub
fn
monomorphized_lvalue_ty
(
&
self
,
lvalue
:
&
mir
::
Lvalue
<
'tcx
>
)
->
Ty
<
'tcx
>
{
let
tcx
=
self
.
fcx.
ccx
.tcx
();
let
tcx
=
self
.ccx
.tcx
();
let
lvalue_ty
=
lvalue
.ty
(
&
self
.mir
,
tcx
);
self
.monomorphize
(
&
lvalue_ty
.to_ty
(
tcx
))
}
...
...
src/librustc_trans/mir/mod.rs
浏览文件 @
6fac0a1a
...
...
@@ -48,9 +48,10 @@ pub struct MirContext<'a, 'tcx:'a> {
debug_context
:
debuginfo
::
FunctionDebugContext
,
/// Function context
fcx
:
&
'a
common
::
FunctionContext
<
'a
,
'tcx
>
,
ccx
:
&
'a
CrateContext
<
'a
,
'tcx
>
,
/// When unwinding is initiated, we have to store this personality
/// value somewhere so that we can load it and re-use it in the
/// resume instruction. The personality is (afaik) some kind of
...
...
@@ -100,7 +101,7 @@ pub struct MirContext<'a, 'tcx:'a> {
impl
<
'a
,
'tcx
>
MirContext
<
'a
,
'tcx
>
{
pub
fn
monomorphize
<
T
>
(
&
self
,
value
:
&
T
)
->
T
where
T
:
TransNormalize
<
'tcx
>
{
monomorphize
::
apply_param_substs
(
self
.
fcx.
ccx
.shared
(),
self
.param_substs
,
value
)
monomorphize
::
apply_param_substs
(
self
.ccx
.shared
(),
self
.param_substs
,
value
)
}
pub
fn
set_debug_loc
(
&
mut
self
,
bcx
:
&
BlockAndBuilder
,
source_info
:
mir
::
SourceInfo
)
{
...
...
@@ -123,12 +124,12 @@ pub fn debug_loc(&mut self, source_info: mir::SourceInfo) -> (DIScope, Span) {
// (unless the crate is being compiled with `-Z debug-macros`).
if
source_info
.span.expn_id
==
NO_EXPANSION
||
source_info
.span.expn_id
==
COMMAND_LINE_EXPN
||
self
.
fcx.
ccx
.sess
()
.opts.debugging_opts.debug_macros
{
self
.ccx
.sess
()
.opts.debugging_opts.debug_macros
{
let
scope
=
self
.scope_metadata_for_loc
(
source_info
.scope
,
source_info
.span.lo
);
(
scope
,
source_info
.span
)
}
else
{
let
cm
=
self
.
fcx.
ccx
.sess
()
.codemap
();
let
cm
=
self
.ccx
.sess
()
.codemap
();
// Walk up the macro expansion chain until we reach a non-expanded span.
let
mut
span
=
source_info
.span
;
while
span
.expn_id
!=
NO_EXPANSION
&&
span
.expn_id
!=
COMMAND_LINE_EXPN
{
...
...
@@ -154,10 +155,8 @@ fn scope_metadata_for_loc(&self, scope_id: mir::VisibilityScope, pos: BytePos)
let
scope_metadata
=
self
.scopes
[
scope_id
]
.scope_metadata
;
if
pos
<
self
.scopes
[
scope_id
]
.file_start_pos
||
pos
>=
self
.scopes
[
scope_id
]
.file_end_pos
{
let
cm
=
self
.fcx.ccx
.sess
()
.codemap
();
debuginfo
::
extend_scope_to_file
(
self
.fcx.ccx
,
scope_metadata
,
&
cm
.lookup_char_pos
(
pos
)
.file
)
let
cm
=
self
.ccx
.sess
()
.codemap
();
debuginfo
::
extend_scope_to_file
(
self
.ccx
,
scope_metadata
,
&
cm
.lookup_char_pos
(
pos
)
.file
)
}
else
{
scope_metadata
}
...
...
@@ -225,6 +224,7 @@ pub fn trans_mir<'a, 'tcx: 'a>(
let
mut
mircx
=
MirContext
{
mir
:
mir
,
fcx
:
fcx
,
ccx
:
fcx
.ccx
,
llpersonalityslot
:
None
,
blocks
:
block_bcxs
,
unreachable_block
:
None
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录