Skip to content

Commit d0a48d1

Browse files
committed
rustllvm: Fix warnings about unused function parameters
1 parent 148c125 commit d0a48d1

File tree

7 files changed

+12
-47
lines changed

7 files changed

+12
-47
lines changed

src/librustc_codegen_llvm/back/write.rs

-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::back::profiling::{
66
use crate::base;
77
use crate::common;
88
use crate::consts;
9-
use crate::context::all_outputs_are_pic_executables;
109
use crate::llvm::{self, DiagnosticInfo, PassManager, SMDiagnostic};
1110
use crate::llvm_util;
1211
use crate::type_::Type;
@@ -150,7 +149,6 @@ pub fn target_machine_factory(
150149
let features = features.join(",");
151150
let features = CString::new(features).unwrap();
152151
let abi = SmallCStr::new(&sess.target.target.options.llvm_abiname);
153-
let pic_is_pie = all_outputs_are_pic_executables(sess);
154152
let trap_unreachable = sess.target.target.options.trap_unreachable;
155153
let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;
156154

@@ -174,7 +172,6 @@ pub fn target_machine_factory(
174172
reloc_model,
175173
opt_level,
176174
use_softfp,
177-
pic_is_pie,
178175
ffunction_sections,
179176
fdata_sections,
180177
trap_unreachable,

src/librustc_codegen_llvm/context.rs

+5-15
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,6 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
9797
}
9898
}
9999

100-
/// PIE is potentially more effective than PIC, but can only be used in executables.
101-
/// If all our outputs are executables, then we can relax PIC to PIE when producing object code.
102-
/// If the list of crate types is not yet known we conservatively return `false`.
103-
pub fn all_outputs_are_pic_executables(sess: &Session) -> bool {
104-
sess.relocation_model() == RelocModel::Pic
105-
&& sess
106-
.crate_types
107-
.try_get()
108-
.map_or(false, |crate_types| crate_types.iter().all(|ty| *ty == CrateType::Executable))
109-
}
110-
111100
fn strip_function_ptr_alignment(data_layout: String) -> String {
112101
// FIXME: Make this more general.
113102
data_layout.replace("-Fi8-", "-")
@@ -183,10 +172,11 @@ pub unsafe fn create_module(
183172

184173
if sess.relocation_model() == RelocModel::Pic {
185174
llvm::LLVMRustSetModulePICLevel(llmod);
186-
}
187-
188-
if all_outputs_are_pic_executables(sess) {
189-
llvm::LLVMRustSetModulePIELevel(llmod);
175+
// PIE is potentially more effective than PIC, but can only be used in executables.
176+
// If all our outputs are executables, then we can relax PIC to PIE.
177+
if sess.crate_types.get().iter().all(|ty| *ty == CrateType::Executable) {
178+
llvm::LLVMRustSetModulePIELevel(llmod);
179+
}
190180
}
191181

192182
// If skipping the PLT is enabled, we need to add some module metadata

src/librustc_codegen_llvm/debuginfo/metadata.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ fn subroutine_type_metadata(
447447
unsafe {
448448
llvm::LLVMRustDIBuilderCreateSubroutineType(
449449
DIB(cx),
450-
unknown_file_metadata(cx),
451450
create_DIArray(DIB(cx), &signature_metadata[..]),
452451
)
453452
},
@@ -635,14 +634,12 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp
635634
// anything reading the debuginfo for a recursive
636635
// type is going to see *something* weird - the only
637636
// question is what exactly it will see.
638-
let (size, align) = cx.size_and_align_of(t);
639637
let name = "<recur_type>";
640638
llvm::LLVMRustDIBuilderCreateBasicType(
641639
DIB(cx),
642640
name.as_ptr().cast(),
643641
name.len(),
644-
size.bits(),
645-
align.bits() as u32,
642+
cx.size_of(t).bits(),
646643
DW_ATE_unsigned,
647644
)
648645
}
@@ -841,14 +838,12 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
841838
_ => bug!("debuginfo::basic_type_metadata - `t` is invalid type"),
842839
};
843840

844-
let (size, align) = cx.size_and_align_of(t);
845841
let ty_metadata = unsafe {
846842
llvm::LLVMRustDIBuilderCreateBasicType(
847843
DIB(cx),
848844
name.as_ptr().cast(),
849845
name.len(),
850-
size.bits(),
851-
align.bits() as u32,
846+
cx.size_of(t).bits(),
852847
encoding,
853848
)
854849
};
@@ -2187,9 +2182,6 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'
21872182
name.as_ptr().cast(),
21882183
name.len(),
21892184
actual_type_metadata,
2190-
unknown_file_metadata(cx),
2191-
0,
2192-
0,
21932185
))
21942186
})
21952187
} else {

src/librustc_codegen_llvm/debuginfo/mod.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
252252

253253
let function_type_metadata = unsafe {
254254
let fn_signature = get_function_signature(self, fn_abi);
255-
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), file_metadata, fn_signature)
255+
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), fn_signature)
256256
};
257257

