Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
bd1d1866
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,发现更多精彩内容 >>
提交
bd1d1866
编写于
4月 27, 2022
作者:
L
lcnr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
store `codegen_fn_attrs` in crate metadata
上级
e013f9e0
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
31 addition
and
34 deletion
+31
-34
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
+1
-0
compiler/rustc_metadata/src/rmeta/encoder.rs
compiler/rustc_metadata/src/rmeta/encoder.rs
+1
-0
compiler/rustc_metadata/src/rmeta/mod.rs
compiler/rustc_metadata/src/rmeta/mod.rs
+2
-0
compiler/rustc_middle/src/query/mod.rs
compiler/rustc_middle/src/query/mod.rs
+1
-0
compiler/rustc_typeck/src/collect.rs
compiler/rustc_typeck/src/collect.rs
+26
-34
未找到文件。
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
浏览文件 @
bd1d1866
...
...
@@ -129,6 +129,7 @@ fn into_args(self) -> (DefId, SimplifiedType) {
type_of
=>
{
table
}
variances_of
=>
{
table
}
fn_sig
=>
{
table
}
codegen_fn_attrs
=>
{
table
}
impl_trait_ref
=>
{
table
}
const_param_default
=>
{
table
}
thir_abstract_const
=>
{
table
}
...
...
compiler/rustc_metadata/src/rmeta/encoder.rs
浏览文件 @
bd1d1866
...
...
@@ -1007,6 +1007,7 @@ fn encode_def_ids(&mut self) {
record!
(
self
.tables.def_span
[
def_id
]
<-
tcx
.def_span
(
def_id
));
self
.encode_attrs
(
def_id
);
record!
(
self
.tables.expn_that_defined
[
def_id
]
<-
self
.tcx
.expn_that_defined
(
def_id
));
record!
(
self
.tables.codegen_fn_attrs
[
def_id
]
<-
self
.tcx
.codegen_fn_attrs
(
def_id
));
if
should_encode_visibility
(
def_kind
)
{
record!
(
self
.tables.visibility
[
def_id
]
<-
self
.tcx
.visibility
(
def_id
));
}
...
...
compiler/rustc_metadata/src/rmeta/mod.rs
浏览文件 @
bd1d1866
...
...
@@ -14,6 +14,7 @@
use
rustc_hir
::
lang_items
;
use
rustc_index
::{
bit_set
::
FiniteBitSet
,
vec
::
IndexVec
};
use
rustc_middle
::
metadata
::
ModChild
;
use
rustc_middle
::
middle
::
codegen_fn_attrs
::
CodegenFnAttrs
;
use
rustc_middle
::
middle
::
exported_symbols
::{
ExportedSymbol
,
SymbolExportInfo
};
use
rustc_middle
::
mir
;
use
rustc_middle
::
thir
;
...
...
@@ -329,6 +330,7 @@ fn encode(&self, buf: &mut Encoder) -> LazyTables<'tcx> {
type_of
:
Table
<
DefIndex
,
Lazy!
(
Ty
<
'tcx
>
)
>
,
variances_of
:
Table
<
DefIndex
,
Lazy
<
[
ty
::
Variance
]
>>
,
fn_sig
:
Table
<
DefIndex
,
Lazy!
(
ty
::
PolyFnSig
<
'tcx
>
)
>
,
codegen_fn_attrs
:
Table
<
DefIndex
,
Lazy!
(
CodegenFnAttrs
)
>
,
impl_trait_ref
:
Table
<
DefIndex
,
Lazy!
(
ty
::
TraitRef
<
'tcx
>
)
>
,
const_param_default
:
Table
<
DefIndex
,
Lazy
<
rustc_middle
::
ty
::
Const
<
'tcx
>>>
,
optimized_mir
:
Table
<
DefIndex
,
Lazy!
(
mir
::
Body
<
'tcx
>
)
>
,
...
...
compiler/rustc_middle/src/query/mod.rs
浏览文件 @
bd1d1866
...
...
@@ -1081,6 +1081,7 @@
desc
{
|
tcx
|
"computing codegen attributes of `{}`"
,
tcx
.def_path_str
(
def_id
)
}
storage
(
ArenaCacheSelector
<
'tcx
>
)
cache_on_disk_if
{
true
}
separate_provide_extern
}
query
asm_target_features
(
def_id
:
DefId
)
->
&
'tcx
FxHashSet
<
Symbol
>
{
...
...
compiler/rustc_typeck/src/collect.rs
浏览文件 @
bd1d1866
...
...
@@ -2610,7 +2610,6 @@ fn generator_kind(tcx: TyCtxt<'_>, def_id: DefId) -> Option<hir::GeneratorKind>
fn
from_target_feature
(
tcx
:
TyCtxt
<
'_
>
,
id
:
DefId
,
attr
:
&
ast
::
Attribute
,
supported_target_features
:
&
FxHashMap
<
String
,
Option
<
Symbol
>>
,
target_features
:
&
mut
Vec
<
Symbol
>
,
...
...
@@ -2679,7 +2678,7 @@ fn from_target_feature(
Some
(
name
)
=>
bug!
(
"unknown target feature gate {}"
,
name
),
None
=>
true
,
};
if
!
allowed
&&
id
.is_local
()
{
if
!
allowed
{
feature_err
(
&
tcx
.sess.parse_sess
,
feature_gate
.unwrap
(),
...
...
@@ -2693,7 +2692,7 @@ fn from_target_feature(
}
}
fn
linkage_by_name
(
tcx
:
TyCtxt
<
'_
>
,
def_id
:
DefId
,
name
:
&
str
)
->
Linkage
{
fn
linkage_by_name
(
tcx
:
TyCtxt
<
'_
>
,
def_id
:
Local
DefId
,
name
:
&
str
)
->
Linkage
{
use
rustc_middle
::
mir
::
mono
::
Linkage
::
*
;
// Use the names from src/llvm/docs/LangRef.rst here. Most types are only
...
...
@@ -2716,28 +2715,20 @@ fn linkage_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: &str) -> Linkage {
"private"
=>
Private
,
"weak"
=>
WeakAny
,
"weak_odr"
=>
WeakODR
,
_
=>
{
let
span
=
tcx
.hir
()
.span_if_local
(
def_id
);
if
let
Some
(
span
)
=
span
{
tcx
.sess
.span_fatal
(
span
,
"invalid linkage specified"
)
}
else
{
tcx
.sess
.fatal
(
&
format!
(
"invalid linkage specified: {}"
,
name
))
}
}
_
=>
tcx
.sess
.span_fatal
(
tcx
.def_span
(
def_id
),
"invalid linkage specified"
),
}
}
fn
codegen_fn_attrs
(
tcx
:
TyCtxt
<
'_
>
,
id
:
DefId
)
->
CodegenFnAttrs
{
let
attrs
=
tcx
.get_attrs
(
id
);
fn
codegen_fn_attrs
(
tcx
:
TyCtxt
<
'_
>
,
did
:
DefId
)
->
CodegenFnAttrs
{
let
did
=
did
.expect_local
();
let
attrs
=
tcx
.hir
()
.attrs
(
tcx
.hir
()
.local_def_id_to_hir_id
(
did
));
let
mut
codegen_fn_attrs
=
CodegenFnAttrs
::
new
();
if
tcx
.should_inherit_track_caller
(
id
)
{
if
tcx
.should_inherit_track_caller
(
d
id
)
{
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
TRACK_CALLER
;
}
// With -Z panic-in-drop=abort, drop_in_place never unwinds.
if
tcx
.sess.opts.debugging_opts.panic_in_drop
==
PanicStrategy
::
Abort
{
if
Some
(
id
)
==
tcx
.lang_items
()
.drop_in_place_fn
()
{
if
Some
(
did
.to_def_id
()
)
==
tcx
.lang_items
()
.drop_in_place_fn
()
{
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
NEVER_UNWIND
;
}
}
...
...
@@ -2745,7 +2736,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
// The panic_no_unwind function called by TerminatorKind::Abort will never
// unwind. If the panic handler that it invokes unwind then it will simply
// call the panic handler again.
if
Some
(
id
)
==
tcx
.lang_items
()
.panic_no_unwind
()
{
if
Some
(
did
.to_def_id
()
)
==
tcx
.lang_items
()
.panic_no_unwind
()
{
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
NEVER_UNWIND
;
}
...
...
@@ -2760,7 +2751,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
}
else
if
attr
.has_name
(
sym
::
rustc_allocator
)
{
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
ALLOCATOR
;
}
else
if
attr
.has_name
(
sym
::
ffi_returns_twice
)
{
if
tcx
.is_foreign_item
(
id
)
{
if
tcx
.is_foreign_item
(
d
id
)
{
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
FFI_RETURNS_TWICE
;
}
else
{
// `#[ffi_returns_twice]` is only allowed `extern fn`s.
...
...
@@ -2773,7 +2764,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
.emit
();
}
}
else
if
attr
.has_name
(
sym
::
ffi_pure
)
{
if
tcx
.is_foreign_item
(
id
)
{
if
tcx
.is_foreign_item
(
d
id
)
{
if
attrs
.iter
()
.any
(|
a
|
a
.has_name
(
sym
::
ffi_const
))
{
// `#[ffi_const]` functions cannot be `#[ffi_pure]`
struct_span_err!
(
...
...
@@ -2797,7 +2788,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
.emit
();
}
}
else
if
attr
.has_name
(
sym
::
ffi_const
)
{
if
tcx
.is_foreign_item
(
id
)
{
if
tcx
.is_foreign_item
(
d
id
)
{
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
FFI_CONST
;
}
else
{
// `#[ffi_const]` is only allowed on foreign functions
...
...
@@ -2857,7 +2848,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
None
=>
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
USED
,
}
}
else
if
attr
.has_name
(
sym
::
cmse_nonsecure_entry
)
{
if
!
matches!
(
tcx
.fn_sig
(
id
)
.abi
(),
abi
::
Abi
::
C
{
..
})
{
if
!
matches!
(
tcx
.fn_sig
(
d
id
)
.abi
(),
abi
::
Abi
::
C
{
..
})
{
struct_span_err!
(
tcx
.sess
,
attr
.span
,
...
...
@@ -2874,11 +2865,11 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
}
else
if
attr
.has_name
(
sym
::
thread_local
)
{
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
THREAD_LOCAL
;
}
else
if
attr
.has_name
(
sym
::
track_caller
)
{
if
!
tcx
.is_closure
(
id
)
&&
tcx
.fn_sig
(
id
)
.abi
()
!=
abi
::
Abi
::
Rust
{
if
!
tcx
.is_closure
(
did
.to_def_id
())
&&
tcx
.fn_sig
(
d
id
)
.abi
()
!=
abi
::
Abi
::
Rust
{
struct_span_err!
(
tcx
.sess
,
attr
.span
,
E0737
,
"`#[track_caller]` requires Rust ABI"
)
.emit
();
}
if
tcx
.is_closure
(
id
)
&&
!
tcx
.features
()
.closure_track_caller
{
if
tcx
.is_closure
(
did
.to_def_id
()
)
&&
!
tcx
.features
()
.closure_track_caller
{
feature_err
(
&
tcx
.sess.parse_sess
,
sym
::
closure_track_caller
,
...
...
@@ -2904,7 +2895,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
codegen_fn_attrs
.export_name
=
Some
(
s
);
}
}
else
if
attr
.has_name
(
sym
::
target_feature
)
{
if
!
tcx
.is_closure
(
id
)
&&
tcx
.fn_sig
(
id
)
.unsafety
()
==
hir
::
Unsafety
::
Normal
{
if
!
tcx
.is_closure
(
did
.to_def_id
())
&&
tcx
.fn_sig
(
did
)
.unsafety
()
==
hir
::
Unsafety
::
Normal
{
if
tcx
.sess.target.is_like_wasm
||
tcx
.sess.opts.actually_rustdoc
{
// The `#[target_feature]` attribute is allowed on
// WebAssembly targets on all functions, including safe
...
...
@@ -2930,22 +2923,21 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
attr
.span
,
"`#[target_feature(..)]` can only be applied to `unsafe` functions"
,
);
err
.span_label
(
tcx
.def_span
(
id
),
"not an `unsafe` function"
);
err
.span_label
(
tcx
.def_span
(
d
id
),
"not an `unsafe` function"
);
err
.emit
();
}
else
if
let
Some
(
local_id
)
=
id
.as_local
()
{
check_target_feature_trait_unsafe
(
tcx
,
local_
id
,
attr
.span
);
}
else
{
check_target_feature_trait_unsafe
(
tcx
,
d
id
,
attr
.span
);
}
}
from_target_feature
(
tcx
,
id
,
attr
,
supported_target_features
,
&
mut
codegen_fn_attrs
.target_features
,
);
}
else
if
attr
.has_name
(
sym
::
linkage
)
{
if
let
Some
(
val
)
=
attr
.value_str
()
{
codegen_fn_attrs
.linkage
=
Some
(
linkage_by_name
(
tcx
,
id
,
val
.as_str
()));
codegen_fn_attrs
.linkage
=
Some
(
linkage_by_name
(
tcx
,
d
id
,
val
.as_str
()));
}
}
else
if
attr
.has_name
(
sym
::
link_section
)
{
if
let
Some
(
val
)
=
attr
.value_str
()
{
...
...
@@ -3161,8 +3153,8 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
});
// #73631: closures inherit `#[target_feature]` annotations
if
tcx
.features
()
.target_feature_11
&&
tcx
.is_closure
(
id
)
{
let
owner_id
=
tcx
.parent
(
id
);
if
tcx
.features
()
.target_feature_11
&&
tcx
.is_closure
(
did
.to_def_id
()
)
{
let
owner_id
=
tcx
.parent
(
did
.to_def_id
()
);
codegen_fn_attrs
.target_features
.extend
(
tcx
.codegen_fn_attrs
(
owner_id
)
.target_features
.iter
()
.copied
())
...
...
@@ -3187,7 +3179,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
if
!
codegen_fn_attrs
.no_sanitize
.is_empty
()
{
if
codegen_fn_attrs
.inline
==
InlineAttr
::
Always
{
if
let
(
Some
(
no_sanitize_span
),
Some
(
inline_span
))
=
(
no_sanitize_span
,
inline_span
)
{
let
hir_id
=
tcx
.hir
()
.local_def_id_to_hir_id
(
id
.expect_local
()
);
let
hir_id
=
tcx
.hir
()
.local_def_id_to_hir_id
(
did
);
tcx
.struct_span_lint_hir
(
lint
::
builtin
::
INLINE_NO_SANITIZE
,
hir_id
,
...
...
@@ -3207,7 +3199,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
// strippable by the linker.
//
// Additionally weak lang items have predetermined symbol names.
if
tcx
.is_weak_lang_item
(
id
)
{
if
tcx
.is_weak_lang_item
(
did
.to_def_id
()
)
{
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
RUSTC_STD_INTERNAL_SYMBOL
;
}
if
let
Some
(
name
)
=
weak_lang_items
::
link_name
(
attrs
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录