File tree 4 files changed +17
-11
lines changed
compiler/rustc_codegen_llvm/src
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> {
435
435
template_str. push_str ( "\n .att_syntax\n " ) ;
436
436
}
437
437
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 ( ) ) ;
445
439
}
446
440
447
441
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(
1148
1148
// We need custom section flags, so emit module-level inline assembly.
1149
1149
let section_flags = if cgcx. is_pe_coff { "n" } else { "e" } ;
1150
1150
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) ;
1152
1152
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) ;
1154
1154
}
1155
1155
}
1156
1156
}
Original file line number Diff line number Diff line change @@ -1014,8 +1014,12 @@ unsafe extern "C" {
1014
1014
pub ( crate ) fn LLVMGetDataLayoutStr ( M : & Module ) -> * const c_char ;
1015
1015
pub ( crate ) fn LLVMSetDataLayout ( M : & Module , Triple : * const c_char ) ;
1016
1016
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
+ ) ;
1019
1023
1020
1024
/// Create the specified uniqued inline asm string. See `InlineAsm::get()`.
1021
1025
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) {
440
440
LLVMRustSetDSOLocal ( v, true ) ;
441
441
}
442
442
}
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