Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #91937

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
911736d
Mark defaulted `PartialEq`/`PartialOrd` methods as const
ecstatic-morse Nov 30, 2021
dc18d50
Test const impl of `cmp` traits
ecstatic-morse Dec 1, 2021
3011154
Revert "Set MACOSX_DEPLOYMENT_TARGET env var to default for linking i…
hkratz Dec 13, 2021
ae21dd0
Remove in_band_lifetimes
Patrick-Poitras Dec 14, 2021
b682dec
Remove `in_band_lifetimes` from `rustc_symbol_mangling`
Dec 14, 2021
1ea756b
Remove `in_band_lifetimes` from `rustc_trait_selection`
Dec 14, 2021
90aa8fb
made compiler happy
lameferret Dec 14, 2021
97e844a
fix clippy::single_char_pattern perf findings
matthiaskrgr Dec 13, 2021
a586e7d
Make suggestions from @jackh726; run fmt
Patrick-Poitras Dec 14, 2021
462bb57
Remove `in_band_lifetimes` from `rustc_codegen_llvm`
LegionMammal978 Dec 14, 2021
af27a43
Rollup merge of #91439 - ecstatic-morse:const-cmp-trait-default-metho…
matthiaskrgr Dec 14, 2021
93e6b90
Rollup merge of #91870 - rusticstuff:macosx_min_version_revert, r=Mar…
matthiaskrgr Dec 14, 2021
af11c6f
Rollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514
matthiaskrgr Dec 14, 2021
f5af398
Rollup merge of #91882 - Patrick-Poitras:remove-in-band-lifetimes-fro…
matthiaskrgr Dec 14, 2021
201f391
Rollup merge of #91901 - SylvanB:remove_in_band_lifetimes_rustc_symbo…
matthiaskrgr Dec 14, 2021
0847115
Rollup merge of #91904 - SylvanB:remove_in_band_lifetimes_rustc_trait…
matthiaskrgr Dec 14, 2021
4750924
Rollup merge of #91906 - anuvratsingh:remove_in_band_lifetimes_librar…
matthiaskrgr Dec 14, 2021
fb33c2b
Rollup merge of #91931 - LegionMammal978:less-inband-codegen_llvm, r=…
matthiaskrgr Dec 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions compiler/rustc_codegen_llvm/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ impl ArgAttributesExt for ArgAttributes {
}

