Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f2d01010
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,发现更多精彩内容 >>
未验证
提交
f2d01010
编写于
7月 20, 2017
作者:
O
Oliver Schneider
提交者:
Oliver Schneider
7月 20, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Also test optimized MIR
上级
9710ff48
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
20 deletion
+46
-20
src/bin/miri.rs
src/bin/miri.rs
+1
-5
src/step.rs
src/step.rs
+14
-8
tests/compiletest.rs
tests/compiletest.rs
+24
-7
tests/run-pass-fullmir/integer-ops.rs
tests/run-pass-fullmir/integer-ops.rs
+3
-0
tests/run-pass/cast-rfc0401-vtable-kinds.rs
tests/run-pass/cast-rfc0401-vtable-kinds.rs
+4
-0
未找到文件。
src/bin/miri.rs
浏览文件 @
f2d01010
...
...
@@ -199,11 +199,7 @@ fn main() {
args
.push
(
sysroot_flag
);
args
.push
(
find_sysroot
());
}
// we run the optimization passes inside miri
// if we ran them twice we'd get funny failures due to borrowck ElaborateDrops only working on
// unoptimized MIR
// FIXME: add an after-mir-passes hook to rustc driver
args
.push
(
"-Zmir-opt-level=0"
.to_owned
());
// for auxilary builds in unit tests
args
.push
(
"-Zalways-encode-mir"
.to_owned
());
...
...
src/step.rs
浏览文件 @
f2d01010
...
...
@@ -87,14 +87,9 @@ fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<'tcx> {
match
*
dest_layout
{
Layout
::
General
{
discr
,
..
}
=>
{
// FIXME: I (oli-obk) think we need to check the
// `dest_ty` for the variant's discriminant and write
// instead of the variant index
// We don't have any tests actually going through these lines
let
discr_ty
=
discr
.to_ty
(
&
self
.tcx
,
false
);
let
discr_lval
=
self
.lvalue_field
(
dest
,
0
,
dest_ty
,
discr_ty
)
?
;
self
.write_value
(
Value
::
ByVal
(
PrimVal
::
Bytes
(
variant_index
as
u128
)),
discr_lval
,
discr_ty
)
?
;
let
discr_size
=
discr
.size
()
.bytes
();
let
dest_ptr
=
self
.force_allocation
(
dest
)
?
.to_ptr
()
?
;
self
.memory
.write_uint
(
dest_ptr
,
variant_index
as
u128
,
discr_size
)
?
}
Layout
::
RawNullablePointer
{
nndiscr
,
..
}
=>
{
...
...
@@ -103,6 +98,17 @@ fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<'tcx> {
}
}
Layout
::
StructWrappedNullablePointer
{
nndiscr
,
ref
discrfield
,
..
}
=>
{
if
variant_index
as
u64
!=
nndiscr
{
let
(
offset
,
ty
)
=
self
.nonnull_offset_and_ty
(
dest_ty
,
nndiscr
,
discrfield
)
?
;
let
nonnull
=
self
.force_allocation
(
dest
)
?
.to_ptr
()
?
.offset
(
offset
.bytes
(),
self
.memory.layout
)
?
;
trace!
(
"struct wrapped nullable pointer type: {}"
,
ty
);
// only the pointer part of a fat pointer is used for this space optimization
let
discr_size
=
self
.type_size
(
ty
)
?
.expect
(
"bad StructWrappedNullablePointer discrfield"
);
self
.memory
.write_uint
(
nonnull
,
0
,
discr_size
)
?
;
}
},
_
=>
bug!
(
"SetDiscriminant on {} represented as {:#?}"
,
dest_ty
,
dest_layout
),
}
}
...
...
tests/compiletest.rs
浏览文件 @
f2d01010
#![feature(slice_concat_ext)]
extern
crate
compiletest_rs
as
compiletest
;
use
std
::
slice
::
SliceConcatExt
;
use
std
::
path
::{
PathBuf
,
Path
};
use
std
::
io
::
Write
;
...
...
@@ -41,22 +44,34 @@ fn run_pass(path: &str) {
compiletest
::
run_tests
(
&
config
);
}
fn
miri_pass
(
path
:
&
str
,
target
:
&
str
,
host
:
&
str
,
fullmir
:
bool
)
{
eprintln!
(
"## Running run-pass tests in {} against miri for target {}"
,
path
,
target
);
fn
miri_pass
(
path
:
&
str
,
target
:
&
str
,
host
:
&
str
,
fullmir
:
bool
,
opt
:
bool
)
{
let
opt_str
=
if
opt
{
" with optimizations"
}
else
{
""
};
eprintln!
(
"## Running run-pass tests in {} against miri for target {}{}"
,
path
,
target
,
opt_str
);
let
mut
config
=
compiletest
::
default_config
();
config
.mode
=
"mir-opt"
.parse
()
.expect
(
"Invalid mode"
);
config
.src_base
=
PathBuf
::
from
(
path
);
config
.target
=
target
.to_owned
();
config
.host
=
host
.to_owned
();
config
.rustc_path
=
PathBuf
::
from
(
"target/debug/miri"
);
let
mut
flags
=
Vec
::
new
();
if
fullmir
{
if
host
!=
target
{
// skip fullmir on nonhost
return
;
}
let
sysroot
=
Path
::
new
(
&
std
::
env
::
var
(
"HOME"
)
.unwrap
())
.join
(
".xargo"
)
.join
(
"HOST"
);
config
.target_rustcflags
=
Some
(
format!
(
"--sysroot {}"
,
sysroot
.to_str
()
.unwrap
()));
flags
.push
(
format!
(
"--sysroot {}"
,
sysroot
.to_str
()
.unwrap
()));
}
if
opt
{
flags
.push
(
"-Zmir-opt-level=3"
.to_owned
());
}
else
{
flags
.push
(
"-Zmir-opt-level=0"
.to_owned
());
}
config
.target_rustcflags
=
Some
(
flags
.join
(
" "
));
// don't actually execute the final binary, it might be for other targets and we only care
// about running miri, not the binary.
config
.runtool
=
Some
(
"echo
\"\"
|| "
.to_owned
());
...
...
@@ -113,10 +128,12 @@ fn run_pass_miri() {
let
sysroot
=
get_sysroot
();
let
host
=
get_host
();
for_all_targets
(
&
sysroot
,
|
target
|
{
miri_pass
(
"tests/run-pass"
,
&
target
,
&
host
,
false
);
});
miri_pass
(
"tests/run-pass-fullmir"
,
&
host
,
&
host
,
true
);
for
&
opt
in
[
false
,
true
]
.iter
()
{
for_all_targets
(
&
sysroot
,
|
target
|
{
miri_pass
(
"tests/run-pass"
,
&
target
,
&
host
,
false
,
opt
);
});
miri_pass
(
"tests/run-pass-fullmir"
,
&
host
,
&
host
,
true
,
opt
);
}
}
#[test]
...
...
tests/run-pass-fullmir/integer-ops.rs
浏览文件 @
f2d01010
...
...
@@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// FIXME: remove the next line once https://github.com/rust-lang/rust/issues/43359 is fixed
// compile-flags: -Zmir-opt-level=0
use
std
::
i32
;
pub
fn
main
()
{
...
...
tests/run-pass/cast-rfc0401-vtable-kinds.rs
浏览文件 @
f2d01010
...
...
@@ -8,6 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// FIXME: remove the next line when https://github.com/rust-lang/rust/issues/43358 is resolved
// compile-flags: -Zmir-opt-level=0
// Check that you can cast between different pointers to trait objects
// whose vtable have the same kind (both lengths, or both trait pointers).
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录