Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
727a5d54
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,发现更多精彩内容 >>
提交
727a5d54
编写于
8月 25, 2015
作者:
B
Björn Steinbrink
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prefer alloc_ty() instead of alloca() where possible
上级
95337a29
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
9 addition
and
20 deletion
+9
-20
src/librustc_trans/trans/_match.rs
src/librustc_trans/trans/_match.rs
+1
-2
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/base.rs
+1
-2
src/librustc_trans/trans/datum.rs
src/librustc_trans/trans/datum.rs
+2
-5
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/expr.rs
+2
-4
src/librustc_trans/trans/foreign.rs
src/librustc_trans/trans/foreign.rs
+1
-4
src/librustc_trans/trans/glue.rs
src/librustc_trans/trans/glue.rs
+1
-1
src/librustc_trans/trans/tvec.rs
src/librustc_trans/trans/tvec.rs
+1
-2
未找到文件。
src/librustc_trans/trans/_match.rs
浏览文件 @
727a5d54
...
...
@@ -1196,8 +1196,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let
unsized_ty
=
def
.struct_variant
()
.fields
.last
()
.map
(|
field
|
{
monomorphize
::
field_ty
(
bcx
.tcx
(),
substs
,
field
)
})
.unwrap
();
let
llty
=
type_of
::
type_of
(
bcx
.ccx
(),
unsized_ty
);
let
scratch
=
alloca
(
bcx
,
llty
,
"__struct_field_fat_ptr"
);
let
scratch
=
alloc_ty
(
bcx
,
unsized_ty
,
"__struct_field_fat_ptr"
);
let
data
=
adt
::
trans_field_ptr
(
bcx
,
&*
repr
,
struct_val
,
0
,
arg_count
);
let
len
=
Load
(
bcx
,
expr
::
get_meta
(
bcx
,
val
.val
));
Store
(
bcx
,
data
,
expr
::
get_dataptr
(
bcx
,
scratch
));
...
...
src/librustc_trans/trans/base.rs
浏览文件 @
727a5d54
...
...
@@ -1020,8 +1020,7 @@ pub fn alloc_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, name: &str) ->
let
ccx
=
bcx
.ccx
();
let
ty
=
type_of
::
type_of
(
ccx
,
t
);
assert
!
(
!
t
.has_param_types
());
let
val
=
alloca
(
bcx
,
ty
,
name
);
return
val
;
alloca
(
bcx
,
ty
,
name
)
}
pub
fn
alloca
(
cx
:
Block
,
ty
:
Type
,
name
:
&
str
)
->
ValueRef
{
...
...
src/librustc_trans/trans/datum.rs
浏览文件 @
727a5d54
...
...
@@ -101,7 +101,6 @@
use
trans
::
cleanup
::{
CleanupMethods
,
DropHintDatum
,
DropHintMethods
};
use
trans
::
expr
;
use
trans
::
tvec
;
use
trans
::
type_of
;
use
middle
::
ty
::
Ty
;
use
std
::
fmt
;
...
...
@@ -302,8 +301,7 @@ pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
->
DatumBlock
<
'blk
,
'tcx
,
Lvalue
>
where
F
:
FnOnce
(
A
,
Block
<
'blk
,
'tcx
>
,
ValueRef
)
->
Block
<
'blk
,
'tcx
>
,
{
let
llty
=
type_of
::
type_of
(
bcx
.ccx
(),
ty
);
let
scratch
=
alloca
(
bcx
,
llty
,
name
);
let
scratch
=
alloc_ty
(
bcx
,
ty
,
name
);
// Subtle. Populate the scratch memory *before* scheduling cleanup.
call_lifetime_start
(
bcx
,
scratch
);
...
...
@@ -323,8 +321,7 @@ pub fn rvalue_scratch_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ty
:
Ty
<
'tcx
>
,
name
:
&
str
)
->
Datum
<
'tcx
,
Rvalue
>
{
let
llty
=
type_of
::
type_of
(
bcx
.ccx
(),
ty
);
let
scratch
=
alloca
(
bcx
,
llty
,
name
);
let
scratch
=
alloc_ty
(
bcx
,
ty
,
name
);
call_lifetime_start
(
bcx
,
scratch
);
Datum
::
new
(
scratch
,
ty
,
Rvalue
::
new
(
ByRef
))
}
...
...
src/librustc_trans/trans/expr.rs
浏览文件 @
727a5d54
...
...
@@ -246,8 +246,7 @@ pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// Maybe just get the value directly, instead of loading it?
immediate_rvalue
(
load_ty
(
bcx
,
global
,
const_ty
),
const_ty
)
}
else
{
let
llty
=
type_of
::
type_of
(
bcx
.ccx
(),
const_ty
);
let
scratch
=
alloca
(
bcx
,
llty
,
"const"
);
let
scratch
=
alloc_ty
(
bcx
,
const_ty
,
"const"
);
call_lifetime_start
(
bcx
,
scratch
);
let
lldest
=
if
!
const_ty
.is_structural
()
{
// Cast pointer to slot, because constants have different types.
...
...
@@ -410,9 +409,8 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
datum
.to_rvalue_datum
(
bcx
,
"__coerce_source"
));
let
target
=
bcx
.monomorphize
(
&
target
);
let
llty
=
type_of
::
type_of
(
bcx
.ccx
(),
target
);
let
scratch
=
alloc
a
(
bcx
,
llty
,
"__coerce_target"
);
let
scratch
=
alloc
_ty
(
bcx
,
target
,
"__coerce_target"
);
call_lifetime_start
(
bcx
,
scratch
);
let
target_datum
=
Datum
::
new
(
scratch
,
target
,
Rvalue
::
new
(
ByRef
));
...
...
src/librustc_trans/trans/foreign.rs
浏览文件 @
727a5d54
...
...
@@ -296,10 +296,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// Ensure that we always have the Rust value indirectly,
// because it makes bitcasting easier.
if
!
rust_indirect
{
let
scratch
=
base
::
alloca
(
bcx
,
type_of
::
type_of
(
ccx
,
passed_arg_tys
[
i
]),
"__arg"
);
let
scratch
=
base
::
alloc_ty
(
bcx
,
passed_arg_tys
[
i
],
"__arg"
);
if
type_is_fat_ptr
(
ccx
.tcx
(),
passed_arg_tys
[
i
])
{
Store
(
bcx
,
llargs_rust
[
i
+
offset
],
expr
::
get_dataptr
(
bcx
,
scratch
));
Store
(
bcx
,
llargs_rust
[
i
+
offset
+
1
],
expr
::
get_meta
(
bcx
,
scratch
));
...
...
src/librustc_trans/trans/glue.rs
浏览文件 @
727a5d54
...
...
@@ -187,7 +187,7 @@ pub fn drop_ty_immediate<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
skip_dtor
:
bool
)
->
Block
<
'blk
,
'tcx
>
{
let
_
icx
=
push_ctxt
(
"drop_ty_immediate"
);
let
vp
=
alloc
a
(
bcx
,
type_of
(
bcx
.ccx
(),
t
)
,
""
);
let
vp
=
alloc
_ty
(
bcx
,
t
,
""
);
call_lifetime_start
(
bcx
,
vp
);
store_ty
(
bcx
,
v
,
vp
,
t
);
let
bcx
=
drop_ty_core
(
bcx
,
vp
,
t
,
debug_loc
,
skip_dtor
,
None
);
...
...
src/librustc_trans/trans/tvec.rs
浏览文件 @
727a5d54
...
...
@@ -106,11 +106,10 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
debug!
(
" vt={}, count={}"
,
vt
.to_string
(
ccx
),
count
);
let
fixed_ty
=
bcx
.tcx
()
.mk_array
(
vt
.unit_ty
,
count
);
let
llfixed_ty
=
type_of
::
type_of
(
bcx
.ccx
(),
fixed_ty
);
// Always create an alloca even if zero-sized, to preserve
// the non-null invariant of the inner slice ptr
let
llfixed
=
base
::
alloc
a
(
bcx
,
ll
fixed_ty
,
""
);
let
llfixed
=
base
::
alloc
_ty
(
bcx
,
fixed_ty
,
""
);
call_lifetime_start
(
bcx
,
llfixed
);
if
count
>
0
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录