@@ -19,11 +19,8 @@ use crate::llvm::AttributePlace::Function;
1919use crate :: type_:: Type ;
2020use crate :: value:: Value ;
2121use 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 } ;
2724use smallvec:: SmallVec ;
2825
2926/// Declare a function.
@@ -119,12 +116,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
119116 ///
120117 /// If there’s a value with the same name already declared, the function will
121118 /// 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 {
128120 debug ! ( "declare_rust_fn(name={:?}, fn_abi={:?})" , name, fn_abi) ;
129121
130122 // Function addresses in Rust are never significant, allowing functions to
@@ -140,35 +132,18 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
140132 fn_abi. apply_attrs_llfn ( self , llfn) ;
141133
142134 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) ;
172147 }
173148
174149 if self . tcx . sess . is_sanitizer_kcfi_enabled ( ) {
@@ -181,13 +156,8 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
181156 options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
182157 }
183158
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) ;
191161 }
192162
193163 llfn
0 commit comments