@@ -19,11 +19,8 @@ use crate::llvm::AttributePlace::Function;
19
19
use crate :: type_:: Type ;
20
20
use crate :: value:: Value ;
21
21
use rustc_codegen_ssa:: traits:: TypeMembershipMethods ;
22
- use rustc_middle:: ty:: { Instance , Ty } ;
23
- use rustc_symbol_mangling:: typeid:: {
24
- kcfi_typeid_for_fnabi, kcfi_typeid_for_instance, typeid_for_fnabi, typeid_for_instance,
25
- TypeIdOptions ,
26
- } ;
22
+ use rustc_middle:: ty:: Ty ;
23
+ use rustc_symbol_mangling:: typeid:: { kcfi_typeid_for_fnabi, typeid_for_fnabi, TypeIdOptions } ;
27
24
use smallvec:: SmallVec ;
28
25
29
26
/// Declare a function.
@@ -119,12 +116,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
119
116
///
120
117
/// If there’s a value with the same name already declared, the function will
121
118
/// update the declaration and return existing Value instead.
122
- pub fn declare_fn (
123
- & self ,
124
- name : & str ,
125
- fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
126
- instance : Option < Instance < ' tcx > > ,
127
- ) -> & ' ll Value {
119
+ pub fn declare_fn ( & self , name : & str , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ) -> & ' ll Value {
128
120
debug ! ( "declare_rust_fn(name={:?}, fn_abi={:?})" , name, fn_abi) ;
129
121
130
122
// Function addresses in Rust are never significant, allowing functions to
@@ -140,35 +132,18 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
140
132
fn_abi. apply_attrs_llfn ( self , llfn) ;
141
133
142
134
if self . tcx . sess . is_sanitizer_cfi_enabled ( ) {
143
- 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) ;
158
- } else {
159
- let typeid = typeid_for_fnabi ( self . tcx , fn_abi, TypeIdOptions :: empty ( ) ) ;
160
- self . set_type_metadata ( llfn, typeid) ;
161
- let typeid = typeid_for_fnabi ( self . tcx , fn_abi, TypeIdOptions :: GENERALIZE_POINTERS ) ;
162
- self . add_type_metadata ( llfn, typeid) ;
163
- let typeid = typeid_for_fnabi ( self . tcx , fn_abi, TypeIdOptions :: NORMALIZE_INTEGERS ) ;
164
- self . add_type_metadata ( llfn, typeid) ;
165
- let typeid = typeid_for_fnabi (
166
- self . tcx ,
167
- fn_abi,
168
- TypeIdOptions :: GENERALIZE_POINTERS | TypeIdOptions :: NORMALIZE_INTEGERS ,
169
- ) ;
170
- self . add_type_metadata ( llfn, typeid) ;
171
- }
135
+ let typeid = typeid_for_fnabi ( self . tcx , fn_abi, TypeIdOptions :: empty ( ) ) ;
136
+ self . set_type_metadata ( llfn, typeid) ;
137
+ let typeid = typeid_for_fnabi ( self . tcx , fn_abi, TypeIdOptions :: GENERALIZE_POINTERS ) ;
138
+ self . add_type_metadata ( llfn, typeid) ;
139
+ let typeid = typeid_for_fnabi ( self . tcx , fn_abi, TypeIdOptions :: NORMALIZE_INTEGERS ) ;
140
+ self . add_type_metadata ( llfn, typeid) ;
141
+ let typeid = typeid_for_fnabi (
142
+ self . tcx ,
143
+ fn_abi,
144
+ TypeIdOptions :: GENERALIZE_POINTERS | TypeIdOptions :: NORMALIZE_INTEGERS ,
145
+ ) ;
146
+ self . add_type_metadata ( llfn, typeid) ;
172
147
}
173
148
174
149
if self . tcx . sess . is_sanitizer_kcfi_enabled ( ) {
@@ -181,13 +156,8 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
181
156
options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
182
157
}
183
158
184
- if let Some ( instance) = instance {
185
- let kcfi_typeid = kcfi_typeid_for_instance ( self . tcx , & instance, options) ;
186
- self . set_kcfi_type_metadata ( llfn, kcfi_typeid) ;
187
- } else {
188
- let kcfi_typeid = kcfi_typeid_for_fnabi ( self . tcx , fn_abi, options) ;
189
- self . set_kcfi_type_metadata ( llfn, kcfi_typeid) ;
190
- }
159
+ let kcfi_typeid = kcfi_typeid_for_fnabi ( self . tcx , fn_abi, options) ;
160
+ self . set_kcfi_type_metadata ( llfn, kcfi_typeid) ;
191
161
}
192
162
193
163
llfn
0 commit comments