Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
55b5a365
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,发现更多精彩内容 >>
提交
55b5a365
编写于
2月 23, 2016
作者:
E
Eduard Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
trans: Remove unused return type argument from declare_cfn.
上级
5af3c12c
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
34 addition
and
53 deletion
+34
-53
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/base.rs
+3
-2
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/common.rs
+14
-19
src/librustc_trans/trans/context.rs
src/librustc_trans/trans/context.rs
+5
-11
src/librustc_trans/trans/declare.rs
src/librustc_trans/trans/declare.rs
+5
-11
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/expr.rs
+1
-2
src/librustc_trans/trans/glue.rs
src/librustc_trans/trans/glue.rs
+5
-6
src/librustc_trans/trans/intrinsic.rs
src/librustc_trans/trans/intrinsic.rs
+1
-2
未找到文件。
src/librustc_trans/trans/base.rs
浏览文件 @
55b5a365
...
...
@@ -2630,14 +2630,15 @@ fn create_entry_fn(ccx: &CrateContext,
use_start_lang_item
:
bool
)
{
let
llfty
=
Type
::
func
(
&
[
ccx
.int_type
(),
Type
::
i8p
(
ccx
)
.ptr_to
()],
&
ccx
.int_type
());
let
llfn
=
declare
::
define_cfn
(
ccx
,
"main"
,
llfty
,
ccx
.tcx
()
.mk_nil
())
.unwrap_or_else
(||
{
if
declare
::
get_defined_value
(
ccx
,
"main"
)
.is_some
()
{
// FIXME: We should be smart and show a better diagnostic here.
ccx
.sess
()
.struct_span_err
(
sp
,
"entry symbol `main` defined multiple times"
)
.help
(
"did you use #[no_mangle] on `fn main`? Use #[start] instead"
)
.emit
();
ccx
.sess
()
.abort_if_errors
();
panic!
();
});
}
let
llfn
=
declare
::
declare_cfn
(
ccx
,
"main"
,
llfty
);
let
llbb
=
unsafe
{
llvm
::
LLVMAppendBasicBlockInContext
(
ccx
.llcx
(),
llfn
,
"top
\0
"
.as_ptr
()
as
*
const
_
)
...
...
src/librustc_trans/trans/common.rs
浏览文件 @
55b5a365
...
...
@@ -519,28 +519,23 @@ pub fn eh_personality(&self) -> ValueRef {
Some
(
def_id
)
if
!
base
::
wants_msvc_seh
(
ccx
.sess
())
=>
{
Callee
::
def
(
ccx
,
def_id
,
tcx
.mk_substs
(
Substs
::
empty
()))
.reify
(
ccx
)
.val
}
_
=>
{
let
mut
personality
=
self
.ccx
.eh_personality
()
.borrow_mut
();
match
*
personality
{
Some
(
llpersonality
)
=>
llpersonality
,
None
=>
{
let
name
=
if
!
base
::
wants_msvc_seh
(
self
.ccx
.sess
())
{
_
=>
if
let
Some
(
llpersonality
)
=
ccx
.eh_personality
()
.get
()
{
llpersonality
}
else
{
let
name
=
if
!
base
::
wants_msvc_seh
(
ccx
.sess
())
{
"rust_eh_personality"
}
else
if
target
.arch
==
"x86"
{
"_except_handler3"
}
else
{
"__C_specific_handler"
};
let
fty
=
Type
::
variadic_func
(
&
[],
&
Type
::
i32
(
self
.ccx
));
let
f
=
declare
::
declare_cfn
(
self
.ccx
,
name
,
fty
,
self
.ccx
.tcx
()
.types.i32
);
*
personality
=
Some
(
f
);
let
fty
=
Type
::
variadic_func
(
&
[],
&
Type
::
i32
(
ccx
));
let
f
=
declare
::
declare_cfn
(
ccx
,
name
,
fty
);
ccx
.eh_personality
()
.set
(
Some
(
f
));
f
}
}
}
}
}
// Returns a ValueRef of the "eh_unwind_resume" lang item if one is defined,
// otherwise declares it as an external function.
...
...
src/librustc_trans/trans/context.rs
浏览文件 @
55b5a365
...
...
@@ -865,8 +865,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> {
macro_rules!
ifn
{
(
$name:expr
,
fn
()
->
$ret:expr
)
=>
(
if
key
==
$name
{
let
f
=
declare
::
declare_cfn
(
ccx
,
$name
,
Type
::
func
(
&
[],
&
$ret
),
ccx
.tcx
()
.mk_nil
());
let
f
=
declare
::
declare_cfn
(
ccx
,
$name
,
Type
::
func
(
&
[],
&
$ret
));
llvm
::
SetUnnamedAddr
(
f
,
false
);
ccx
.intrinsics
()
.borrow_mut
()
.insert
(
$name
,
f
.clone
());
return
Some
(
f
);
...
...
@@ -874,9 +873,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> {
);
(
$name:expr
,
fn
(
...
)
->
$ret:expr
)
=>
(
if
key
==
$name
{
let
f
=
declare
::
declare_cfn
(
ccx
,
$name
,
Type
::
variadic_func
(
&
[],
&
$ret
),
ccx
.tcx
()
.mk_nil
());
let
f
=
declare
::
declare_cfn
(
ccx
,
$name
,
Type
::
variadic_func
(
&
[],
&
$ret
));
llvm
::
SetUnnamedAddr
(
f
,
false
);
ccx
.intrinsics
()
.borrow_mut
()
.insert
(
$name
,
f
.clone
());
return
Some
(
f
);
...
...
@@ -884,8 +881,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> {
);
(
$name:expr
,
fn
(
$
(
$arg:expr
),
*
)
->
$ret:expr
)
=>
(
if
key
==
$name
{
let
f
=
declare
::
declare_cfn
(
ccx
,
$name
,
Type
::
func
(
&
[
$
(
$arg
),
*
],
&
$ret
),
ccx
.tcx
()
.mk_nil
());
let
f
=
declare
::
declare_cfn
(
ccx
,
$name
,
Type
::
func
(
&
[
$
(
$arg
),
*
],
&
$ret
));
llvm
::
SetUnnamedAddr
(
f
,
false
);
ccx
.intrinsics
()
.borrow_mut
()
.insert
(
$name
,
f
.clone
());
return
Some
(
f
);
...
...
@@ -1032,8 +1028,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> {
ifn!
(
$name
,
fn
(
$
(
$arg
),
*
)
->
void
);
}
else
if
key
==
$name
{
let
f
=
declare
::
declare_cfn
(
ccx
,
stringify!
(
$cname
),
Type
::
func
(
&
[
$
(
$arg
),
*
],
&
void
),
ccx
.tcx
()
.mk_nil
());
Type
::
func
(
&
[
$
(
$arg
),
*
],
&
void
));
llvm
::
SetLinkage
(
f
,
llvm
::
InternalLinkage
);
let
bld
=
ccx
.builder
();
...
...
@@ -1055,8 +1050,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> {
ifn!
(
$name
,
fn
(
$
(
$arg
),
*
)
->
$ret
);
}
else
if
key
==
$name
{
let
f
=
declare
::
declare_cfn
(
ccx
,
stringify!
(
$cname
),
Type
::
func
(
&
[
$
(
$arg
),
*
],
&
$ret
),
ccx
.tcx
()
.mk_nil
());
Type
::
func
(
&
[
$
(
$arg
),
*
],
&
$ret
));
ccx
.intrinsics
()
.borrow_mut
()
.insert
(
$name
,
f
.clone
());
return
Some
(
f
);
}
...
...
src/librustc_trans/trans/declare.rs
浏览文件 @
55b5a365
...
...
@@ -55,9 +55,8 @@ pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRe
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing ValueRef instead.
pub
fn
declare_fn
(
ccx
:
&
CrateContext
,
name
:
&
str
,
callconv
:
llvm
::
CallConv
,
ty
:
Type
,
output
:
ty
::
FnOutput
)
->
ValueRef
{
debug!
(
"declare_fn(name={:?})"
,
name
);
fn
declare_raw_fn
(
ccx
:
&
CrateContext
,
name
:
&
str
,
callconv
:
llvm
::
CallConv
,
ty
:
Type
)
->
ValueRef
{
debug!
(
"declare_raw_fn(name={:?}, ty={:?})"
,
name
,
ty
);
let
namebuf
=
CString
::
new
(
name
)
.unwrap_or_else
(|
_
|{
ccx
.sess
()
.bug
(
&
format!
(
"name {:?} contains an interior null byte"
,
name
))
});
...
...
@@ -70,10 +69,6 @@ pub fn declare_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv,
// be merged.
llvm
::
SetUnnamedAddr
(
llfn
,
true
);
if
output
==
ty
::
FnDiverging
{
llvm
::
SetFunctionAttribute
(
llfn
,
llvm
::
Attribute
::
NoReturn
);
}
if
ccx
.tcx
()
.sess.opts.cg.no_redzone
.unwrap_or
(
ccx
.tcx
()
.sess.target.target.options.disable_redzone
)
{
llvm
::
SetFunctionAttribute
(
llfn
,
llvm
::
Attribute
::
NoRedZone
)
...
...
@@ -90,9 +85,8 @@ pub fn declare_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv,
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing ValueRef instead.
pub
fn
declare_cfn
(
ccx
:
&
CrateContext
,
name
:
&
str
,
fn_type
:
Type
,
output
:
ty
::
Ty
)
->
ValueRef
{
declare_fn
(
ccx
,
name
,
llvm
::
CCallConv
,
fn_type
,
ty
::
FnConverging
(
output
))
pub
fn
declare_cfn
(
ccx
:
&
CrateContext
,
name
:
&
str
,
fn_type
:
Type
)
->
ValueRef
{
declare_raw_fn
(
ccx
,
name
,
llvm
::
CCallConv
,
fn_type
)
}
...
...
@@ -237,7 +231,7 @@ pub fn define_internal_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
/// Get defined or externally defined (AvailableExternally linkage) value by
/// name.
fn
get_defined_value
(
ccx
:
&
CrateContext
,
name
:
&
str
)
->
Option
<
ValueRef
>
{
pub
fn
get_defined_value
(
ccx
:
&
CrateContext
,
name
:
&
str
)
->
Option
<
ValueRef
>
{
debug!
(
"get_defined_value(name={:?})"
,
name
);
let
namebuf
=
CString
::
new
(
name
)
.unwrap_or_else
(|
_
|{
ccx
.sess
()
.bug
(
&
format!
(
"name {:?} contains an interior null byte"
,
name
))
...
...
src/librustc_trans/trans/expr.rs
浏览文件 @
55b5a365
...
...
@@ -1678,8 +1678,7 @@ fn trans_scalar_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
if
use_fmod
{
let
f64t
=
Type
::
f64
(
bcx
.ccx
());
let
fty
=
Type
::
func
(
&
[
f64t
,
f64t
],
&
f64t
);
let
llfn
=
declare
::
declare_cfn
(
bcx
.ccx
(),
"fmod"
,
fty
,
tcx
.types.f64
);
let
llfn
=
declare
::
declare_cfn
(
bcx
.ccx
(),
"fmod"
,
fty
);
if
lhs_t
==
tcx
.types.f32
{
let
lhs
=
FPExt
(
bcx
,
lhs
,
f64t
);
let
rhs
=
FPExt
(
bcx
,
rhs
,
f64t
);
...
...
src/librustc_trans/trans/glue.rs
浏览文件 @
55b5a365
...
...
@@ -14,7 +14,7 @@
use
std
;
use
back
::
link
::
*
;
use
back
::
link
;
use
llvm
;
use
llvm
::{
ValueRef
,
get_param
};
use
middle
::
lang_items
::
ExchangeFreeFnLangItem
;
...
...
@@ -251,15 +251,14 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// To avoid infinite recursion, don't `make_drop_glue` until after we've
// added the entry to the `drop_glues` cache.
if
let
Some
(
old_sym
)
=
ccx
.available_drop_glues
()
.borrow
()
.get
(
&
g
)
{
let
llfn
=
declare
::
declare_cfn
(
ccx
,
&
old_sym
,
llfnty
,
ccx
.tcx
()
.mk_nil
()
);
let
llfn
=
declare
::
declare_cfn
(
ccx
,
&
old_sym
,
llfnty
);
ccx
.drop_glues
()
.borrow_mut
()
.insert
(
g
,
llfn
);
return
llfn
;
};
let
fn_nm
=
mangle_internal_name_by_type_and_seq
(
ccx
,
t
,
"drop"
);
let
llfn
=
declare
::
define_cfn
(
ccx
,
&
fn_nm
,
llfnty
,
ccx
.tcx
()
.mk_nil
())
.unwrap_or_else
(||{
ccx
.sess
()
.bug
(
&
format!
(
"symbol `{}` already defined"
,
fn_nm
));
});
let
fn_nm
=
link
::
mangle_internal_name_by_type_and_seq
(
ccx
,
t
,
"drop"
);
assert
!
(
declare
::
get_defined_value
(
ccx
,
&
fn_nm
)
.is_none
());
let
llfn
=
declare
::
declare_cfn
(
ccx
,
&
fn_nm
,
llfnty
);
ccx
.available_drop_glues
()
.borrow_mut
()
.insert
(
g
,
fn_nm
);
let
_
s
=
StatRecorder
::
new
(
ccx
,
format!
(
"drop {:?}"
,
t
));
...
...
src/librustc_trans/trans/intrinsic.rs
浏览文件 @
55b5a365
...
...
@@ -949,8 +949,7 @@ fn modify_as_needed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
intrinsics
::
IntrinsicDef
::
Named
(
name
)
=>
{
let
f
=
declare
::
declare_cfn
(
ccx
,
name
,
Type
::
func
(
&
inputs
,
&
outputs
),
tcx
.mk_nil
());
Type
::
func
(
&
inputs
,
&
outputs
));
Call
(
bcx
,
f
,
&
llargs
,
None
,
call_debug_location
)
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录