Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
238ed47d
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,发现更多精彩内容 >>
提交
238ed47d
编写于
12月 21, 2017
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Generate code for const- and inline-fns if -Clink-dead-code is specified.
上级
de38f495
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
3 deletion
+38
-3
src/librustc_mir/monomorphize/item.rs
src/librustc_mir/monomorphize/item.rs
+1
-1
src/librustc_mir/monomorphize/partitioning.rs
src/librustc_mir/monomorphize/partitioning.rs
+3
-1
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+7
-1
src/test/codegen/link-dead-code.rs
src/test/codegen/link-dead-code.rs
+27
-0
未找到文件。
src/librustc_mir/monomorphize/item.rs
浏览文件 @
238ed47d
...
...
@@ -115,7 +115,7 @@ fn instantiation_mode(&self,
let
inline_in_all_cgus
=
tcx
.sess.opts.debugging_opts.inline_in_all_cgus
.unwrap_or_else
(||
{
tcx
.sess.opts.optimize
!=
OptLevel
::
No
});
})
&&
!
tcx
.sess.opts.cg.link_dead_code
;
match
*
self
.as_mono_item
()
{
MonoItem
::
Fn
(
ref
instance
)
=>
{
...
...
src/librustc_mir/monomorphize/partitioning.rs
浏览文件 @
238ed47d
...
...
@@ -236,7 +236,9 @@ pub fn partition<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Next we try to make as many symbols "internal" as possible, so LLVM has
// more freedom to optimize.
internalize_symbols
(
tcx
,
&
mut
post_inlining
,
inlining_map
);
if
!
tcx
.sess.opts.cg.link_dead_code
{
internalize_symbols
(
tcx
,
&
mut
post_inlining
,
inlining_map
);
}
// Finally, sort by codegen unit name, so that we get deterministic results
let
PostInliningPartitioning
{
...
...
src/librustc_trans/base.rs
浏览文件 @
238ed47d
...
...
@@ -1014,7 +1014,13 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
MonoItemCollectionMode
::
Lazy
}
}
None
=>
MonoItemCollectionMode
::
Lazy
None
=>
{
if
tcx
.sess.opts.cg.link_dead_code
{
MonoItemCollectionMode
::
Eager
}
else
{
MonoItemCollectionMode
::
Lazy
}
}
};
let
(
items
,
inlining_map
)
=
...
...
src/test/codegen/link-dead-code.rs
0 → 100644
浏览文件 @
238ed47d
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags:-Clink-dead-code
#![feature(const_fn)]
#![crate_type
=
"rlib"
]
// This test makes sure that, when -Clink-dead-code is specified, we generate
// code for functions that would otherwise be skipped.
// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code8const_fn
const
fn
const_fn
()
->
i32
{
1
}
// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code9inline_fn
#[inline]
fn
inline_fn
()
->
i32
{
2
}
// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code10private_fn
fn
private_fn
()
->
i32
{
3
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录