Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
bb2059f9
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,发现更多精彩内容 >>
提交
bb2059f9
编写于
2月 24, 2022
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debuginfo: Simplify TypeMap used during LLVM debuginfo generation -- address review comments.
上级
e72e6399
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
8 deletion
+23
-8
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+23
-8
未找到文件。
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
浏览文件 @
bb2059f9
...
...
@@ -113,11 +113,20 @@ pub struct HiddenZst {
/// A unique identifier for anything that we create a debuginfo node for.
/// The types it contains are expected to already be normalized (which
/// is debug_asserted in the constructors).
///
/// Note that there are some things that only show up in debuginfo, like
/// the separate type descriptions for each enum variant. These get an ID
/// too because they have their own debuginfo node in LLVM IR.
#[derive(Debug,
Clone,
Copy,
PartialEq,
Eq,
Hash,
HashStable)]
pub
(
super
)
enum
UniqueTypeId
<
'tcx
>
{
/// The ID of a regular type as it shows up at the language level.
Ty
(
Ty
<
'tcx
>
,
HiddenZst
),
/// The ID for the artificial struct type describing a single enum variant.
Variant
(
Ty
<
'tcx
>
,
VariantIdx
,
HiddenZst
),
/// The ID for the single DW_TAG_variant_part nested inside the top-level
/// DW_TAG_structure_type that describes enums and generators.
VariantPart
(
Ty
<
'tcx
>
,
HiddenZst
),
/// The ID of the artificial type we create for VTables.
VTableTy
(
Ty
<
'tcx
>
,
Option
<
PolyExistentialTraitRef
<
'tcx
>>
,
HiddenZst
),
}
...
...
@@ -163,7 +172,11 @@ pub fn for_vtable_ty(
UniqueTypeId
::
VTableTy
(
self_type
,
implemented_trait
,
HiddenZst
{
_
inaccessible
:
()
})
}
pub
fn
to_string
(
&
self
,
tcx
:
TyCtxt
<
'tcx
>
)
->
String
{
/// Generates a string version of this [UniqueTypeId], which can be used as the `UniqueId`
/// argument of the various `LLVMRustDIBuilderCreate*Type()` methods.
///
/// Right now this takes the form of a hex-encoded opaque hash value.
pub
fn
generate_unique_id_string
(
&
self
,
tcx
:
TyCtxt
<
'tcx
>
)
->
String
{
let
mut
hasher
=
StableHasher
::
new
();
let
mut
hcx
=
tcx
.create_stable_hashing_context
();
hcx
.while_hashing_spans
(
false
,
|
hcx
|
{
...
...
@@ -646,9 +659,8 @@ pub fn type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll
"expected type metadata for unique
\
type ID '{:?}' to already be in
\
the `debuginfo::TypeMap` but it
\
was not.
(Ty = {})
"
,
was not."
,
unique_type_id
,
t
);
}
};
...
...
@@ -672,6 +684,9 @@ fn recursion_marker_type<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) -> &'ll DIType {
//
// FIXME: the name `<recur_type>` does not fit the naming scheme
// of other types.
//
// FIXME: it might make sense to use an actual pointer type here
// so that debuggers can show the address.
let
name
=
"<recur_type>"
;
llvm
::
LLVMRustDIBuilderCreateBasicType
(
DIB
(
cx
),
...
...
@@ -2030,7 +2045,7 @@ fn prepare_enum_metadata<'ll, 'tcx>(
};
let
enum_metadata
=
{
let
unique_type_id_str
=
unique_type_id
.
to
_string
(
tcx
);
let
unique_type_id_str
=
unique_type_id
.
generate_unique_id
_string
(
tcx
);
unsafe
{
llvm
::
LLVMRustDIBuilderCreateUnionType
(
...
...
@@ -2142,7 +2157,7 @@ fn prepare_enum_metadata<'ll, 'tcx>(
};
let
variant_part_unique_type_id_str
=
UniqueTypeId
::
for_enum_variant_part
(
tcx
,
enum_type
)
.
to
_string
(
tcx
);
UniqueTypeId
::
for_enum_variant_part
(
tcx
,
enum_type
)
.
generate_unique_id
_string
(
tcx
);
let
empty_array
=
create_DIArray
(
DIB
(
cx
),
&
[]);
let
name
=
""
;
...
...
@@ -2171,7 +2186,7 @@ fn prepare_enum_metadata<'ll, 'tcx>(
// an equivalent layout but offers us much better integration with
// debuggers.
let
type_array
=
create_DIArray
(
DIB
(
cx
),
&
[
Some
(
variant_part
)]);
let
unique_type_id_str
=
unique_type_id
.
to
_string
(
tcx
);
let
unique_type_id_str
=
unique_type_id
.
generate_unique_id
_string
(
tcx
);
unsafe
{
llvm
::
LLVMRustDIBuilderCreateStructType
(
...
...
@@ -2345,7 +2360,7 @@ fn create_struct_stub<'ll, 'tcx>(
flags
:
DIFlags
,
vtable_holder
:
Option
<&
'll
DIType
>
,
)
->
&
'll
DICompositeType
{
let
unique_type_id
=
unique_type_id
.
to
_string
(
cx
.tcx
);
let
unique_type_id
=
unique_type_id
.
generate_unique_id
_string
(
cx
.tcx
);
let
metadata_stub
=
unsafe
{
// `LLVMRustDIBuilderCreateStructType()` wants an empty array. A null
...
...
@@ -2383,7 +2398,7 @@ fn create_union_stub<'ll, 'tcx>(
containing_scope
:
&
'll
DIScope
,
)
->
&
'll
DICompositeType
{
let
(
union_size
,
union_align
)
=
cx
.size_and_align_of
(
union_type
);
let
unique_type_id
=
unique_type_id
.
to
_string
(
cx
.tcx
);
let
unique_type_id
=
unique_type_id
.
generate_unique_id
_string
(
cx
.tcx
);
let
metadata_stub
=
unsafe
{
// `LLVMRustDIBuilderCreateUnionType()` wants an empty array. A null
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录