Rollup merge of #65124 - memoryruins:castaway, r=petrochenkov
Replace some instances of `as *[const | mut] _` with `.cast()` While in `codegen_llvm`, noticed some places for the recent `pointer::cast` method.
This commit is contained in:
commit
42caed9bac
@ -68,7 +68,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut ModuleLlvm, kind: Alloc
|
||||
|
||||
let llbb = llvm::LLVMAppendBasicBlockInContext(llcx,
|
||||
llfn,
|
||||
"entry\0".as_ptr() as *const _);
|
||||
"entry\0".as_ptr().cast());
|
||||
|
||||
let llbuilder = llvm::LLVMCreateBuilderInContext(llcx);
|
||||
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
|
||||
@ -80,7 +80,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut ModuleLlvm, kind: Alloc
|
||||
args.as_ptr(),
|
||||
args.len() as c_uint,
|
||||
None,
|
||||
"\0".as_ptr() as *const _);
|
||||
"\0".as_ptr().cast());
|
||||
llvm::LLVMSetTailCall(ret, True);
|
||||
if output.is_some() {
|
||||
llvm::LLVMBuildRet(llbuilder, ret);
|
||||
|
@ -546,7 +546,7 @@ pub(crate) fn run_pass_manager(cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
llvm::LLVMRustAddAnalysisPasses(module.module_llvm.tm, pm, module.module_llvm.llmod());
|
||||
|
||||
if config.verify_llvm_ir {
|
||||
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
|
||||
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr().cast());
|
||||
llvm::LLVMRustAddPass(pm, pass.unwrap());
|
||||
}
|
||||
|
||||
@ -581,12 +581,12 @@ pub(crate) fn run_pass_manager(cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
// We always generate bitcode through ThinLTOBuffers,
|
||||
// which do not support anonymous globals
|
||||
if config.bitcode_needed() {
|
||||
let pass = llvm::LLVMRustFindAndCreatePass("name-anon-globals\0".as_ptr() as *const _);
|
||||
let pass = llvm::LLVMRustFindAndCreatePass("name-anon-globals\0".as_ptr().cast());
|
||||
llvm::LLVMRustAddPass(pm, pass.unwrap());
|
||||
}
|
||||
|
||||
if config.verify_llvm_ir {
|
||||
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
|
||||
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr().cast());
|
||||
llvm::LLVMRustAddPass(pm, pass.unwrap());
|
||||
}
|
||||
|
||||
|
@ -221,8 +221,8 @@ impl<'a> DiagnosticHandlers<'a> {
|
||||
llcx: &'a llvm::Context) -> Self {
|
||||
let data = Box::into_raw(Box::new((cgcx, handler)));
|
||||
unsafe {
|
||||
llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data as *mut _);
|
||||
llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data as *mut _);
|
||||
llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data.cast());
|
||||
llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data.cast());
|
||||
}
|
||||
DiagnosticHandlers { data, llcx }
|
||||
}
|
||||
@ -672,7 +672,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
let llglobal = llvm::LLVMAddGlobal(
|
||||
llmod,
|
||||
common::val_ty(llconst),
|
||||
"rustc.embedded.module\0".as_ptr() as *const _,
|
||||
"rustc.embedded.module\0".as_ptr().cast(),
|
||||
);
|
||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
||||
|
||||
@ -684,7 +684,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
} else {
|
||||
".llvmbc\0"
|
||||
};
|
||||
llvm::LLVMSetSection(llglobal, section.as_ptr() as *const _);
|
||||
llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
|
||||
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
|
||||
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
|
||||
|
||||
@ -692,7 +692,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
let llglobal = llvm::LLVMAddGlobal(
|
||||
llmod,
|
||||
common::val_ty(llconst),
|
||||
"rustc.embedded.cmdline\0".as_ptr() as *const _,
|
||||
"rustc.embedded.cmdline\0".as_ptr().cast(),
|
||||
);
|
||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
||||
let section = if is_apple {
|
||||
@ -700,7 +700,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
} else {
|
||||
".llvmcmd\0"
|
||||
};
|
||||
llvm::LLVMSetSection(llglobal, section.as_ptr() as *const _);
|
||||
llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
|
||||
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
|
||||
}
|
||||
|
||||
@ -842,7 +842,7 @@ fn create_msvc_imps(
|
||||
for (imp_name, val) in globals {
|
||||
let imp = llvm::LLVMAddGlobal(llmod,
|
||||
i8p_ty,
|
||||
imp_name.as_ptr() as *const _);
|
||||
imp_name.as_ptr().cast());
|
||||
llvm::LLVMSetInitializer(imp, consts::ptrcast(val, i8p_ty));
|
||||
llvm::LLVMRustSetLinkage(imp, llvm::Linkage::ExternalLinkage);
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
|
||||
if let Some(section) = attrs.link_section {
|
||||
let section = llvm::LLVMMDStringInContext(
|
||||
self.llcx,
|
||||
section.as_str().as_ptr() as *const _,
|
||||
section.as_str().as_ptr().cast(),
|
||||
section.as_str().len() as c_uint,
|
||||
);
|
||||
assert!(alloc.relocations().is_empty());
|
||||
@ -500,14 +500,14 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
|
||||
0..alloc.len());
|
||||
let alloc = llvm::LLVMMDStringInContext(
|
||||
self.llcx,
|
||||
bytes.as_ptr() as *const _,
|
||||
bytes.as_ptr().cast(),
|
||||
bytes.len() as c_uint,
|
||||
);
|
||||
let data = [section, alloc];
|
||||
let meta = llvm::LLVMMDNodeInContext(self.llcx, data.as_ptr(), 2);
|
||||
llvm::LLVMAddNamedMetadataOperand(
|
||||
self.llmod,
|
||||
"wasm.custom_sections\0".as_ptr() as *const _,
|
||||
"wasm.custom_sections\0".as_ptr().cast(),
|
||||
meta,
|
||||
);
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ pub unsafe fn create_module(
|
||||
// If skipping the PLT is enabled, we need to add some module metadata
|
||||
// to ensure intrinsic calls don't use it.
|
||||
if !sess.needs_plt() {
|
||||
let avoid_plt = "RtLibUseGOT\0".as_ptr() as *const _;
|
||||
let avoid_plt = "RtLibUseGOT\0".as_ptr().cast();
|
||||
llvm::LLVMRustAddModuleFlag(llmod, avoid_plt, 1);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
|
||||
|
||||
let section_var = unsafe {
|
||||
llvm::LLVMGetNamedGlobal(cx.llmod,
|
||||
c_section_var_name.as_ptr() as *const _)
|
||||
c_section_var_name.as_ptr().cast())
|
||||
};
|
||||
|
||||
section_var.unwrap_or_else(|| {
|
||||
@ -52,7 +52,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
|
||||
llvm_type).unwrap_or_else(||{
|
||||
bug!("symbol `{}` is already defined", section_var_name)
|
||||
});
|
||||
llvm::LLVMSetSection(section_var, section_name.as_ptr() as *const _);
|
||||
llvm::LLVMSetSection(section_var, section_name.as_ptr().cast());
|
||||
llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents));
|
||||
llvm::LLVMSetGlobalConstant(section_var, llvm::True);
|
||||
llvm::LLVMSetUnnamedAddr(section_var, llvm::True);
|
||||
|
@ -961,9 +961,9 @@ pub fn compile_unit_metadata(
|
||||
file_metadata,
|
||||
producer.as_ptr(),
|
||||
tcx.sess.opts.optimize != config::OptLevel::No,
|
||||
flags.as_ptr() as *const _,
|
||||
flags.as_ptr().cast(),
|
||||
0,
|
||||
split_name.as_ptr() as *const _,
|
||||
split_name.as_ptr().cast(),
|
||||
kind);
|
||||
|
||||
if tcx.sess.opts.debugging_opts.profile {
|
||||
@ -992,7 +992,7 @@ pub fn compile_unit_metadata(
|
||||
if tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
|
||||
let name_metadata = llvm::LLVMMDStringInContext(
|
||||
debug_context.llcontext,
|
||||
rustc_producer.as_ptr() as *const _,
|
||||
rustc_producer.as_ptr().cast(),
|
||||
rustc_producer.as_bytes().len() as c_uint,
|
||||
);
|
||||
llvm::LLVMAddNamedMetadataOperand(
|
||||
|
@ -127,20 +127,20 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
|
||||
if cx.sess().target.target.options.is_like_osx ||
|
||||
cx.sess().target.target.options.is_like_android {
|
||||
llvm::LLVMRustAddModuleFlag(cx.llmod,
|
||||
"Dwarf Version\0".as_ptr() as *const _,
|
||||
"Dwarf Version\0".as_ptr().cast(),
|
||||
2)
|
||||
}
|
||||
|
||||
// Indicate that we want CodeView debug information on MSVC
|
||||
if cx.sess().target.target.options.is_like_msvc {
|
||||
llvm::LLVMRustAddModuleFlag(cx.llmod,
|
||||
"CodeView\0".as_ptr() as *const _,
|
||||
"CodeView\0".as_ptr().cast(),
|
||||
1)
|
||||
}
|
||||
|
||||
// Prevent bitcode readers from deleting the debug info.
|
||||
let ptr = "Debug Info Version\0".as_ptr();
|
||||
llvm::LLVMRustAddModuleFlag(cx.llmod, ptr as *const _,
|
||||
llvm::LLVMRustAddModuleFlag(cx.llmod, ptr.cast(),
|
||||
llvm::LLVMRustDebugMetadataVersion());
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user