1
1
use rustc_codegen_ssa:: debuginfo:: {
2
+ tag_base_type,
2
3
type_names:: { compute_debuginfo_type_name, cpp_like_debuginfo} ,
3
4
wants_c_like_enum_debuginfo,
4
5
} ;
@@ -9,14 +10,12 @@ use rustc_middle::{
9
10
mir:: CoroutineLayout ,
10
11
ty:: {
11
12
self ,
12
- layout:: { IntegerExt , LayoutOf , PrimitiveExt , TyAndLayout } ,
13
+ layout:: { LayoutOf , TyAndLayout } ,
13
14
AdtDef , CoroutineArgs , CoroutineArgsExt , Ty , VariantDef ,
14
15
} ,
15
16
} ;
16
17
use rustc_span:: Symbol ;
17
- use rustc_target:: abi:: {
18
- FieldIdx , HasDataLayout , Integer , Primitive , TagEncoding , VariantIdx , Variants ,
19
- } ;
18
+ use rustc_target:: abi:: { FieldIdx , TagEncoding , VariantIdx , Variants } ;
20
19
use std:: borrow:: Cow ;
21
20
22
21
use crate :: {
@@ -55,6 +54,12 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
55
54
56
55
let enum_type_and_layout = cx. layout_of ( enum_type) ;
57
56
57
+ if cpp_like_debuginfo ( cx. tcx )
58
+ && tag_base_type ( cx. tcx , enum_type_and_layout) . primitive_size ( cx. tcx ) . bits ( ) == 128
59
+ {
60
+ return cpp_like:: build_enum_type_di_node ( cx, unique_type_id) ;
61
+ }
62
+
58
63
if wants_c_like_enum_debuginfo ( enum_type_and_layout) {
59
64
return build_c_style_enum_di_node ( cx, enum_adt_def, enum_type_and_layout) ;
60
65
}
@@ -90,7 +95,7 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
90
95
di_node : build_enumeration_type_di_node (
91
96
cx,
92
97
& compute_debuginfo_type_name ( cx. tcx , enum_type_and_layout. ty , false ) ,
93
- tag_base_type ( cx, enum_type_and_layout) ,
98
+ tag_base_type ( cx. tcx , enum_type_and_layout) ,
94
99
enum_adt_def. discriminants ( cx. tcx ) . map ( |( variant_index, discr) | {
95
100
let name = Cow :: from ( enum_adt_def. variant ( variant_index) . name . as_str ( ) ) ;
96
101
( name, discr. val )
@@ -101,48 +106,6 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
101
106
}
102
107
}
103
108
104
- /// Extract the type with which we want to describe the tag of the given enum or coroutine.
105
- fn tag_base_type < ' ll , ' tcx > (
106
- cx : & CodegenCx < ' ll , ' tcx > ,
107
- enum_type_and_layout : TyAndLayout < ' tcx > ,
108
- ) -> Ty < ' tcx > {
109
- debug_assert ! ( match enum_type_and_layout. ty. kind( ) {
110
- ty:: Coroutine ( ..) => true ,
111
- ty:: Adt ( adt_def, _) => adt_def. is_enum( ) ,
112
- _ => false ,
113
- } ) ;
114
-
115
- match enum_type_and_layout. layout . variants ( ) {
116
- // A single-variant enum has no discriminant.
117
- Variants :: Single { .. } => {
118
- bug ! ( "tag_base_type() called for enum without tag: {:?}" , enum_type_and_layout)
119
- }
120
-
121
- Variants :: Multiple { tag_encoding : TagEncoding :: Niche { .. } , tag, .. } => {
122
- // Niche tags are always normalized to unsized integers of the correct size.
123
- match tag. primitive ( ) {
124
- Primitive :: Int ( t, _) => t,
125
- Primitive :: Float ( f) => Integer :: from_size ( f. size ( ) ) . unwrap ( ) ,
126
- // FIXME(erikdesjardins): handle non-default addrspace ptr sizes
127
- Primitive :: Pointer ( _) => {
128
- // If the niche is the NULL value of a reference, then `discr_enum_ty` will be
129
- // a RawPtr. CodeView doesn't know what to do with enums whose base type is a
130
- // pointer so we fix this up to just be `usize`.
131
- // DWARF might be able to deal with this but with an integer type we are on
132
- // the safe side there too.
133
- cx. data_layout ( ) . ptr_sized_integer ( )
134
- }
135
- }
136
- . to_ty ( cx. tcx , false )
137
- }
138
-
139
- Variants :: Multiple { tag_encoding : TagEncoding :: Direct , tag, .. } => {
140
- // Direct tags preserve the sign.
141
- tag. primitive ( ) . to_ty ( cx. tcx )
142
- }
143
- }
144
- }
145
-
146
109
/// Build a DW_TAG_enumeration_type debuginfo node, with the given base type and variants.
147
110
/// This is a helper function and does not register anything in the type map by itself.
148
111
///
0 commit comments