Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4c27a3c6
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
4c27a3c6
编写于
6月 07, 2016
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
trans: Enable falling back to on-demand instantiation for drop-glue and monomorphizations.
See issue #34151 for more information.
上级
a7bc0b92
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
22 deletion
+66
-22
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+10
-6
src/librustc_trans/context.rs
src/librustc_trans/context.rs
+2
-0
src/librustc_trans/glue.rs
src/librustc_trans/glue.rs
+27
-6
src/librustc_trans/monomorphize.rs
src/librustc_trans/monomorphize.rs
+19
-2
src/librustc_trans/partitioning.rs
src/librustc_trans/partitioning.rs
+2
-2
src/librustc_trans/trans_item.rs
src/librustc_trans/trans_item.rs
+6
-6
未找到文件。
src/librustc_trans/base.rs
浏览文件 @
4c27a3c6
...
...
@@ -2684,6 +2684,8 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
println!
(
"n_null_glues: {}"
,
stats
.n_null_glues
.get
());
println!
(
"n_real_glues: {}"
,
stats
.n_real_glues
.get
());
println!
(
"n_fallback_instantiations: {}"
,
stats
.n_fallback_instantiations
.get
());
println!
(
"n_fns: {}"
,
stats
.n_fns
.get
());
println!
(
"n_monos: {}"
,
stats
.n_monos
.get
());
println!
(
"n_inlines: {}"
,
stats
.n_inlines
.get
());
...
...
@@ -2875,6 +2877,14 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
assert
!
(
scx
.tcx
()
.sess.opts.cg.codegen_units
==
codegen_units
.len
()
||
scx
.tcx
()
.sess.opts.debugging_opts.incremental
.is_some
());
{
let
mut
ccx_map
=
scx
.translation_items
()
.borrow_mut
();
for
trans_item
in
items
.iter
()
.cloned
()
{
ccx_map
.insert
(
trans_item
,
TransItemState
::
PredictedButNotGenerated
);
}
}
if
scx
.sess
()
.opts.debugging_opts.print_trans_items
.is_some
()
{
let
mut
item_to_cgus
=
HashMap
::
new
();
...
...
@@ -2926,12 +2936,6 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
for
item
in
item_keys
{
println!
(
"TRANS_ITEM {}"
,
item
);
}
let
mut
ccx_map
=
scx
.translation_items
()
.borrow_mut
();
for
cgi
in
items
{
ccx_map
.insert
(
cgi
,
TransItemState
::
PredictedButNotGenerated
);
}
}
(
codegen_units
,
symbol_map
)
...
...
src/librustc_trans/context.rs
浏览文件 @
4c27a3c6
...
...
@@ -53,6 +53,7 @@ pub struct Stats {
pub
n_glues_created
:
Cell
<
usize
>
,
pub
n_null_glues
:
Cell
<
usize
>
,
pub
n_real_glues
:
Cell
<
usize
>
,
pub
n_fallback_instantiations
:
Cell
<
usize
>
,
pub
n_fns
:
Cell
<
usize
>
,
pub
n_monos
:
Cell
<
usize
>
,
pub
n_inlines
:
Cell
<
usize
>
,
...
...
@@ -406,6 +407,7 @@ pub fn new(tcx: TyCtxt<'b, 'tcx, 'tcx>,
n_glues_created
:
Cell
::
new
(
0
),
n_null_glues
:
Cell
::
new
(
0
),
n_real_glues
:
Cell
::
new
(
0
),
n_fallback_instantiations
:
Cell
::
new
(
0
),
n_fns
:
Cell
::
new
(
0
),
n_monos
:
Cell
::
new
(
0
),
n_inlines
:
Cell
::
new
(
0
),
...
...
src/librustc_trans/glue.rs
浏览文件 @
4c27a3c6
...
...
@@ -234,13 +234,34 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
g
:
DropGlueKind
<
'tcx
>
)
->
ValueRef
{
let
g
=
g
.map_ty
(|
t
|
get_drop_glue_type
(
ccx
.tcx
(),
t
));
match
ccx
.drop_glues
()
.borrow
()
.get
(
&
g
)
{
Some
(
&
(
glue
,
_
))
=>
glue
,
None
=>
{
bug!
(
"Could not find drop glue for {:?} -- {} -- {}.
\
It should have be instantiated during the pre-definition phase"
,
g
,
TransItem
::
DropGlue
(
g
)
.to_raw_string
(),
ccx
.codegen_unit
()
.name
)
}
Some
(
&
(
glue
,
_
))
=>
return
glue
,
None
=>
{
debug!
(
"Could not find drop glue for {:?} -- {} -- {}.
\
Falling back to on-demand instantiation."
,
g
,
TransItem
::
DropGlue
(
g
)
.to_raw_string
(),
ccx
.codegen_unit
()
.name
);
ccx
.stats
()
.n_fallback_instantiations
.set
(
ccx
.stats
()
.n_fallback_instantiations
.get
()
+
1
);
}
}
// FIXME: #34151
// Normally, getting here would indicate a bug in trans::collector,
// since it seems to have missed a translation item. When we are
// translating with non-MIR-based trans, however, the results of the
// collector are not entirely reliable since it bases its analysis
// on MIR. Thus, we'll instantiate the missing function on demand in
// this codegen unit, so that things keep working.
TransItem
::
DropGlue
(
g
)
.predefine
(
ccx
,
llvm
::
LinkOnceODRLinkage
);
TransItem
::
DropGlue
(
g
)
.define
(
ccx
);
// Now that we made sure that the glue function is in ccx.drop_glues,
// give it another try
get_drop_glue_core
(
ccx
,
g
)
}
pub
fn
implement_drop_glue
<
'a
,
'tcx
>
(
ccx
:
&
CrateContext
<
'a
,
'tcx
>
,
...
...
src/librustc_trans/monomorphize.rs
浏览文件 @
4c27a3c6
...
...
@@ -121,8 +121,25 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ref
attrs
,
node
:
hir
::
MethodTraitItem
(
hir
::
MethodSig
{
..
},
Some
(
_
)),
..
})
=>
{
attributes
::
from_fn_attrs
(
ccx
,
attrs
,
lldecl
);
llvm
::
SetLinkage
(
lldecl
,
llvm
::
ExternalLinkage
);
let
trans_item
=
TransItem
::
Fn
(
instance
);
if
ccx
.shared
()
.translation_items
()
.borrow
()
.contains_key
(
&
trans_item
)
{
attributes
::
from_fn_attrs
(
ccx
,
attrs
,
lldecl
);
llvm
::
SetLinkage
(
lldecl
,
llvm
::
ExternalLinkage
);
}
else
{
// FIXME: #34151
// Normally, getting here would indicate a bug in trans::collector,
// since it seems to have missed a translation item. When we are
// translating with non-MIR based trans, however, the results of
// the collector are not entirely reliable since it bases its
// analysis on MIR. Thus, we'll instantiate the missing function
// privately in this codegen unit, so that things keep working.
ccx
.stats
()
.n_fallback_instantiations
.set
(
ccx
.stats
()
.n_fallback_instantiations
.get
()
+
1
);
trans_item
.predefine
(
ccx
,
llvm
::
PrivateLinkage
);
trans_item
.define
(
ccx
);
}
}
hir_map
::
NodeVariant
(
_
)
|
hir_map
::
NodeStructCtor
(
_
)
=>
{
...
...
src/librustc_trans/partitioning.rs
浏览文件 @
4c27a3c6
...
...
@@ -517,11 +517,11 @@ fn single_codegen_unit<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
if
reachable
.contains
(
&
node_id
)
{
llvm
::
ExternalLinkage
}
else
{
llvm
::
Internal
Linkage
llvm
::
Private
Linkage
}
}
TransItem
::
DropGlue
(
_
)
=>
{
llvm
::
Internal
Linkage
llvm
::
Private
Linkage
}
TransItem
::
Fn
(
instance
)
=>
{
if
trans_item
.is_generic_fn
()
||
...
...
src/librustc_trans/trans_item.rs
浏览文件 @
4c27a3c6
...
...
@@ -108,19 +108,19 @@ pub fn predefine(&self,
ccx
.codegen_unit
()
.name
);
let
symbol_name
=
ccx
.symbol_map
()
.get
(
*
self
)
.expect
(
"Name not present in SymbolMap?"
);
debug!
(
"symbol {}"
,
symbol_name
);
.get
_or_compute
(
ccx
.shared
(),
*
self
);
debug!
(
"symbol {}"
,
&
symbol_name
);
match
*
self
{
TransItem
::
Static
(
node_id
)
=>
{
TransItem
::
predefine_static
(
ccx
,
node_id
,
linkage
,
symbol_name
);
TransItem
::
predefine_static
(
ccx
,
node_id
,
linkage
,
&
symbol_name
);
}
TransItem
::
Fn
(
instance
)
=>
{
TransItem
::
predefine_fn
(
ccx
,
instance
,
linkage
,
symbol_name
);
TransItem
::
predefine_fn
(
ccx
,
instance
,
linkage
,
&
symbol_name
);
}
TransItem
::
DropGlue
(
dg
)
=>
{
TransItem
::
predefine_drop_glue
(
ccx
,
dg
,
linkage
,
symbol_name
);
TransItem
::
predefine_drop_glue
(
ccx
,
dg
,
linkage
,
&
symbol_name
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录