diff options
Diffstat (limited to 'src/librustc_codegen_llvm/asm.rs')
| -rw-r--r-- | src/librustc_codegen_llvm/asm.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/librustc_codegen_llvm/asm.rs b/src/librustc_codegen_llvm/asm.rs index 7975a70ab26..6edc3d5ecd4 100644 --- a/src/librustc_codegen_llvm/asm.rs +++ b/src/librustc_codegen_llvm/asm.rs @@ -12,7 +12,6 @@ use rustc_span::Span; use libc::{c_char, c_uint}; use log::debug; -use std::ffi::{CStr, CString}; impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { fn codegen_inline_asm( @@ -80,12 +79,11 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { _ => self.type_struct(&output_types, false), }; - let asm = CString::new(ia.asm.as_str().as_bytes()).unwrap(); - let constraint_cstr = CString::new(all_constraints).unwrap(); + let asm = ia.asm.as_str(); let r = inline_asm_call( self, &asm, - &constraint_cstr, + &all_constraints, &inputs, output_type, ia.volatile, @@ -125,17 +123,17 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { impl AsmMethods for CodegenCx<'ll, 'tcx> { fn codegen_global_asm(&self, ga: &hir::GlobalAsm) { - let asm = CString::new(ga.asm.as_str().as_bytes()).unwrap(); + let asm = ga.asm.as_str(); unsafe { - llvm::LLVMRustAppendModuleInlineAsm(self.llmod, asm.as_ptr()); + llvm::LLVMRustAppendModuleInlineAsm(self.llmod, asm.as_ptr().cast(), asm.len()); } } } fn inline_asm_call( bx: &mut Builder<'a, 'll, 'tcx>, - asm: &CStr, - cons: &CStr, + asm: &str, + cons: &str, inputs: &[&'ll Value], output: &'ll llvm::Type, volatile: bool, @@ -157,13 +155,15 @@ fn inline_asm_call( let fty = bx.cx.type_func(&argtys[..], output); unsafe { // Ask LLVM to verify that the constraints are well-formed. - let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons.as_ptr()); + let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons.as_ptr().cast(), cons.len()); debug!("constraint verification result: {:?}", constraints_ok); if constraints_ok { let v = llvm::LLVMRustInlineAsm( fty, - asm.as_ptr(), - cons.as_ptr(), + asm.as_ptr().cast(), + asm.len(), + cons.as_ptr().cast(), + cons.len(), volatile, alignstack, llvm::AsmDialect::from_generic(dia), |
