@@ -2,7 +2,7 @@ use std::borrow::Borrow;
22use std:: hash:: { Hash , Hasher } ;
33use std:: { fmt, ptr} ;
44
5- use libc:: { c_char , c_uint} ;
5+ use libc:: c_uint;
66use rustc_abi:: { AddressSpace , Align , Integer , Reg , Size } ;
77use rustc_codegen_ssa:: common:: TypeKind ;
88use rustc_codegen_ssa:: traits:: * ;
@@ -299,7 +299,7 @@ impl<'ll, 'tcx> LayoutTypeCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
299299
300300impl < ' ll , ' tcx > TypeMembershipCodegenMethods < ' tcx > for CodegenCx < ' ll , ' tcx > {
301301 fn add_type_metadata ( & self , function : & ' ll Value , typeid : String ) {
302- let typeid_metadata = self . typeid_metadata ( typeid) . unwrap ( ) ;
302+ let typeid_metadata = self . create_metadata ( typeid) ;
303303 unsafe {
304304 let v = [ llvm:: LLVMValueAsMetadata ( self . const_usize ( 0 ) ) , typeid_metadata] ;
305305 llvm:: LLVMRustGlobalAddMetadata (
@@ -311,7 +311,7 @@ impl<'ll, 'tcx> TypeMembershipCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
311311 }
312312
313313 fn set_type_metadata ( & self , function : & ' ll Value , typeid : String ) {
314- let typeid_metadata = self . typeid_metadata ( typeid) . unwrap ( ) ;
314+ let typeid_metadata = self . create_metadata ( typeid) ;
315315 unsafe {
316316 let v = [ llvm:: LLVMValueAsMetadata ( self . const_usize ( 0 ) ) , typeid_metadata] ;
317317 llvm:: LLVMGlobalSetMetadata (
@@ -323,9 +323,7 @@ impl<'ll, 'tcx> TypeMembershipCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
323323 }
324324
325325 fn typeid_metadata ( & self , typeid : String ) -> Option < & ' ll Metadata > {
326- Some ( unsafe {
327- llvm:: LLVMMDStringInContext2 ( self . llcx , typeid. as_ptr ( ) as * const c_char , typeid. len ( ) )
328- } )
326+ Some ( self . create_metadata ( typeid) )
329327 }
330328
331329 fn add_kcfi_type_metadata ( & self , function : & ' ll Value , kcfi_typeid : u32 ) {
0 commit comments