pub trait LlvmType {
fn llvm_type(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type;
fn llvm_type<'ll>(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type;
}

impl LlvmType for Reg {
fn llvm_type(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type {
fn llvm_type<'ll>(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type {
match self.kind {
RegKind::Integer => cx.type_ix(self.size.bits()),
RegKind::Float => match self.size.bits() {
Expand All @@ -154,7 +154,7 @@ impl LlvmType for Reg {
}

impl LlvmType for CastTarget {
fn llvm_type(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type {
fn llvm_type<'ll>(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type {
let rest_ll_unit = self.rest.unit.llvm_type(cx);
let (rest_count, rem_bytes) = if self.rest.unit.size.bytes() == 0 {
(0, 0)
Expand Down Expand Up @@ -212,7 +212,7 @@ pub trait ArgAbiExt<'ll, 'tcx> {
);
}

impl ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
/// Gets the LLVM type for a place of the original Rust type of
/// this argument/return, i.e., the result of `type_of::type_of`.
fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
Expand Down Expand Up @@ -287,7 +287,7 @@ impl ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {

fn store_fn_arg(
&self,
bx: &mut Builder<'a, 'll, 'tcx>,
bx: &mut Builder<'_, 'll, 'tcx>,
idx: &mut usize,
dst: PlaceRef<'tcx, &'ll Value>,
) {
Expand All @@ -314,7 +314,7 @@ impl ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
}
}

impl ArgAbiMethods<'tcx> for Builder<'a, 'll, 'tcx> {
impl<'ll, 'tcx> ArgAbiMethods<'tcx> for Builder<'_, 'll, 'tcx> {
fn store_fn_arg(
&mut self,
arg_abi: &ArgAbi<'tcx, Ty<'tcx>>,
Expand All @@ -336,15 +336,15 @@ impl ArgAbiMethods<'tcx> for Builder<'a, 'll, 'tcx> {
}
}

pub trait FnAbiLlvmExt<'tcx> {
pub trait FnAbiLlvmExt<'ll, 'tcx> {
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn llvm_cconv(&self) -> llvm::CallConv;
fn apply_attrs_llfn(&self, cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value);
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value);
fn apply_attrs_callsite(&self, bx: &mut Builder<'_, 'll, 'tcx>, callsite: &'ll Value);
}

impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
// Ignore "extra" args from the call site for C variadic functions.
// Only the "fixed" args are part of the LLVM function signature.
Expand Down Expand Up @@ -505,7 +505,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
}
}

fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value) {
fn apply_attrs_callsite(&self, bx: &mut Builder<'_, 'll, 'tcx>, callsite: &'ll Value) {
if self.ret.layout.abi.is_uninhabited() {
llvm::Attribute::NoReturn.apply_callsite(llvm::AttributePlace::Function, callsite);
}
Expand Down Expand Up @@ -610,7 +610,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
}
}

impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
impl<'tcx> AbiBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
fn apply_attrs_callsite(&mut self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, callsite: Self::Value) {
fn_abi.apply_attrs_callsite(self, callsite)
}
Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use rustc_target::asm::*;
use libc::{c_char, c_uint};
use tracing::debug;

impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
fn codegen_llvm_inline_asm(
&mut self,
ia: &hir::LlvmInlineAsmInner,
Expand Down Expand Up @@ -399,7 +399,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
}
}

impl AsmMethods for CodegenCx<'ll, 'tcx> {
impl AsmMethods for CodegenCx<'_, '_> {
fn codegen_global_asm(
&self,
template: &[InlineAsmTemplatePiece],
Expand Down Expand Up @@ -447,8 +447,8 @@ impl AsmMethods for CodegenCx<'ll, 'tcx> {
}
}

pub(crate) fn inline_asm_call(
bx: &mut Builder<'a, 'll, 'tcx>,
pub(crate) fn inline_asm_call<'ll>(
bx: &mut Builder<'_, 'll, '_>,
asm: &str,
cons: &str,
inputs: &[&'ll Value],
Expand Down Expand Up @@ -583,7 +583,7 @@ fn a64_vreg_index(reg: InlineAsmReg) -> Option<u32> {
}

/// Converts a register class to an LLVM constraint code.
fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>) -> String {
fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) -> String {
match reg {
// For vector registers LLVM wants the register name to match the type size.
InlineAsmRegOrRegClass::Reg(reg) => {
Expand Down Expand Up @@ -773,7 +773,7 @@ fn modifier_to_llvm(

/// Type to use for outputs that are discarded. It doesn't really matter what
/// the type is, as long as it is valid for the constraint code.
fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll Type {
fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'ll Type {
match reg {
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => cx.type_i32(),
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg)
Expand Down Expand Up @@ -841,7 +841,7 @@ fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll

/// Helper function to get the LLVM type for a Scalar. Pointers are returned as
/// the equivalent integer type.
fn llvm_asm_scalar_type(cx: &CodegenCx<'ll, 'tcx>, scalar: Scalar) -> &'ll Type {
fn llvm_asm_scalar_type<'ll>(cx: &CodegenCx<'ll, '_>, scalar: Scalar) -> &'ll Type {
match scalar.value {
Primitive::Int(Integer::I8, _) => cx.type_i8(),
Primitive::Int(Integer::I16, _) => cx.type_i16(),
Expand All @@ -855,8 +855,8 @@ fn llvm_asm_scalar_type(cx: &CodegenCx<'ll, 'tcx>, scalar: Scalar) -> &'ll Type
}

/// Fix up an input value to work around LLVM bugs.
fn llvm_fixup_input(
bx: &mut Builder<'a, 'll, 'tcx>,
fn llvm_fixup_input<'ll, 'tcx>(
bx: &mut Builder<'_, 'll, 'tcx>,
mut value: &'ll Value,
reg: InlineAsmRegClass,
layout: &TyAndLayout<'tcx>,
Expand Down Expand Up @@ -933,8 +933,8 @@ fn llvm_fixup_input(
}

/// Fix up an output value to work around LLVM bugs.
fn llvm_fixup_output(
bx: &mut Builder<'a, 'll, 'tcx>,
fn llvm_fixup_output<'ll, 'tcx>(
bx: &mut Builder<'_, 'll, 'tcx>,
mut value: &'ll Value,
reg: InlineAsmRegClass,
layout: &TyAndLayout<'tcx>,
Expand Down Expand Up @@ -1009,7 +1009,7 @@ fn llvm_fixup_output(
}

/// Output type to use for llvm_fixup_output.
fn llvm_fixup_output_type(
fn llvm_fixup_output_type<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
reg: InlineAsmRegClass,
layout: &TyAndLayout<'tcx>,
Expand Down
30 changes: 17 additions & 13 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::value::Value;

/// Mark LLVM function to use provided inline heuristic.
#[inline]
fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
fn inline<'ll>(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
use self::InlineAttr::*;
match inline {
Hint => Attribute::InlineHint.apply_llfn(Function, val),
Expand All @@ -41,7 +41,7 @@ fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {

/// Apply LLVM sanitize attributes.
#[inline]
pub fn sanitize(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &'ll Value) {
pub fn sanitize<'ll>(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &'ll Value) {
let enabled = cx.tcx.sess.opts.debugging_opts.sanitizer - no_sanitize;
if enabled.contains(SanitizerSet::ADDRESS) {
llvm::Attribute::SanitizeAddress.apply_llfn(Function, llfn);
Expand All @@ -59,17 +59,17 @@ pub fn sanitize(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &'ll V

/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
#[inline]
pub fn emit_uwtable(val: &'ll Value, emit: bool) {
pub fn emit_uwtable(val: &Value, emit: bool) {
Attribute::UWTable.toggle_llfn(Function, val, emit);
}

/// Tell LLVM if this function should be 'naked', i.e., skip the epilogue and prologue.
#[inline]
fn naked(val: &'ll Value, is_naked: bool) {
fn naked(val: &Value, is_naked: bool) {
Attribute::Naked.toggle_llfn(Function, val, is_naked);
}

pub fn set_frame_pointer_type(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
pub fn set_frame_pointer_type<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
let mut fp = cx.sess().target.frame_pointer;
// "mcount" function relies on stack pointer.
// See <https://sourceware.org/binutils/docs/gprof/Implementation.html>.
Expand All @@ -92,7 +92,7 @@ pub fn set_frame_pointer_type(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {

/// Tell LLVM what instrument function to insert.
#[inline]
fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
fn set_instrument_function<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
if cx.sess().instrument_mcount() {
// Similar to `clang -pg` behavior. Handled by the
// `post-inline-ee-instrument` LLVM pass.
Expand All @@ -110,7 +110,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
}
}

fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
fn set_probestack<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
// Currently stack probes seem somewhat incompatible with the address
// sanitizer and thread sanitizer. With asan we're already protected from
// stack overflow anyway so we don't really need stack probes regardless.
Expand Down Expand Up @@ -161,7 +161,7 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
}
}

fn set_stackprotector(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
fn set_stackprotector<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
let sspattr = match cx.sess().stack_protector() {
StackProtector::None => return,
StackProtector::All => Attribute::StackProtectReq,
Expand All @@ -172,7 +172,7 @@ fn set_stackprotector(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
sspattr.apply_llfn(Function, llfn)
}

pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
pub fn apply_target_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
let target_cpu = SmallCStr::new(llvm_util::target_cpu(cx.tcx.sess));
llvm::AddFunctionAttrStringValue(
llfn,
Expand All @@ -182,7 +182,7 @@ pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
);
}

pub fn apply_tune_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
pub fn apply_tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
if let Some(tune) = llvm_util::tune_cpu(cx.tcx.sess) {
let tune_cpu = SmallCStr::new(tune);
llvm::AddFunctionAttrStringValue(
Expand All @@ -196,14 +196,14 @@ pub fn apply_tune_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {

/// Sets the `NonLazyBind` LLVM attribute on a given function,
/// assuming the codegen options allow skipping the PLT.
pub fn non_lazy_bind(sess: &Session, llfn: &'ll Value) {
pub fn non_lazy_bind<'ll>(sess: &Session, llfn: &'ll Value) {
// Don't generate calls through PLT if it's not necessary
if !sess.needs_plt() {
Attribute::NonLazyBind.apply_llfn(Function, llfn);
}
}

pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) {
pub(crate) fn default_optimisation_attrs<'ll>(sess: &Session, llfn: &'ll Value) {
match sess.opts.optimize {
OptLevel::Size => {
llvm::Attribute::MinSize.unapply_llfn(Function, llfn);
Expand All @@ -226,7 +226,11 @@ pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) {

/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
/// attributes.
pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::Instance<'tcx>) {
pub fn from_fn_attrs<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
llfn: &'ll Value,
instance: ty::Instance<'tcx>,
) {
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());

match codegen_fn_attrs.optimize {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ fn fat_lto(

crate struct Linker<'a>(&'a mut llvm::Linker<'a>);

impl Linker<'a> {
impl<'a> Linker<'a> {
crate fn new(llmod: &'a llvm::Module) -> Self {
unsafe { Linker(llvm::LLVMRustLinkerNew(llmod)) }
}
Expand All @@ -383,7 +383,7 @@ impl Linker<'a> {
}
}

impl Drop for Linker<'a> {
impl Drop for Linker<'_> {
fn drop(&mut self) {
unsafe {
llvm::LLVMRustLinkerFree(&mut *(self.0 as *mut _));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn llvm_err(handler: &rustc_errors::Handler, msg: &str) -> FatalError {
}
}

pub fn write_output_file(
pub fn write_output_file<'ll>(
handler: &rustc_errors::Handler,
target: &'ll llvm::TargetMachine,
pm: &llvm::PassManager<'ll>,
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_codegen_llvm/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct ValueIter<'ll> {
step: unsafe extern "C" fn(&'ll Value) -> Option<&'ll Value>,
}

impl Iterator for ValueIter<'ll> {
impl<'ll> Iterator for ValueIter<'ll> {
type Item = &'ll Value;

fn next(&mut self) -> Option<&'ll Value> {
Expand All @@ -51,14 +51,11 @@ impl Iterator for ValueIter<'ll> {
}
}

pub fn iter_globals(llmod: &'ll llvm::Module) -> ValueIter<'ll> {
pub fn iter_globals(llmod: &llvm::Module) -> ValueIter<'_> {
unsafe { ValueIter { cur: llvm::LLVMGetFirstGlobal(llmod), step: llvm::LLVMGetNextGlobal } }
}

pub fn compile_codegen_unit(
tcx: TyCtxt<'tcx>,
cgu_name: Symbol,
) -> (ModuleCodegen<ModuleLlvm>, u64) {
pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen<ModuleLlvm>, u64) {
let start_time = Instant::now();

let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx);
Expand Down
Loading