rustllvm: Fix warnings about unused function parameters

This commit is contained in:
Vadim Petrochenkov 2020-05-21 20:53:41 +03:00
parent 148c125b1b
commit d0a48d19f5
7 changed files with 12 additions and 47 deletions

View file

@ -6,7 +6,6 @@ use crate::back::profiling::{
use crate::base; use crate::base;
use crate::common; use crate::common;
use crate::consts; use crate::consts;
use crate::context::all_outputs_are_pic_executables;
use crate::llvm::{self, DiagnosticInfo, PassManager, SMDiagnostic}; use crate::llvm::{self, DiagnosticInfo, PassManager, SMDiagnostic};
use crate::llvm_util; use crate::llvm_util;
use crate::type_::Type; use crate::type_::Type;
@ -150,7 +149,6 @@ pub fn target_machine_factory(
let features = features.join(","); let features = features.join(",");
let features = CString::new(features).unwrap(); let features = CString::new(features).unwrap();
let abi = SmallCStr::new(&sess.target.target.options.llvm_abiname); let abi = SmallCStr::new(&sess.target.target.options.llvm_abiname);
let pic_is_pie = all_outputs_are_pic_executables(sess);
let trap_unreachable = sess.target.target.options.trap_unreachable; let trap_unreachable = sess.target.target.options.trap_unreachable;
let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes; let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;
@ -174,7 +172,6 @@ pub fn target_machine_factory(
reloc_model, reloc_model,
opt_level, opt_level,
use_softfp, use_softfp,
pic_is_pie,
ffunction_sections, ffunction_sections,
fdata_sections, fdata_sections,
trap_unreachable, trap_unreachable,

View file

@ -97,17 +97,6 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
} }
} }
/// PIE is potentially more effective than PIC, but can only be used in executables.
/// If all our outputs are executables, then we can relax PIC to PIE when producing object code.
/// If the list of crate types is not yet known we conservatively return `false`.
pub fn all_outputs_are_pic_executables(sess: &Session) -> bool {
sess.relocation_model() == RelocModel::Pic
&& sess
.crate_types
.try_get()
.map_or(false, |crate_types| crate_types.iter().all(|ty| *ty == CrateType::Executable))
}
fn strip_function_ptr_alignment(data_layout: String) -> String { fn strip_function_ptr_alignment(data_layout: String) -> String {
// FIXME: Make this more general. // FIXME: Make this more general.
data_layout.replace("-Fi8-", "-") data_layout.replace("-Fi8-", "-")
@ -183,10 +172,11 @@ pub unsafe fn create_module(
if sess.relocation_model() == RelocModel::Pic { if sess.relocation_model() == RelocModel::Pic {
llvm::LLVMRustSetModulePICLevel(llmod); llvm::LLVMRustSetModulePICLevel(llmod);
} // PIE is potentially more effective than PIC, but can only be used in executables.
// If all our outputs are executables, then we can relax PIC to PIE.
if all_outputs_are_pic_executables(sess) { if sess.crate_types.get().iter().all(|ty| *ty == CrateType::Executable) {
llvm::LLVMRustSetModulePIELevel(llmod); llvm::LLVMRustSetModulePIELevel(llmod);
}
} }
// If skipping the PLT is enabled, we need to add some module metadata // If skipping the PLT is enabled, we need to add some module metadata

View file

@ -447,7 +447,6 @@ fn subroutine_type_metadata(
unsafe { unsafe {
llvm::LLVMRustDIBuilderCreateSubroutineType( llvm::LLVMRustDIBuilderCreateSubroutineType(
DIB(cx), DIB(cx),
unknown_file_metadata(cx),
create_DIArray(DIB(cx), &signature_metadata[..]), create_DIArray(DIB(cx), &signature_metadata[..]),
) )
}, },
@ -635,14 +634,12 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp
// anything reading the debuginfo for a recursive // anything reading the debuginfo for a recursive
// type is going to see *something* weird - the only // type is going to see *something* weird - the only
// question is what exactly it will see. // question is what exactly it will see.
let (size, align) = cx.size_and_align_of(t);
let name = "<recur_type>"; let name = "<recur_type>";
llvm::LLVMRustDIBuilderCreateBasicType( llvm::LLVMRustDIBuilderCreateBasicType(
DIB(cx), DIB(cx),
name.as_ptr().cast(), name.as_ptr().cast(),
name.len(), name.len(),
size.bits(), cx.size_of(t).bits(),
align.bits() as u32,
DW_ATE_unsigned, DW_ATE_unsigned,
) )
} }
@ -841,14 +838,12 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
_ => bug!("debuginfo::basic_type_metadata - `t` is invalid type"), _ => bug!("debuginfo::basic_type_metadata - `t` is invalid type"),
}; };
let (size, align) = cx.size_and_align_of(t);
let ty_metadata = unsafe { let ty_metadata = unsafe {
llvm::LLVMRustDIBuilderCreateBasicType( llvm::LLVMRustDIBuilderCreateBasicType(
DIB(cx), DIB(cx),
name.as_ptr().cast(), name.as_ptr().cast(),
name.len(), name.len(),
size.bits(), cx.size_of(t).bits(),
align.bits() as u32,
encoding, encoding,
) )
}; };
@ -2187,9 +2182,6 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'
name.as_ptr().cast(), name.as_ptr().cast(),
name.len(), name.len(),
actual_type_metadata, actual_type_metadata,
unknown_file_metadata(cx),
0,
0,
)) ))
}) })
} else { } else {

View file

@ -252,7 +252,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
let function_type_metadata = unsafe { let function_type_metadata = unsafe {
let fn_signature = get_function_signature(self, fn_abi); let fn_signature = get_function_signature(self, fn_abi);
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), file_metadata, fn_signature) llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), fn_signature)
}; };
// Find the enclosing function, in case this is a closure. // Find the enclosing function, in case this is a closure.
@ -265,8 +265,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
// name if necessary. // name if necessary.
let generics = self.tcx().generics_of(enclosing_fn_def_id); let generics = self.tcx().generics_of(enclosing_fn_def_id);
let substs = instance.substs.truncate_to(self.tcx(), generics); let substs = instance.substs.truncate_to(self.tcx(), generics);
let template_parameters = let template_parameters = get_template_parameters(self, &generics, substs, &mut name);
get_template_parameters(self, &generics, substs, file_metadata, &mut name);
// Get the linkage_name, which is just the symbol name // Get the linkage_name, which is just the symbol name
let linkage_name = mangled_name_of_instance(self, instance); let linkage_name = mangled_name_of_instance(self, instance);
@ -388,7 +387,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
cx: &CodegenCx<'ll, 'tcx>, cx: &CodegenCx<'ll, 'tcx>,
generics: &ty::Generics, generics: &ty::Generics,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
file_metadata: &'ll DIFile,
name_to_append_suffix_to: &mut String, name_to_append_suffix_to: &mut String,
) -> &'ll DIArray { ) -> &'ll DIArray {
if substs.types().next().is_none() { if substs.types().next().is_none() {
@ -429,9 +427,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
name.as_ptr().cast(), name.as_ptr().cast(),
name.len(), name.len(),
actual_type_metadata, actual_type_metadata,
file_metadata,
0,
0,
)) ))
}) })
} else { } else {

View file

@ -1655,7 +1655,6 @@ extern "C" {
pub fn LLVMRustDIBuilderCreateSubroutineType( pub fn LLVMRustDIBuilderCreateSubroutineType(
Builder: &DIBuilder<'a>, Builder: &DIBuilder<'a>,
File: &'a DIFile,
ParameterTypes: &'a DIArray, ParameterTypes: &'a DIArray,
) -> &'a DICompositeType; ) -> &'a DICompositeType;
@ -1682,7 +1681,6 @@ extern "C" {
Name: *const c_char, Name: *const c_char,
NameLen: size_t, NameLen: size_t,
SizeInBits: u64, SizeInBits: u64,
AlignInBits: u32,
Encoding: c_uint, Encoding: c_uint,
) -> &'a DIBasicType; ) -> &'a DIBasicType;
@ -1880,9 +1878,6 @@ extern "C" {
Name: *const c_char, Name: *const c_char,
NameLen: size_t, NameLen: size_t,
Ty: &'a DIType, Ty: &'a DIType,
File: &'a DIFile,
LineNo: c_uint,
ColumnNo: c_uint,
) -> &'a DITemplateTypeParameter; ) -> &'a DITemplateTypeParameter;
pub fn LLVMRustDIBuilderCreateNameSpace( pub fn LLVMRustDIBuilderCreateNameSpace(
@ -1948,7 +1943,6 @@ extern "C" {
Reloc: RelocModel, Reloc: RelocModel,
Level: CodeGenOptLevel, Level: CodeGenOptLevel,
UseSoftFP: bool, UseSoftFP: bool,
PositionIndependentExecutable: bool,
FunctionSections: bool, FunctionSections: bool,
DataSections: bool, DataSections: bool,
TrapUnreachable: bool, TrapUnreachable: bool,

View file

@ -445,7 +445,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
const char *TripleStr, const char *CPU, const char *Feature, const char *TripleStr, const char *CPU, const char *Feature,
const char *ABIStr, LLVMRustCodeModel RustCM, LLVMRustRelocModel RustReloc, const char *ABIStr, LLVMRustCodeModel RustCM, LLVMRustRelocModel RustReloc,
LLVMRustCodeGenOptLevel RustOptLevel, bool UseSoftFloat, LLVMRustCodeGenOptLevel RustOptLevel, bool UseSoftFloat,
bool PositionIndependentExecutable, bool FunctionSections, bool FunctionSections,
bool DataSections, bool DataSections,
bool TrapUnreachable, bool TrapUnreachable,
bool Singlethread, bool Singlethread,

View file

@ -720,7 +720,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFile(
extern "C" LLVMMetadataRef extern "C" LLVMMetadataRef
LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder, LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
LLVMMetadataRef File,
LLVMMetadataRef ParameterTypes) { LLVMMetadataRef ParameterTypes) {
return wrap(Builder->createSubroutineType( return wrap(Builder->createSubroutineType(
DITypeRefArray(unwrap<MDTuple>(ParameterTypes)))); DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
@ -755,7 +754,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateBasicType( extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateBasicType(
LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen, LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen,
uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding) { uint64_t SizeInBits, unsigned Encoding) {
return wrap(Builder->createBasicType(StringRef(Name, NameLen), SizeInBits, Encoding)); return wrap(Builder->createBasicType(StringRef(Name, NameLen), SizeInBits, Encoding));
} }
@ -964,9 +963,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter( extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
const char *Name, size_t NameLen, const char *Name, size_t NameLen, LLVMMetadataRef Ty) {
LLVMMetadataRef Ty, LLVMMetadataRef File, unsigned LineNo,
unsigned ColumnNo) {
return wrap(Builder->createTemplateTypeParameter( return wrap(Builder->createTemplateTypeParameter(
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIType>(Ty))); unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIType>(Ty)));
} }