Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2a5029ed
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,发现更多精彩内容 >>
提交
2a5029ed
编写于
12月 18, 2016
作者:
S
Scott Olson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update MIR passes to match rustc.
上级
b233ada5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
3 deletion
+49
-3
src/eval_context.rs
src/eval_context.rs
+11
-1
src/lvalue.rs
src/lvalue.rs
+9
-1
src/step.rs
src/step.rs
+29
-1
未找到文件。
src/eval_context.rs
浏览文件 @
2a5029ed
...
...
@@ -465,7 +465,7 @@ pub(super) fn eval_rvalue_into_lvalue(
let
operand_ty
=
self
.operand_ty
(
operand
);
assert_eq!
(
self
.type_size
(
operand_ty
)
?
,
Some
(
0
));
}
self
.write_primval
(
dest
,
PrimVal
::
from_i64
(
0
),
dest_ty
)
?
;
self
.write_primval
(
dest
,
PrimVal
::
Bytes
(
0
),
dest_ty
)
?
;
}
}
else
{
bug!
(
"tried to assign {:?} to Layout::RawNullablePointer"
,
kind
);
...
...
@@ -1423,11 +1423,21 @@ pub fn run_mir_passes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
no_landing_pads
::
NoLandingPads
));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
simplify
::
SimplifyCfg
::
new
(
"no-landing-pads"
)));
// From here on out, regions are gone.
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
erase_regions
::
EraseRegions
));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
add_call_guards
::
AddCallGuards
));
passes
.push_pass
(
Box
::
new
(::
rustc_borrowck
::
ElaborateDrops
));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
no_landing_pads
::
NoLandingPads
));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
simplify
::
SimplifyCfg
::
new
(
"elaborate-drops"
)));
// No lifetime analysis based on borrowing can be done from here on out.
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
instcombine
::
InstCombine
::
new
()));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
deaggregator
::
Deaggregator
));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
copy_prop
::
CopyPropagation
));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
simplify
::
SimplifyLocals
));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
add_call_guards
::
AddCallGuards
));
passes
.push_pass
(
Box
::
new
(::
rustc_mir
::
transform
::
dump_mir
::
Marker
(
"PreMiri"
)));
passes
.run_passes
(
tcx
);
...
...
src/lvalue.rs
浏览文件 @
2a5029ed
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
mir
;
use
rustc
::
ty
::
layout
::
Size
;
use
rustc
::
ty
::
subst
::
Substs
;
use
rustc
::
ty
::{
self
,
Ty
};
use
rustc_data_structures
::
indexed_vec
::
Idx
;
...
...
@@ -196,7 +197,7 @@ fn eval_lvalue_projection(
}
RawNullablePointer
{
..
}
=>
{
assert_eq!
(
field
.index
()
,
0
);
assert_eq!
(
field
,
0
);
return
Ok
(
base
);
}
...
...
@@ -206,6 +207,13 @@ fn eval_lvalue_projection(
UntaggedUnion
{
..
}
=>
return
Ok
(
base
),
Vector
{
element
,
count
}
=>
{
let
field
=
field
as
u64
;
assert
!
(
field
<
count
);
let
elem_size
=
element
.size
(
&
self
.tcx.data_layout
)
.bytes
();
Size
::
from_bytes
(
field
*
elem_size
)
}
_
=>
bug!
(
"field access on non-product type: {:?}"
,
base_layout
),
};
...
...
src/step.rs
浏览文件 @
2a5029ed
...
...
@@ -8,6 +8,7 @@
use
rustc
::
hir
;
use
rustc
::
mir
::
visit
::{
Visitor
,
LvalueContext
};
use
rustc
::
mir
;
use
rustc
::
ty
::
layout
::
Layout
;
use
rustc
::
ty
::{
subst
,
self
};
use
error
::{
EvalResult
,
EvalError
};
...
...
@@ -85,7 +86,34 @@ fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<'tcx, ()> {
use
rustc
::
mir
::
StatementKind
::
*
;
match
stmt
.kind
{
Assign
(
ref
lvalue
,
ref
rvalue
)
=>
self
.eval_rvalue_into_lvalue
(
rvalue
,
lvalue
)
?
,
SetDiscriminant
{
..
}
=>
unimplemented!
(),
SetDiscriminant
{
ref
lvalue
,
variant_index
}
=>
{
let
dest
=
self
.eval_lvalue
(
lvalue
)
?
;
let
dest_ty
=
self
.lvalue_ty
(
lvalue
);
let
dest_layout
=
self
.type_layout
(
dest_ty
)
?
;
match
*
dest_layout
{
Layout
::
General
{
discr
,
ref
variants
,
..
}
=>
{
let
discr_size
=
discr
.size
()
.bytes
();
let
discr_offset
=
variants
[
variant_index
]
.offsets
[
0
]
.bytes
();
// FIXME(solson)
let
dest
=
self
.force_allocation
(
dest
)
?
;
let
discr_dest
=
(
dest
.to_ptr
())
.offset
(
discr_offset
);
self
.memory
.write_uint
(
discr_dest
,
variant_index
as
u64
,
discr_size
)
?
;
}
Layout
::
RawNullablePointer
{
nndiscr
,
..
}
=>
{
use
value
::
PrimVal
;
if
variant_index
as
u64
!=
nndiscr
{
self
.write_primval
(
dest
,
PrimVal
::
Bytes
(
0
),
dest_ty
)
?
;
}
}
_
=>
bug!
(
"SetDiscriminant on {} represented as {:#?}"
,
dest_ty
,
dest_layout
),
}
}
// Miri can safely ignore these. Only translation needs it.
StorageLive
(
_
)
|
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录