Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7f04d35c
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,发现更多精彩内容 >>
提交
7f04d35c
编写于
4月 21, 2016
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add FixedUnitCount codegen unit partitioning strategy.
上级
c61f2293
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
59 addition
and
13 deletion
+59
-13
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+11
-2
src/librustc_trans/partitioning.rs
src/librustc_trans/partitioning.rs
+38
-1
src/test/codegen-units/partitioning/extern-drop-glue.rs
src/test/codegen-units/partitioning/extern-drop-glue.rs
+1
-1
src/test/codegen-units/partitioning/extern-generic.rs
src/test/codegen-units/partitioning/extern-generic.rs
+1
-1
src/test/codegen-units/partitioning/inlining-from-extern-crate.rs
.../codegen-units/partitioning/inlining-from-extern-crate.rs
+1
-1
src/test/codegen-units/partitioning/local-drop-glue.rs
src/test/codegen-units/partitioning/local-drop-glue.rs
+1
-1
src/test/codegen-units/partitioning/local-generic.rs
src/test/codegen-units/partitioning/local-generic.rs
+1
-1
src/test/codegen-units/partitioning/local-inlining.rs
src/test/codegen-units/partitioning/local-inlining.rs
+1
-1
src/test/codegen-units/partitioning/local-transitive-inlining.rs
...t/codegen-units/partitioning/local-transitive-inlining.rs
+1
-1
src/test/codegen-units/partitioning/methods-are-with-self-type.rs
.../codegen-units/partitioning/methods-are-with-self-type.rs
+1
-1
src/test/codegen-units/partitioning/regular-modules.rs
src/test/codegen-units/partitioning/regular-modules.rs
+1
-1
src/test/codegen-units/partitioning/statics.rs
src/test/codegen-units/partitioning/statics.rs
+1
-1
未找到文件。
src/librustc_trans/base.rs
浏览文件 @
7f04d35c
...
...
@@ -58,7 +58,7 @@
use
build
::
*
;
use
builder
::{
Builder
,
noname
};
use
callee
::{
Callee
,
CallArgs
,
ArgExprs
,
ArgVals
};
use
partitioning
;
use
partitioning
::{
self
,
PartitioningStrategy
}
;
use
cleanup
::{
self
,
CleanupMethods
,
DropHint
};
use
closure
;
use
common
::{
Block
,
C_bool
,
C_bytes_in_context
,
C_i32
,
C_int
,
C_uint
,
C_integral
};
...
...
@@ -2938,8 +2938,17 @@ fn collect_translation_items<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>) {
collector
::
collect_crate_translation_items
(
&
ccx
,
collection_mode
)
});
let
strategy
=
if
ccx
.sess
()
.opts.debugging_opts.incremental
.is_some
()
{
PartitioningStrategy
::
PerModule
}
else
{
PartitioningStrategy
::
FixedUnitCount
(
ccx
.sess
()
.opts.cg.codegen_units
)
};
let
codegen_units
=
time
(
time_passes
,
"codegen unit partitioning"
,
||
{
partitioning
::
partition
(
ccx
.tcx
(),
items
.iter
()
.cloned
(),
&
inlining_map
)
partitioning
::
partition
(
ccx
.tcx
(),
items
.iter
()
.cloned
(),
strategy
,
&
inlining_map
)
});
if
ccx
.sess
()
.opts.debugging_opts.print_trans_items
.is_some
()
{
...
...
src/librustc_trans/partitioning.rs
浏览文件 @
7f04d35c
...
...
@@ -132,11 +132,17 @@ pub struct CodegenUnit<'tcx> {
pub
items
:
FnvHashMap
<
TransItem
<
'tcx
>
,
llvm
::
Linkage
>
,
}
pub
enum
PartitioningStrategy
{
PerModule
,
FixedUnitCount
(
usize
)
}
// Anything we can't find a proper codegen unit for goes into this.
const
FALLBACK_CODEGEN_UNIT
:
&
'static
str
=
"__rustc_fallback_codegen_unit"
;
pub
fn
partition
<
'tcx
,
I
>
(
tcx
:
&
TyCtxt
<
'tcx
>
,
trans_items
:
I
,
strategy
:
PartitioningStrategy
,
inlining_map
:
&
InliningMap
<
'tcx
>
)
->
Vec
<
CodegenUnit
<
'tcx
>>
where
I
:
Iterator
<
Item
=
TransItem
<
'tcx
>>
...
...
@@ -144,7 +150,11 @@ pub fn partition<'tcx, I>(tcx: &TyCtxt<'tcx>,
// In the first step, we place all regular translation items into their
// respective 'home' codegen unit. Regular translation items are all
// functions and statics defined in the local crate.
let
initial_partitioning
=
place_root_translation_items
(
tcx
,
trans_items
);
let
mut
initial_partitioning
=
place_root_translation_items
(
tcx
,
trans_items
);
if
let
PartitioningStrategy
::
FixedUnitCount
(
count
)
=
strategy
{
merge_codegen_units
(
&
mut
initial_partitioning
,
count
,
&
tcx
.crate_name
[
..
]);
}
// In the next step, we use the inlining map to determine which addtional
// translation items have to go into each codegen unit. These additional
...
...
@@ -217,6 +227,33 @@ fn place_root_translation_items<'tcx, I>(tcx: &TyCtxt<'tcx>,
}
}
fn
merge_codegen_units
<
'tcx
>
(
initial_partitioning
:
&
mut
InitialPartitioning
<
'tcx
>
,
target_cgu_count
:
usize
,
crate_name
:
&
str
)
{
if
target_cgu_count
>=
initial_partitioning
.codegen_units
.len
()
{
return
;
}
assert
!
(
target_cgu_count
>=
1
);
let
codegen_units
=
&
mut
initial_partitioning
.codegen_units
;
// Merge the two smallest codegen units until the target size is reached
while
codegen_units
.len
()
>
target_cgu_count
{
// Sort small cgus to the back
codegen_units
.as_mut_slice
()
.sort_by_key
(|
cgu
|
-
(
cgu
.items
.len
()
as
i64
));
let
smallest
=
codegen_units
.pop
()
.unwrap
();
let
second_smallest
=
codegen_units
.last_mut
()
.unwrap
();
for
(
k
,
v
)
in
smallest
.items
.into_iter
()
{
second_smallest
.items
.insert
(
k
,
v
);
}
}
for
(
index
,
cgu
)
in
codegen_units
.iter_mut
()
.enumerate
()
{
cgu
.name
=
token
::
intern_and_get_ident
(
&
format!
(
"{}.{}"
,
crate_name
,
index
)[
..
]);
}
}
fn
place_inlined_translation_items
<
'tcx
>
(
initial_partitioning
:
InitialPartitioning
<
'tcx
>
,
inlining_map
:
&
InliningMap
<
'tcx
>
)
->
Vec
<
CodegenUnit
<
'tcx
>>
{
...
...
src/test/codegen-units/partitioning/extern-drop-glue.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// compile-flags:-Zprint-trans-items=lazy
-Zincremental=""
#![allow(dead_code)]
#![crate_type=
"lib"
]
...
...
src/test/codegen-units/partitioning/extern-generic.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zprint-trans-items=eager
-Zincremental=""
#![allow(dead_code)]
#![crate_type=
"lib"
]
...
...
src/test/codegen-units/partitioning/inlining-from-extern-crate.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// compile-flags:-Zprint-trans-items=lazy
-Zincremental=""
#![crate_type=
"lib"
]
...
...
src/test/codegen-units/partitioning/local-drop-glue.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// compile-flags:-Zprint-trans-items=lazy
-Zincremental=""
#![allow(dead_code)]
#![crate_type=
"lib"
]
...
...
src/test/codegen-units/partitioning/local-generic.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zprint-trans-items=eager
-Zincremental=""
#![allow(dead_code)]
#![crate_type=
"lib"
]
...
...
src/test/codegen-units/partitioning/local-inlining.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// compile-flags:-Zprint-trans-items=lazy
-Zincremental=""
#![allow(dead_code)]
#![crate_type=
"lib"
]
...
...
src/test/codegen-units/partitioning/local-transitive-inlining.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// compile-flags:-Zprint-trans-items=lazy
-Zincremental=""
#![allow(dead_code)]
#![crate_type=
"lib"
]
...
...
src/test/codegen-units/partitioning/methods-are-with-self-type.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// compile-flags:-Zprint-trans-items=lazy
-Zincremental=""
#![allow(dead_code)]
...
...
src/test/codegen-units/partitioning/regular-modules.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zprint-trans-items=eager
-Z incremental=""
#![allow(dead_code)]
#![crate_type=
"lib"
]
...
...
src/test/codegen-units/partitioning/statics.rs
浏览文件 @
7f04d35c
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// compile-flags:-Zprint-trans-items=lazy
-Zincremental=""
#![crate_type=
"lib"
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录