Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
265f2fa4
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,发现更多精彩内容 >>
提交
265f2fa4
编写于
7月 17, 2018
作者:
I
Irina Popa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc_codegen_llvm: fix tidy errors.
上级
ba006440
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
77 addition
and
24 deletion
+77
-24
src/librustc_codegen_llvm/back/write.rs
src/librustc_codegen_llvm/back/write.rs
+4
-1
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/base.rs
+10
-2
src/librustc_codegen_llvm/builder.rs
src/librustc_codegen_llvm/builder.rs
+20
-10
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/common.rs
+10
-2
src/librustc_codegen_llvm/context.rs
src/librustc_codegen_llvm/context.rs
+5
-1
src/librustc_codegen_llvm/debuginfo/create_scope_map.rs
src/librustc_codegen_llvm/debuginfo/create_scope_map.rs
+5
-2
src/librustc_codegen_llvm/declare.rs
src/librustc_codegen_llvm/declare.rs
+6
-1
src/librustc_codegen_llvm/llvm/archive_ro.rs
src/librustc_codegen_llvm/llvm/archive_ro.rs
+3
-2
src/librustc_codegen_llvm/llvm/ffi.rs
src/librustc_codegen_llvm/llvm/ffi.rs
+8
-2
src/librustc_codegen_llvm/mir/operand.rs
src/librustc_codegen_llvm/mir/operand.rs
+6
-1
未找到文件。
src/librustc_codegen_llvm/back/write.rs
浏览文件 @
265f2fa4
...
...
@@ -128,7 +128,10 @@ fn get_llvm_opt_size(optimize: config::OptLevel) -> llvm::CodeGenOptSize {
}
}
pub
fn
create_target_machine
(
sess
:
&
Session
,
find_features
:
bool
)
->
&
'static
mut
llvm
::
TargetMachine
{
pub
fn
create_target_machine
(
sess
:
&
Session
,
find_features
:
bool
,
)
->
&
'static
mut
llvm
::
TargetMachine
{
target_machine_factory
(
sess
,
find_features
)()
.unwrap_or_else
(|
err
|
{
llvm_err
(
sess
.diagnostic
(),
err
)
.raise
()
})
...
...
src/librustc_codegen_llvm/base.rs
浏览文件 @
265f2fa4
...
...
@@ -395,14 +395,22 @@ pub fn from_immediate(bx: &Builder<'_, 'll, '_>, val: &'ll Value) -> &'ll Value
}
}
pub
fn
to_immediate
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
val
:
&
'll
Value
,
layout
:
layout
::
TyLayout
)
->
&
'll
Value
{
pub
fn
to_immediate
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
val
:
&
'll
Value
,
layout
:
layout
::
TyLayout
,
)
->
&
'll
Value
{
if
let
layout
::
Abi
::
Scalar
(
ref
scalar
)
=
layout
.abi
{
return
to_immediate_scalar
(
bx
,
val
,
scalar
);
}
val
}
pub
fn
to_immediate_scalar
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
val
:
&
'll
Value
,
scalar
:
&
layout
::
Scalar
)
->
&
'll
Value
{
pub
fn
to_immediate_scalar
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
val
:
&
'll
Value
,
scalar
:
&
layout
::
Scalar
,
)
->
&
'll
Value
{
if
scalar
.is_bool
()
{
return
bx
.trunc
(
val
,
Type
::
i1
(
bx
.cx
));
}
...
...
src/librustc_codegen_llvm/builder.rs
浏览文件 @
265f2fa4
...
...
@@ -157,14 +157,24 @@ pub fn br(&self, dest: &'ll BasicBlock) {
}
}
pub
fn
cond_br
(
&
self
,
cond
:
&
'll
Value
,
then_llbb
:
&
'll
BasicBlock
,
else_llbb
:
&
'll
BasicBlock
)
{
pub
fn
cond_br
(
&
self
,
cond
:
&
'll
Value
,
then_llbb
:
&
'll
BasicBlock
,
else_llbb
:
&
'll
BasicBlock
,
)
{
self
.count_insn
(
"condbr"
);
unsafe
{
llvm
::
LLVMBuildCondBr
(
self
.llbuilder
,
cond
,
then_llbb
,
else_llbb
);
}
}
pub
fn
switch
(
&
self
,
v
:
&
'll
Value
,
else_llbb
:
&
'll
BasicBlock
,
num_cases
:
usize
)
->
&
'll
Value
{
pub
fn
switch
(
&
self
,
v
:
&
'll
Value
,
else_llbb
:
&
'll
BasicBlock
,
num_cases
:
usize
,
)
->
&
'll
Value
{
unsafe
{
llvm
::
LLVMBuildSwitch
(
self
.llbuilder
,
v
,
else_llbb
,
num_cases
as
c_uint
)
}
...
...
@@ -814,8 +824,8 @@ pub fn vector_reduce_fadd_fast(&self, acc: &'ll Value, src: &'ll Value) -> &'ll
// FIXME: add a non-fast math version once
// https://bugs.llvm.org/show_bug.cgi?id=36732
// is fixed.
let
instr
=
llvm
::
LLVMRustBuildVectorReduceFAdd
(
self
.llbuilder
,
acc
,
src
)
;
let
instr
=
instr
.expect
(
"LLVMRustBuildVectorReduceFAdd is not available in LLVM version < 5.0"
);
let
instr
=
llvm
::
LLVMRustBuildVectorReduceFAdd
(
self
.llbuilder
,
acc
,
src
)
.expect
(
"LLVMRustBuildVectorReduceFAdd is not available in LLVM version < 5.0"
);
llvm
::
LLVMRustSetHasUnsafeAlgebra
(
instr
);
instr
}
...
...
@@ -826,8 +836,8 @@ pub fn vector_reduce_fmul_fast(&self, acc: &'ll Value, src: &'ll Value) -> &'ll
// FIXME: add a non-fast math version once
// https://bugs.llvm.org/show_bug.cgi?id=36732
// is fixed.
let
instr
=
llvm
::
LLVMRustBuildVectorReduceFMul
(
self
.llbuilder
,
acc
,
src
)
;
let
instr
=
instr
.expect
(
"LLVMRustBuildVectorReduceFMul is not available in LLVM version < 5.0"
);
let
instr
=
llvm
::
LLVMRustBuildVectorReduceFMul
(
self
.llbuilder
,
acc
,
src
)
.expect
(
"LLVMRustBuildVectorReduceFMul is not available in LLVM version < 5.0"
);
llvm
::
LLVMRustSetHasUnsafeAlgebra
(
instr
);
instr
}
...
...
@@ -884,8 +894,8 @@ pub fn vector_reduce_fmax(&self, src: &'ll Value) -> &'ll Value {
pub
fn
vector_reduce_fmin_fast
(
&
self
,
src
:
&
'll
Value
)
->
&
'll
Value
{
self
.count_insn
(
"vector.reduce.fmin_fast"
);
unsafe
{
let
instr
=
llvm
::
LLVMRustBuildVectorReduceFMin
(
self
.llbuilder
,
src
,
/*NoNaNs:*/
true
)
;
let
instr
=
instr
.expect
(
"LLVMRustBuildVectorReduceFMin is not available in LLVM version < 5.0"
);
let
instr
=
llvm
::
LLVMRustBuildVectorReduceFMin
(
self
.llbuilder
,
src
,
/*NoNaNs:*/
true
)
.expect
(
"LLVMRustBuildVectorReduceFMin is not available in LLVM version < 5.0"
);
llvm
::
LLVMRustSetHasUnsafeAlgebra
(
instr
);
instr
}
...
...
@@ -893,8 +903,8 @@ pub fn vector_reduce_fmin_fast(&self, src: &'ll Value) -> &'ll Value {
pub
fn
vector_reduce_fmax_fast
(
&
self
,
src
:
&
'll
Value
)
->
&
'll
Value
{
self
.count_insn
(
"vector.reduce.fmax_fast"
);
unsafe
{
let
instr
=
llvm
::
LLVMRustBuildVectorReduceFMax
(
self
.llbuilder
,
src
,
/*NoNaNs:*/
true
)
;
let
instr
=
instr
.expect
(
"LLVMRustBuildVectorReduceFMax is not available in LLVM version < 5.0"
);
let
instr
=
llvm
::
LLVMRustBuildVectorReduceFMax
(
self
.llbuilder
,
src
,
/*NoNaNs:*/
true
)
.expect
(
"LLVMRustBuildVectorReduceFMax is not available in LLVM version < 5.0"
);
llvm
::
LLVMRustSetHasUnsafeAlgebra
(
instr
);
instr
}
...
...
src/librustc_codegen_llvm/common.rs
浏览文件 @
265f2fa4
...
...
@@ -183,7 +183,11 @@ pub fn C_u8(cx: &CodegenCx<'ll, '_>, i: u8) -> &'ll Value {
// This is a 'c-like' raw string, which differs from
// our boxed-and-length-annotated strings.
pub
fn
C_cstr
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
s
:
LocalInternedString
,
null_terminated
:
bool
)
->
&
'll
Value
{
pub
fn
C_cstr
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
s
:
LocalInternedString
,
null_terminated
:
bool
,
)
->
&
'll
Value
{
unsafe
{
if
let
Some
(
&
llval
)
=
cx
.const_cstr_cache
.borrow
()
.get
(
&
s
)
{
return
llval
;
...
...
@@ -225,7 +229,11 @@ pub fn C_struct(cx: &CodegenCx<'ll, '_>, elts: &[&'ll Value], packed: bool) -> &
C_struct_in_context
(
cx
.llcx
,
elts
,
packed
)
}
pub
fn
C_struct_in_context
(
llcx
:
&
'll
llvm
::
Context
,
elts
:
&
[
&
'll
Value
],
packed
:
bool
)
->
&
'll
Value
{
pub
fn
C_struct_in_context
(
llcx
:
&
'll
llvm
::
Context
,
elts
:
&
[
&
'll
Value
],
packed
:
bool
,
)
->
&
'll
Value
{
unsafe
{
llvm
::
LLVMConstStructInContext
(
llcx
,
elts
.as_ptr
(),
elts
.len
()
as
c_uint
,
...
...
src/librustc_codegen_llvm/context.rs
浏览文件 @
265f2fa4
...
...
@@ -155,7 +155,11 @@ pub fn is_pie_binary(sess: &Session) -> bool {
!
is_any_library
(
sess
)
&&
get_reloc_model
(
sess
)
==
llvm
::
RelocMode
::
PIC
}
pub
unsafe
fn
create_module
(
sess
:
&
Session
,
llcx
:
&
'll
llvm
::
Context
,
mod_name
:
&
str
)
->
&
'll
llvm
::
Module
{
pub
unsafe
fn
create_module
(
sess
:
&
Session
,
llcx
:
&
'll
llvm
::
Context
,
mod_name
:
&
str
,
)
->
&
'll
llvm
::
Module
{
let
mod_name
=
CString
::
new
(
mod_name
)
.unwrap
();
let
llmod
=
llvm
::
LLVMModuleCreateWithNameInContext
(
mod_name
.as_ptr
(),
llcx
);
...
...
src/librustc_codegen_llvm/debuginfo/create_scope_map.rs
浏览文件 @
265f2fa4
...
...
@@ -43,8 +43,11 @@ pub fn is_valid(&self) -> bool {
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
/// If debuginfo is disabled, the returned vector is empty.
pub
fn
create_mir_scopes
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
mir
:
&
Mir
,
debug_context
:
&
FunctionDebugContext
<
'll
>
)
->
IndexVec
<
SourceScope
,
MirDebugScope
<
'll
>>
{
pub
fn
create_mir_scopes
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
mir
:
&
Mir
,
debug_context
:
&
FunctionDebugContext
<
'll
>
,
)
->
IndexVec
<
SourceScope
,
MirDebugScope
<
'll
>>
{
let
null_scope
=
MirDebugScope
{
scope_metadata
:
None
,
file_start_pos
:
BytePos
(
0
),
...
...
src/librustc_codegen_llvm/declare.rs
浏览文件 @
265f2fa4
...
...
@@ -55,7 +55,12 @@ pub fn declare_global(cx: &CodegenCx<'ll, '_>, name: &str, ty: &'ll Type) -> &'l
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing Value instead.
fn
declare_raw_fn
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
name
:
&
str
,
callconv
:
llvm
::
CallConv
,
ty
:
&
'll
Type
)
->
&
'll
Value
{
fn
declare_raw_fn
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
name
:
&
str
,
callconv
:
llvm
::
CallConv
,
ty
:
&
'll
Type
,
)
->
&
'll
Value
{
debug!
(
"declare_raw_fn(name={:?}, ty={:?})"
,
name
,
ty
);
let
namebuf
=
CString
::
new
(
name
)
.unwrap_or_else
(|
_
|{
bug!
(
"name {:?} contains an interior null byte"
,
name
)
...
...
src/librustc_codegen_llvm/llvm/archive_ro.rs
浏览文件 @
265f2fa4
...
...
@@ -39,8 +39,9 @@ impl ArchiveRO {
pub
fn
open
(
dst
:
&
Path
)
->
Result
<
ArchiveRO
,
String
>
{
return
unsafe
{
let
s
=
path2cstr
(
dst
);
let
ar
=
super
::
LLVMRustOpenArchive
(
s
.as_ptr
())
.ok_or_else
(||
super
::
last_error
()
.unwrap_or
(
"failed to open archive"
.to_string
()))
?
;
let
ar
=
super
::
LLVMRustOpenArchive
(
s
.as_ptr
())
.ok_or_else
(||
{
super
::
last_error
()
.unwrap_or
(
"failed to open archive"
.to_string
())
})
?
;
Ok
(
ArchiveRO
{
raw
:
ar
})
};
...
...
src/librustc_codegen_llvm/llvm/ffi.rs
浏览文件 @
265f2fa4
...
...
@@ -740,7 +740,11 @@ pub fn LLVMRustBuildCatchPad(B: &'a Builder,
Args
:
*
const
&
'a
Value
,
Name
:
*
const
c_char
)
->
Option
<&
'a
Value
>
;
pub
fn
LLVMRustBuildCatchRet
(
B
:
&
'a
Builder
,
Pad
:
&
'a
Value
,
BB
:
&
'a
BasicBlock
)
->
Option
<&
'a
Value
>
;
pub
fn
LLVMRustBuildCatchRet
(
B
:
&
'a
Builder
,
Pad
:
&
'a
Value
,
BB
:
&
'a
BasicBlock
,
)
->
Option
<&
'a
Value
>
;
pub
fn
LLVMRustBuildCatchSwitch
(
Builder
:
&
'a
Builder
,
ParentPad
:
Option
<&
'a
Value
>
,
BB
:
Option
<&
'a
BasicBlock
>
,
...
...
@@ -1480,7 +1484,9 @@ pub fn LLVMRustPrintModule(PM: &PassManager<'a>,
pub
fn
LLVMRustOpenArchive
(
path
:
*
const
c_char
)
->
Option
<&
'static
mut
Archive
>
;
pub
fn
LLVMRustArchiveIteratorNew
(
AR
:
&
'a
Archive
)
->
&
'a
mut
ArchiveIterator
<
'a
>
;
pub
fn
LLVMRustArchiveIteratorNext
(
AIR
:
&
ArchiveIterator
<
'a
>
)
->
Option
<&
'a
mut
ArchiveChild
<
'a
>>
;
pub
fn
LLVMRustArchiveIteratorNext
(
AIR
:
&
ArchiveIterator
<
'a
>
,
)
->
Option
<&
'a
mut
ArchiveChild
<
'a
>>
;
pub
fn
LLVMRustArchiveChildName
(
ACR
:
&
ArchiveChild
,
size
:
&
mut
size_t
)
->
*
const
c_char
;
pub
fn
LLVMRustArchiveChildData
(
ACR
:
&
ArchiveChild
,
size
:
&
mut
size_t
)
->
*
const
c_char
;
pub
fn
LLVMRustArchiveChildFree
(
ACR
:
&
'a
mut
ArchiveChild
<
'a
>
);
...
...
src/librustc_codegen_llvm/mir/operand.rs
浏览文件 @
265f2fa4
...
...
@@ -266,7 +266,12 @@ pub fn nontemporal_store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'ll,
self
.store_with_flags
(
bx
,
dest
,
MemFlags
::
NONTEMPORAL
);
}
fn
store_with_flags
(
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
dest
:
PlaceRef
<
'll
,
'tcx
>
,
flags
:
MemFlags
)
{
fn
store_with_flags
(
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
dest
:
PlaceRef
<
'll
,
'tcx
>
,
flags
:
MemFlags
,
)
{
debug!
(
"OperandRef::store: operand={:?}, dest={:?}"
,
self
,
dest
);
// Avoid generating stores of zero-sized values, because the only way to have a zero-sized
// value is through `undef`, and store itself is useless.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录