258258
// Find the enclosing function, in case this is a closure.
@@ -265,8 +265,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
265265
// name if necessary.
266266
let generics = self.tcx().generics_of(enclosing_fn_def_id);
267267
let substs = instance.substs.truncate_to(self.tcx(), generics);
268-
let template_parameters =
269-
get_template_parameters(self, &generics, substs, file_metadata, &mut name);
268+
let template_parameters = get_template_parameters(self, &generics, substs, &mut name);
270269

271270
// Get the linkage_name, which is just the symbol name
272271
let linkage_name = mangled_name_of_instance(self, instance);
@@ -388,7 +387,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
388387
cx: &CodegenCx<'ll, 'tcx>,
389388
generics: &ty::Generics,
390389
substs: SubstsRef<'tcx>,
391-
file_metadata: &'ll DIFile,
392390
name_to_append_suffix_to: &mut String,
393391
) -> &'ll DIArray {
394392
if substs.types().next().is_none() {
@@ -429,9 +427,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
429427
name.as_ptr().cast(),
430428
name.len(),
431429
actual_type_metadata,
432-
file_metadata,
433-
0,
434-
0,
435430
))
436431
})
437432
} else {

src/librustc_codegen_llvm/llvm/ffi.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,6 @@ extern "C" {
16551655

16561656
pub fn LLVMRustDIBuilderCreateSubroutineType(
16571657
Builder: &DIBuilder<'a>,
1658-
File: &'a DIFile,
16591658
ParameterTypes: &'a DIArray,
16601659
) -> &'a DICompositeType;
16611660

@@ -1682,7 +1681,6 @@ extern "C" {
16821681
Name: *const c_char,
16831682
NameLen: size_t,
16841683
SizeInBits: u64,
1685-
AlignInBits: u32,
16861684
Encoding: c_uint,
16871685
) -> &'a DIBasicType;
16881686

@@ -1880,9 +1878,6 @@ extern "C" {
18801878
Name: *const c_char,
18811879
NameLen: size_t,
18821880
Ty: &'a DIType,
1883-
File: &'a DIFile,
1884-
LineNo: c_uint,
1885-
ColumnNo: c_uint,
18861881
) -> &'a DITemplateTypeParameter;
18871882

18881883
pub fn LLVMRustDIBuilderCreateNameSpace(
@@ -1948,7 +1943,6 @@ extern "C" {
19481943
Reloc: RelocModel,
19491944
Level: CodeGenOptLevel,
19501945
UseSoftFP: bool,
1951-
PositionIndependentExecutable: bool,
19521946
FunctionSections: bool,
19531947
DataSections: bool,
19541948
TrapUnreachable: bool,

src/rustllvm/PassWrapper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
445445
const char *TripleStr, const char *CPU, const char *Feature,
446446
const char *ABIStr, LLVMRustCodeModel RustCM, LLVMRustRelocModel RustReloc,
447447
LLVMRustCodeGenOptLevel RustOptLevel, bool UseSoftFloat,
448-
bool PositionIndependentExecutable, bool FunctionSections,
448+
bool FunctionSections,
449449
bool DataSections,
450450
bool TrapUnreachable,
451451
bool Singlethread,

src/rustllvm/RustWrapper.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFile(
720720

721721
extern "C" LLVMMetadataRef
722722
LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
723-
LLVMMetadataRef File,
724723
LLVMMetadataRef ParameterTypes) {
725724
return wrap(Builder->createSubroutineType(
726725
DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
@@ -755,7 +754,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
755754

756755
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateBasicType(
757756
LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen,
758-
uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding) {
757+
uint64_t SizeInBits, unsigned Encoding) {
759758
return wrap(Builder->createBasicType(StringRef(Name, NameLen), SizeInBits, Encoding));
760759
}
761760

@@ -964,9 +963,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
964963

965964
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
966965
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
967-
const char *Name, size_t NameLen,
968-
LLVMMetadataRef Ty, LLVMMetadataRef File, unsigned LineNo,
969-
unsigned ColumnNo) {
966+
const char *Name, size_t NameLen, LLVMMetadataRef Ty) {
970967
return wrap(Builder->createTemplateTypeParameter(
971968
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIType>(Ty)));
972969
}

0 commit comments

Comments
 (0)