Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
17526155
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,发现更多精彩内容 >>
提交
17526155
编写于
2月 11, 2016
作者:
S
Simonas Kazlauskas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MSVC SEH in MIR is implemented here
上级
5ad4673a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
80 addition
and
32 deletion
+80
-32
src/librustc_mir/mir_map.rs
src/librustc_mir/mir_map.rs
+0
-3
src/librustc_mir/transform/no_landing_pads.rs
src/librustc_mir/transform/no_landing_pads.rs
+3
-1
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/common.rs
+4
-0
src/librustc_trans/trans/mir/block.rs
src/librustc_trans/trans/mir/block.rs
+73
-24
src/test/run-fail/mir_drop_panics.rs
src/test/run-fail/mir_drop_panics.rs
+0
-1
src/test/run-fail/mir_trans_calls_converging_drops.rs
src/test/run-fail/mir_trans_calls_converging_drops.rs
+0
-1
src/test/run-fail/mir_trans_calls_converging_drops_2.rs
src/test/run-fail/mir_trans_calls_converging_drops_2.rs
+0
-1
src/test/run-fail/mir_trans_calls_diverging_drops.rs
src/test/run-fail/mir_trans_calls_diverging_drops.rs
+0
-1
未找到文件。
src/librustc_mir/mir_map.rs
浏览文件 @
17526155
...
...
@@ -148,9 +148,6 @@ fn visit_fn(&mut self,
match
build_mir
(
Cx
::
new
(
&
infcx
),
implicit_arg_tys
,
id
,
span
,
decl
,
body
)
{
Ok
(
mut
mir
)
=>
{
// FIXME: This should run later rather than earlier (since this is supposed to be a
// codegen option), but we do not want to re-run the whole simplify_cfg pass all
// over again after this pass.
no_landing_pads
::
NoLandingPads
.run_on_mir
(
&
mut
mir
,
self
.tcx
);
simplify_cfg
::
SimplifyCfg
::
new
()
.run_on_mir
(
&
mut
mir
,
self
.tcx
);
...
...
src/librustc_mir/transform/no_landing_pads.rs
浏览文件 @
17526155
...
...
@@ -26,7 +26,9 @@ fn visit_terminator(&mut self, bb: BasicBlock, terminator: &mut Terminator<'tcx>
Terminator
::
Return
|
Terminator
::
If
{
..
}
|
Terminator
::
Switch
{
..
}
|
Terminator
::
SwitchInt
{
..
}
=>
{
/* nothing to do */
},
Terminator
::
SwitchInt
{
..
}
=>
{
/* nothing to do */
},
Terminator
::
Drop
{
ref
mut
unwind
,
..
}
=>
{
unwind
.take
();
},
...
...
src/librustc_trans/trans/common.rs
浏览文件 @
17526155
...
...
@@ -767,6 +767,10 @@ pub fn monomorphize<T>(&self, value: &T) -> T
{
self
.bcx
.monomorphize
(
value
)
}
pub
fn
set_lpad
(
&
self
,
lpad
:
Option
<
LandingPad
>
)
{
self
.bcx.lpad
.set
(
lpad
.map
(|
p
|
&*
self
.fcx
()
.lpad_arena
.alloc
(
p
)))
}
}
impl
<
'blk
,
'tcx
>
Deref
for
BlockAndBuilder
<
'blk
,
'tcx
>
{
...
...
src/librustc_trans/trans/mir/block.rs
浏览文件 @
17526155
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
llvm
::{
BasicBlockRef
,
ValueRef
};
use
llvm
::{
BasicBlockRef
,
ValueRef
,
OperandBundleDef
};
use
rustc
::
middle
::
ty
;
use
rustc
::
mir
::
repr
as
mir
;
use
syntax
::
abi
::
Abi
;
...
...
@@ -34,6 +34,18 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
let
mut
bcx
=
self
.bcx
(
bb
);
let
data
=
self
.mir
.basic_block_data
(
bb
);
// MSVC SEH bits
let
(
cleanup_pad
,
cleanup_bundle
)
=
if
let
Some
((
cp
,
cb
))
=
self
.make_cleanup_pad
(
bb
)
{
(
Some
(
cp
),
Some
(
cb
))
}
else
{
(
None
,
None
)
};
let
funclet_br
=
|
bcx
:
BlockAndBuilder
,
llbb
:
BasicBlockRef
|
if
let
Some
(
cp
)
=
cleanup_pad
{
bcx
.cleanup_ret
(
cp
,
Some
(
llbb
));
}
else
{
bcx
.br
(
llbb
);
};
for
statement
in
&
data
.statements
{
bcx
=
self
.trans_statement
(
bcx
,
statement
);
}
...
...
@@ -41,8 +53,21 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
debug!
(
"trans_block: terminator: {:?}"
,
data
.terminator
());
match
*
data
.terminator
()
{
mir
::
Terminator
::
Resume
=>
{
if
let
Some
(
cleanup_pad
)
=
cleanup_pad
{
bcx
.cleanup_ret
(
cleanup_pad
,
None
);
}
else
{
let
ps
=
self
.get_personality_slot
(
&
bcx
);
let
lp
=
bcx
.load
(
ps
);
bcx
.with_block
(|
bcx
|
{
base
::
call_lifetime_end
(
bcx
,
ps
);
base
::
trans_unwind_resume
(
bcx
,
lp
);
});
}
}
mir
::
Terminator
::
Goto
{
target
}
=>
{
bcx
.br
(
self
.llblock
(
target
));
funclet_br
(
bcx
,
self
.llblock
(
target
));
}
mir
::
Terminator
::
If
{
ref
cond
,
targets
:
(
true_bb
,
false_bb
)
}
=>
{
...
...
@@ -85,19 +110,10 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
}
}
mir
::
Terminator
::
Resume
=>
{
let
ps
=
self
.get_personality_slot
(
&
bcx
);
let
lp
=
bcx
.load
(
ps
);
bcx
.with_block
(|
bcx
|
{
base
::
call_lifetime_end
(
bcx
,
ps
);
base
::
trans_unwind_resume
(
bcx
,
lp
);
});
}
mir
::
Terminator
::
Return
=>
{
let
return_ty
=
bcx
.monomorphize
(
&
self
.mir.return_ty
);
bcx
.with_block
(|
bcx
|
{
base
::
build_return_block
(
bcx
.fcx
,
bcx
,
return_ty
,
DebugLoc
::
None
);
base
::
build_return_block
(
self
.fcx
,
bcx
,
return_ty
,
DebugLoc
::
None
);
})
}
...
...
@@ -106,7 +122,7 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
let
ty
=
lvalue
.ty
.to_ty
(
bcx
.tcx
());
// Double check for necessity to drop
if
!
glue
::
type_needs_drop
(
bcx
.tcx
(),
ty
)
{
bcx
.br
(
self
.llblock
(
target
));
funclet_br
(
bcx
,
self
.llblock
(
target
));
return
;
}
let
drop_fn
=
glue
::
get_drop_glue
(
bcx
.ccx
(),
ty
);
...
...
@@ -123,11 +139,11 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
&
[
llvalue
],
self
.llblock
(
target
),
unwind
.llbb
(),
None
,
cleanup_bundle
.as_ref
()
,
None
);
}
else
{
bcx
.call
(
drop_fn
,
&
[
llvalue
],
None
,
None
);
bcx
.br
(
self
.llblock
(
target
));
bcx
.call
(
drop_fn
,
&
[
llvalue
],
cleanup_bundle
.as_ref
()
,
None
);
funclet_br
(
bcx
,
self
.llblock
(
target
));
}
}
...
...
@@ -191,14 +207,14 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
&
llargs
[
..
],
unreachable_blk
.llbb
,
landingpad
.llbb
(),
None
,
cleanup_bundle
.as_ref
()
,
Some
(
attrs
));
},
(
false
,
&
Some
(
cleanup
),
&
Some
((
_
,
success
)))
=>
{
let
cleanup
=
self
.bcx
(
cleanup
);
let
landingpad
=
self
.make_landing_pad
(
cleanup
);
let
(
target
,
postinvoke
)
=
if
must_copy_dest
{
(
bcx
.fcx
()
.new_block
(
""
,
None
)
.build
(),
Some
(
self
.bcx
(
success
)))
(
self
.fcx
.new_block
(
""
,
None
)
.build
(),
Some
(
self
.bcx
(
success
)))
}
else
{
(
self
.bcx
(
success
),
None
)
};
...
...
@@ -206,7 +222,7 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
&
llargs
[
..
],
target
.llbb
(),
landingpad
.llbb
(),
None
,
cleanup_bundle
.as_ref
()
,
Some
(
attrs
));
if
let
Some
(
postinvoketarget
)
=
postinvoke
{
// We translate the copy into a temporary block. The temporary block is
...
...
@@ -242,13 +258,16 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
}
},
(
false
,
_
,
&
None
)
=>
{
bcx
.call
(
callee
.immediate
(),
&
llargs
[
..
],
None
,
Some
(
attrs
));
bcx
.call
(
callee
.immediate
(),
&
llargs
[
..
],
cleanup_bundle
.as_ref
(),
Some
(
attrs
));
bcx
.unreachable
();
}
(
false
,
_
,
&
Some
((
_
,
target
)))
=>
{
let
llret
=
bcx
.call
(
callee
.immediate
(),
&
llargs
[
..
],
None
,
cleanup_bundle
.as_ref
()
,
Some
(
attrs
));
if
must_copy_dest
{
let
(
ret_dest
,
ret_ty
)
=
ret_dest_ty
...
...
@@ -257,7 +276,7 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
base
::
store_ty
(
bcx
,
llret
,
ret_dest
.llval
,
ret_ty
);
});
}
bcx
.br
(
self
.llblock
(
target
));
funclet_br
(
bcx
,
self
.llblock
(
target
));
}
// Foreign functions
(
true
,
_
,
destination
)
=>
{
...
...
@@ -273,7 +292,7 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock) {
debugloc
)
});
if
let
Some
((
_
,
target
))
=
*
destination
{
bcx
.br
(
self
.llblock
(
target
));
funclet_br
(
bcx
,
self
.llblock
(
target
));
}
},
}
...
...
@@ -296,11 +315,16 @@ fn get_personality_slot(&mut self, bcx: &BlockAndBuilder<'bcx, 'tcx>) -> ValueRe
}
}
/// Create a landingpad wrapper around the given Block.
///
/// No-op in MSVC SEH scheme.
fn
make_landing_pad
(
&
mut
self
,
cleanup
:
BlockAndBuilder
<
'bcx
,
'tcx
>
)
->
BlockAndBuilder
<
'bcx
,
'tcx
>
{
// FIXME(#30941) this doesn't handle msvc-style exceptions
if
base
::
wants_msvc_seh
(
cleanup
.sess
())
{
return
cleanup
;
}
let
bcx
=
self
.fcx
.new_block
(
"cleanup"
,
None
)
.build
();
let
ccx
=
bcx
.ccx
();
let
llpersonality
=
self
.fcx
.eh_personality
();
...
...
@@ -313,6 +337,31 @@ fn make_landing_pad(&mut self,
bcx
}
/// Create prologue cleanuppad instruction under MSVC SEH handling scheme.
///
/// Also handles setting some state for the original trans and creating an operand bundle for
/// function calls.
fn
make_cleanup_pad
(
&
mut
self
,
bb
:
mir
::
BasicBlock
)
->
Option
<
(
ValueRef
,
OperandBundleDef
)
>
{
let
bcx
=
self
.bcx
(
bb
);
let
data
=
self
.mir
.basic_block_data
(
bb
);
let
use_funclets
=
base
::
wants_msvc_seh
(
bcx
.sess
())
&&
data
.is_cleanup
;
let
cleanup_pad
=
if
use_funclets
{
bcx
.set_personality_fn
(
self
.fcx
.eh_personality
());
Some
(
bcx
.cleanup_pad
(
None
,
&
[]))
}
else
{
None
};
// Set the landingpad global-state for old translator, so it knows about the SEH used.
bcx
.set_lpad
(
if
let
Some
(
cleanup_pad
)
=
cleanup_pad
{
Some
(
common
::
LandingPad
::
msvc
(
cleanup_pad
))
}
else
if
data
.is_cleanup
{
Some
(
common
::
LandingPad
::
gnu
())
}
else
{
None
});
cleanup_pad
.map
(|
f
|
(
f
,
OperandBundleDef
::
new
(
"funclet"
,
&
[
f
])))
}
fn
unreachable_block
(
&
mut
self
)
->
Block
<
'bcx
,
'tcx
>
{
self
.unreachable_block
.unwrap_or_else
(||
{
let
bl
=
self
.fcx
.new_block
(
"unreachable"
,
None
);
...
...
src/test/run-fail/mir_drop_panics.rs
浏览文件 @
17526155
...
...
@@ -9,7 +9,6 @@
// except according to those terms.
#![feature(rustc_attrs)]
// ignore-msvc: FIXME(#30941)
// error-pattern:panic 1
// error-pattern:drop 2
use
std
::
io
::{
self
,
Write
};
...
...
src/test/run-fail/mir_trans_calls_converging_drops.rs
浏览文件 @
17526155
...
...
@@ -10,7 +10,6 @@
#![feature(rustc_attrs)]
// ignore-msvc: FIXME(#30941)
// error-pattern:converging_fn called
// error-pattern:0 dropped
// error-pattern:exit
...
...
src/test/run-fail/mir_trans_calls_converging_drops_2.rs
浏览文件 @
17526155
...
...
@@ -10,7 +10,6 @@
#![feature(rustc_attrs)]
// ignore-msvc: FIXME(#30941)
// error-pattern:complex called
// error-pattern:dropped
// error-pattern:exit
...
...
src/test/run-fail/mir_trans_calls_diverging_drops.rs
浏览文件 @
17526155
...
...
@@ -10,7 +10,6 @@
#![feature(rustc_attrs)]
// ignore-msvc: FIXME(#30941)
// error-pattern:diverging_fn called
// error-pattern:0 dropped
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录