@@ -22,10 +22,7 @@ use itertools::Itertools;
22
22
use rustc_codegen_ssa:: traits:: TypeMembershipMethods ;
23
23
use rustc_data_structures:: fx:: FxIndexSet ;
24
24
use rustc_middle:: ty:: { Instance , Ty } ;
25
- use rustc_symbol_mangling:: typeid:: {
26
- kcfi_typeid_for_fnabi, kcfi_typeid_for_instance, typeid_for_fnabi, typeid_for_instance,
27
- TypeIdOptions ,
28
- } ;
25
+ use rustc_sanitizers:: { cfi, kcfi} ;
29
26
use smallvec:: SmallVec ;
30
27
31
28
/// Declare a function.
@@ -145,47 +142,49 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
145
142
if let Some ( instance) = instance {
146
143
let mut typeids = FxIndexSet :: default ( ) ;
147
144
for options in [
148
- TypeIdOptions :: GENERALIZE_POINTERS ,
149
- TypeIdOptions :: NORMALIZE_INTEGERS ,
150
- TypeIdOptions :: USE_CONCRETE_SELF ,
145
+ cfi :: TypeIdOptions :: GENERALIZE_POINTERS ,
146
+ cfi :: TypeIdOptions :: NORMALIZE_INTEGERS ,
147
+ cfi :: TypeIdOptions :: USE_CONCRETE_SELF ,
151
148
]
152
149
. into_iter ( )
153
150
. powerset ( )
154
- . map ( TypeIdOptions :: from_iter)
151
+ . map ( cfi :: TypeIdOptions :: from_iter)
155
152
{
156
- let typeid = typeid_for_instance ( self . tcx , instance, options) ;
153
+ let typeid = cfi :: typeid_for_instance ( self . tcx , instance, options) ;
157
154
if typeids. insert ( typeid. clone ( ) ) {
158
155
self . add_type_metadata ( llfn, typeid) ;
159
156
}
160
157
}
161
158
} else {
162
- for options in
163
- [ TypeIdOptions :: GENERALIZE_POINTERS , TypeIdOptions :: NORMALIZE_INTEGERS ]
164
- . into_iter ( )
165
- . powerset ( )
166
- . map ( TypeIdOptions :: from_iter)
159
+ for options in [
160
+ cfi:: TypeIdOptions :: GENERALIZE_POINTERS ,
161
+ cfi:: TypeIdOptions :: NORMALIZE_INTEGERS ,
162
+ ]
163
+ . into_iter ( )
164
+ . powerset ( )
165
+ . map ( cfi:: TypeIdOptions :: from_iter)
167
166
{
168
- let typeid = typeid_for_fnabi ( self . tcx , fn_abi, options) ;
167
+ let typeid = cfi :: typeid_for_fnabi ( self . tcx , fn_abi, options) ;
169
168
self . add_type_metadata ( llfn, typeid) ;
170
169
}
171
170
}
172
171
}
173
172
174
173
if self . tcx . sess . is_sanitizer_kcfi_enabled ( ) {
175
174
// LLVM KCFI does not support multiple !kcfi_type attachments
176
- let mut options = TypeIdOptions :: empty ( ) ;
175
+ let mut options = kcfi :: TypeIdOptions :: empty ( ) ;
177
176
if self . tcx . sess . is_sanitizer_cfi_generalize_pointers_enabled ( ) {
178
- options. insert ( TypeIdOptions :: GENERALIZE_POINTERS ) ;
177
+ options. insert ( kcfi :: TypeIdOptions :: GENERALIZE_POINTERS ) ;
179
178
}
180
179
if self . tcx . sess . is_sanitizer_cfi_normalize_integers_enabled ( ) {
181
- options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
180
+ options. insert ( kcfi :: TypeIdOptions :: NORMALIZE_INTEGERS ) ;
182
181
}
183
182
184
183
if let Some ( instance) = instance {
185
- let kcfi_typeid = kcfi_typeid_for_instance ( self . tcx , instance, options) ;
184
+ let kcfi_typeid = kcfi :: typeid_for_instance ( self . tcx , instance, options) ;
186
185
self . set_kcfi_type_metadata ( llfn, kcfi_typeid) ;
187
186
} else {
188
- let kcfi_typeid = kcfi_typeid_for_fnabi ( self . tcx , fn_abi, options) ;
187
+ let kcfi_typeid = kcfi :: typeid_for_fnabi ( self . tcx , fn_abi, options) ;
189
188
self . set_kcfi_type_metadata ( llfn, kcfi_typeid) ;
190
189
}
191
190
}
0 commit comments