diff options
| author | bors <bors@rust-lang.org> | 2020-03-11 13:05:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-03-11 13:05:52 +0000 |
| commit | c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be (patch) | |
| tree | e8f110a9249dbcf8ce290bda1b3c7702488247fa /src/librustc_codegen_llvm/allocator.rs | |
| parent | 303d8aff6092709edd4dbd35b1c88e9aa40bf6d8 (diff) | |
| parent | a77206fa4a35e7926fb4404bd167b06e342b7626 (diff) | |
| download | rust-c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be.tar.gz rust-c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be.zip | |
Auto merge of #69919 - Centril:rollup-fxo33zs, r=Centril
Rollup of 8 pull requests Successful merges: - #66472 (--show-coverage json) - #69603 (tidy: replace `make check` with `./x.py test` in documentation) - #69760 (Improve expression & attribute parsing) - #69828 (fix memory leak when vec::IntoIter panics during drop) - #69850 (panic_bounds_check: use caller_location, like PanicFnLangItem) - #69876 (Add long error explanation for E0739) - #69888 ([Miri] Use a session variable instead of checking for an env var always) - #69893 (librustc_codegen_llvm: Use slices instead of 0-terminated strings) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_codegen_llvm/allocator.rs')
| -rw-r--r-- | src/librustc_codegen_llvm/allocator.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/librustc_codegen_llvm/allocator.rs b/src/librustc_codegen_llvm/allocator.rs index 821377db0ee..4e7bc9fa0e2 100644 --- a/src/librustc_codegen_llvm/allocator.rs +++ b/src/librustc_codegen_llvm/allocator.rs @@ -1,5 +1,3 @@ -use std::ffi::CString; - use crate::attributes; use libc::c_uint; use rustc::bug; @@ -50,8 +48,8 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut ModuleLlvm, kind: Alloc args.len() as c_uint, False, ); - let name = CString::new(format!("__rust_{}", method.name)).unwrap(); - let llfn = llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr(), ty); + let name = format!("__rust_{}", method.name); + let llfn = llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty); if tcx.sess.target.target.options.default_hidden_visibility { llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden); @@ -60,8 +58,9 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut ModuleLlvm, kind: Alloc attributes::emit_uwtable(llfn, true); } - let callee = CString::new(kind.fn_name(method.name)).unwrap(); - let callee = llvm::LLVMRustGetOrInsertFunction(llmod, callee.as_ptr(), ty); + let callee = kind.fn_name(method.name); + let callee = + llvm::LLVMRustGetOrInsertFunction(llmod, callee.as_ptr().cast(), callee.len(), ty); llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden); let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, "entry\0".as_ptr().cast()); @@ -73,14 +72,8 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut ModuleLlvm, kind: Alloc .enumerate() .map(|(i, _)| llvm::LLVMGetParam(llfn, i as c_uint)) .collect::<Vec<_>>(); - let ret = llvm::LLVMRustBuildCall( - llbuilder, - callee, - args.as_ptr(), - args.len() as c_uint, - None, - "\0".as_ptr().cast(), - ); + let ret = + llvm::LLVMRustBuildCall(llbuilder, callee, args.as_ptr(), args.len() as c_uint, None); llvm::LLVMSetTailCall(ret, True); if output.is_some() { llvm::LLVMBuildRet(llbuilder, ret); |
