@@ -18,6 +18,7 @@ use crate::llvm;
18
18
use crate :: llvm:: AttributePlace :: Function ;
19
19
use crate :: type_:: Type ;
20
20
use crate :: value:: Value ;
21
+ use itertools:: Itertools ;
21
22
use rustc_codegen_ssa:: traits:: TypeMembershipMethods ;
22
23
use rustc_middle:: ty:: { Instance , Ty } ;
23
24
use rustc_symbol_mangling:: typeid:: {
@@ -141,20 +142,32 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
141
142
142
143
if self . tcx . sess . is_sanitizer_cfi_enabled ( ) {
143
144
if let Some ( instance) = instance {
144
- let typeid = typeid_for_instance ( self . tcx , instance, TypeIdOptions :: empty ( ) ) ;
145
- self . set_type_metadata ( llfn, typeid) ;
146
- let typeid =
147
- typeid_for_instance ( self . tcx , instance, TypeIdOptions :: GENERALIZE_POINTERS ) ;
148
- self . add_type_metadata ( llfn, typeid) ;
149
- let typeid =
150
- typeid_for_instance ( self . tcx , instance, TypeIdOptions :: NORMALIZE_INTEGERS ) ;
151
- self . add_type_metadata ( llfn, typeid) ;
152
- let typeid = typeid_for_instance (
153
- self . tcx ,
154
- instance,
155
- TypeIdOptions :: GENERALIZE_POINTERS | TypeIdOptions :: NORMALIZE_INTEGERS ,
156
- ) ;
157
- self . add_type_metadata ( llfn, typeid) ;
145
+ let mut typeids = Vec :: new ( ) ;
146
+ for options in
147
+ [ TypeIdOptions :: GENERALIZE_POINTERS , TypeIdOptions :: NORMALIZE_INTEGERS ]
148
+ . into_iter ( )
149
+ . powerset ( )
150
+ . map ( TypeIdOptions :: from_iter)
151
+ {
152
+ let typeid = typeid_for_instance ( self . tcx , instance, options) ;
153
+ typeids. push ( typeid. clone ( ) ) ;
154
+ self . add_type_metadata ( llfn, typeid) ;
155
+ }
156
+ for options in [
157
+ TypeIdOptions :: NO_TYPE_ERASURE ,
158
+ TypeIdOptions :: GENERALIZE_POINTERS ,
159
+ TypeIdOptions :: NORMALIZE_INTEGERS ,
160
+ ]
161
+ . into_iter ( )
162
+ . powerset ( )
163
+ . map ( TypeIdOptions :: from_iter)
164
+ {
165
+ let typeid = typeid_for_instance ( self . tcx , instance, options) ;
166
+ if !typeids. contains ( & typeid) {
167
+ typeids. push ( typeid. clone ( ) ) ;
168
+ self . add_type_metadata ( llfn, typeid) ;
169
+ }
170
+ }
158
171
} else {
159
172
let typeid = typeid_for_fnabi ( self . tcx , fn_abi, TypeIdOptions :: empty ( ) ) ;
160
173
self . set_type_metadata ( llfn, typeid) ;
0 commit comments