File tree Expand file tree Collapse file tree 4 files changed +17
-11
lines changed
compiler/rustc_codegen_llvm/src Expand file tree Collapse file tree 4 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -435,13 +435,7 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
435435 template_str. push_str ( "\n .att_syntax\n " ) ;
436436 }
437437
438- unsafe {
439- llvm:: LLVMAppendModuleInlineAsm (
440- self . llmod ,
441- template_str. as_c_char_ptr ( ) ,
442- template_str. len ( ) ,
443- ) ;
444- }
438+ llvm:: append_module_inline_asm ( self . llmod , template_str. as_bytes ( ) ) ;
445439 }
446440
447441 fn mangled_name ( & self , instance : Instance < ' tcx > ) -> String {
Original file line number Diff line number Diff line change @@ -1148,9 +1148,9 @@ unsafe fn embed_bitcode(
11481148 // We need custom section flags, so emit module-level inline assembly.
11491149 let section_flags = if cgcx. is_pe_coff { "n" } else { "e" } ;
11501150 let asm = create_section_with_flags_asm ( ".llvmbc" , section_flags, bitcode) ;
1151- llvm:: LLVMAppendModuleInlineAsm ( llmod, asm. as_c_char_ptr ( ) , asm . len ( ) ) ;
1151+ llvm:: append_module_inline_asm ( llmod, & asm) ;
11521152 let asm = create_section_with_flags_asm ( ".llvmcmd" , section_flags, cmdline. as_bytes ( ) ) ;
1153- llvm:: LLVMAppendModuleInlineAsm ( llmod, asm. as_c_char_ptr ( ) , asm . len ( ) ) ;
1153+ llvm:: append_module_inline_asm ( llmod, & asm) ;
11541154 }
11551155 }
11561156}
Original file line number Diff line number Diff line change @@ -1014,8 +1014,12 @@ unsafe extern "C" {
10141014 pub ( crate ) fn LLVMGetDataLayoutStr ( M : & Module ) -> * const c_char ;
10151015 pub ( crate ) fn LLVMSetDataLayout ( M : & Module , Triple : * const c_char ) ;
10161016
1017- /// See Module::setModuleInlineAsm.
1018- pub ( crate ) fn LLVMAppendModuleInlineAsm ( M : & Module , Asm : * const c_char , Len : size_t ) ;
1017+ /// Append inline assembly to a module. See `Module::appendModuleInlineAsm`.
1018+ pub ( crate ) fn LLVMAppendModuleInlineAsm (
1019+ M : & Module ,
1020+ Asm : * const c_uchar , // See "PTR_LEN_STR".
1021+ Len : size_t ,
1022+ ) ;
10191023
10201024 /// Create the specified uniqued inline asm string. See `InlineAsm::get()`.
10211025 pub ( crate ) fn LLVMGetInlineAsm < ' ll > (
Original file line number Diff line number Diff line change @@ -440,3 +440,11 @@ pub(crate) fn set_dso_local<'ll>(v: &'ll Value) {
440440 LLVMRustSetDSOLocal ( v, true ) ;
441441 }
442442}
443+
444+ /// Safe wrapper for `LLVMAppendModuleInlineAsm`, which delegates to
445+ /// `Module::appendModuleInlineAsm`.
446+ pub ( crate ) fn append_module_inline_asm < ' ll > ( llmod : & ' ll Module , asm : & [ u8 ] ) {
447+ unsafe {
448+ LLVMAppendModuleInlineAsm ( llmod, asm. as_ptr ( ) , asm. len ( ) ) ;
449+ }
450+ }
You can’t perform that action at this time.
0 commit comments