8000 Auto merge of #130534 - workingjubilee:rollup-furaug4, r=workingjubilee · rust-lang-ci/rust@a5cf8bb · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a5cf8bb

Browse files
committed
Auto merge of rust-lang#130534 - workingjubilee:rollup-furaug4, r=workingjubilee
Rollup of 9 pull requests Successful merges: - rust-lang#97524 (Add `Thread::{into_raw, from_raw}`) - rust-lang#127988 (Do not ICE with incorrect empty suggestion) - rust-lang#129422 (Gate `repr(Rust)` correctly on non-ADT items) - rust-lang#129934 (Win: Open dir for sync access in remove_dir_all) - rust-lang#130450 (Reduce confusion about `make_indirect_byval` by renaming it) - rust-lang#130476 (Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`) - rust-lang#130487 (Update the minimum external LLVM to 18) - rust-lang#130513 (Clarify docs for std::fs::File::write) - rust-lang#130522 ([Clippy] Swap `manual_retain` to use diagnostic items instead of paths) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f79a912 + 4bd9de5 commit a5cf8bb

File tree

97 files changed

+686
-485
lines changed
  • iter/traits
  • slice
  • str
  • tests
  • proc_macro/src/bridge
  • std/src
  • src
  • tests
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    97 files changed

    +686
    -485
    lines changed

    compiler/rustc_codegen_llvm/src/abi.rs

    Lines changed: 1 addition & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -465,9 +465,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
    465465
    cx.type_array(cx.type_i8(), self.ret.layout.size.bytes()),
    466466
    );
    467467
    attributes::apply_to_llfn(llfn, llvm::AttributePlace::Argument(i), &[sret]);
    468-
    if cx.sess().opts.optimize != config::OptLevel::No
    469-
    && llvm_util::get_version() >= (18, 0, 0)
    470-
    {
    468+
    if cx.sess().opts.optimize != config::OptLevel::No {
    471469
    attributes::apply_to_llfn(
    472470
    llfn,
    473471
    llvm::AttributePlace::Argument(i),

    compiler/rustc_codegen_llvm/src/builder.rs

    Lines changed: 4 additions & 14 deletions
    Original file line numberDiff line numberDiff line change
    @@ -26,13 +26,13 @@ use smallvec::SmallVec;
    2626
    use tracing::{debug, instrument};
    2727

    2828
    use crate::abi::FnAbiLlvmExt;
    29+
    use crate::attributes;
    2930
    use crate::common::Funclet;
    3031
    use crate::context::CodegenCx;
    3132
    use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True};
    3233
    use crate::type_::Type;
    3334
    use crate::type_of::LayoutLlvmExt;
    3435
    use crate::value::Value;
    35-
    use crate::{attributes, llvm_util};
    3636

    3737
    // All Builders must have an llfn associated with them
    3838
    #[must_use]
    @@ -1311,15 +1311,9 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
    13111311
    }
    13121312

    13131313
    fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) {
    1314-
    if llvm_util::get_version() < (17, 0, 2) {
    1315-
    // Work around https://github.com/llvm/llvm-project/issues/66984.
    1316-
    let noinline = llvm::AttributeKind::NoInline.create_attr(self.llcx);
    1317-
    attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[noinline]);
    1318-
    } else {
    1319-
    // Cleanup is always the cold path.
    1320-
    let cold_inline = llvm::AttributeKind::Cold.create_attr(self.llcx);
    1321-
    attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[cold_inline]);
    1322-
    }
    1314+
    // Cleanup is always the cold path.
    1315+
    let cold_inline = llvm::AttributeKind::Cold.create_attr(self.llcx);
    1316+
    attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[cold_inline]);
    13231317
    }
    13241318
    }
    13251319

    @@ -1761,8 +1755,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
    17611755
    ) {
    17621756
    debug!("mcdc_parameters() with args ({:?}, {:?}, {:?})", fn_name, hash, bitmap_bytes);
    17631757

    1764-
    assert!(llvm_util::get_version() >= (18, 0, 0), "MCDC intrinsics require LLVM 18 or later");
    1765-
    17661758
    let llfn = unsafe { llvm::LLVMRustGetInstrProfMCDCParametersIntrinsic(self.cx().llmod) };
    17671759
    let llty = self.cx.type_func(
    17681760
    &[self.cx.type_ptr(), self.cx.type_i64(), self.cx.type_i32()],
    @@ -1796,7 +1788,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
    17961788
    "mcdc_tvbitmap_update() with args ({:?}, {:?}, {:?}, {:?}, {:?})",
    17971789
    fn_name, hash, bitmap_bytes, bitmap_index, mcdc_temp
    17981790
    );
    1799-
    assert!(llvm_util::get_version() >= (18, 0, 0), "MCDC intrinsics require LLVM 18 or later");
    18001791

    18011792
    let llfn =
    18021793
    unsafe { llvm::LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(self.cx().llmod) };
    @@ -1838,7 +1829,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
    18381829
    "mcdc_condbitmap_update() with args ({:?}, {:?}, {:?}, {:?}, {:?})",
    18391830
    fn_name, hash, cond_loc, mcdc_temp, bool_value
    18401831
    );
    1841-
    assert!(llvm_util::get_version() >= (18, 0, 0), "MCDC intrinsics require LLVM 18 or later");
    18421832
    let llfn = unsafe { llvm::LLVMRustGetInstrProfMCDCCondBitmapIntrinsic(self.cx().llmod) };
    18431833
    let llty = self.cx.type_func(
    18441834
    &[

    compiler/rustc_codegen_llvm/src/context.rs

    Lines changed: 0 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -120,14 +120,6 @@ pub(crate) unsafe fn create_module<'ll>(
    120120

    121121
    let mut target_data_layout = sess.target.data_layout.to_string();
    122122
    let llvm_version = llvm_util::get_version();
    123-
    if llvm_version < (18, 0, 0) {
    124-
    if sess.target.arch == "x86" || sess.target.arch == "x86_64" {
    125-
    // LLVM 18 adjusts i128 to be 128-bit aligned on x86 variants.
    126-
    // Earlier LLVMs leave this as default alignment, so remove it.
    127-
    // See https://reviews.llvm.org/D86310
    128-
    target_data_layout = target_data_layout.replace("-i128:128", "");
    129-
    }
    130-
    }
    131123

    132124
    if llvm_version < (19, 0, 0) {
    133125
    if sess.target.arch == "aarch64" || sess.target.arch.starts_with("arm64") {

    compiler/rustc_codegen_llvm/src/llvm_util.rs

    Lines changed: 2 additions & 23 deletions
    Original file line numberDiff line numberDiff line change
    @@ -258,28 +258,14 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
    258258
    ("aarch64", "fhm") => Some(LLVMFeature::new("fp16fml")),
    259259
    ("aarch64", "fp16") => Some(LLVMFeature::new("fullfp16")),
    260< F438 code>260
    // Filter out features that are not supported by the current LLVM version
    261-
    ("aarch64", "faminmax") if get_version().0 < 18 => None,
    262-
    ("aarch64", "fp8") if get_version().0 < 18 => None,
    263-
    ("aarch64", "fp8dot2") if get_version().0 < 18 => None,
    264-
    ("aarch64", "fp8dot4") if get_version().0 < 18 => None,
    265-
    ("aarch64", "fp8fma") if get_version().0 < 18 => None,
    266261
    ("aarch64", "fpmr") if get_version().0 != 18 => None,
    267-
    ("aarch64", "lut") if get_version().0 < 18 => None,
    268-
    ("aarch64", "sme-f8f16") if get_version().0 < 18 => None,
    269-
    ("aarch64", "sme-f8f32") if get_version().0 < 18 => None,
    270-
    ("aarch64", "sme-fa64") if get_version().0 < 18 => None,
    271-
    ("aarch64", "sme-lutv2") if get_version().0 < 18 => None,
    272-
    ("aarch64", "ssve-fp8dot2") if get_version().0 < 18 => None,
    273-
    ("aarch64", "ssve-fp8dot4") if get_version().0 < 18 => None,
    274-
    ("aarch64", "ssve-fp8fma") if get_version().0 < 18 => None,
    275-
    ("aarch64", "v9.5a") if get_version().0 < 18 => None,
    276262
    // In LLVM 18, `unaligned-scalar-mem` was merged with `unaligned-vector-mem` into a single feature called
    277263
    // `fast-unaligned-access`. In LLVM 19, it was split back out.
    278264
    ("riscv32" | "riscv64", "unaligned-scalar-mem") if get_version().0 == 18 => {
    279265
    Some(LLVMFeature::new("fast-unaligned-access"))
    280266
    }
    281-
    // For LLVM 18, enable the evex512 target feature if a avx512 target feature is enabled.
    282-
    ("x86", s) if get_version().0 >= 18 && s.starts_with("avx512") => {
    267+
    // Enable the evex512 target feature if an avx512 target feature is enabled.
    268+
    ("x86", s) if s.starts_with("avx512") => {
    283269
    Some(LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512")))
    284270
    }
    285271
    (_, s) => Some(LLVMFeature::new(s)),
    @@ -587,7 +573,6 @@ pub(crate) fn global_llvm_features(
    587573
    // -Ctarget-features
    588574
    if !only_base_features {
    589575
    let supported_features = sess.target.supported_target_features();
    590-
    let (llvm_major, _, _) = get_version();
    591576
    let mut featsmap = FxHashMap::default();
    592577

    593578
    // insert implied features
    @@ -664,12 +649,6 @@ pub(crate) fn global_llvm_features(
    664649
    return None;
    665650
    }
    666651

    667-
    // if the target-feature is "backchain" and LLVM version is greater than 18
    668-
    // then we also need to add "+backchain" to the target-features attribute.
    669-
    // otherwise, we will only add the naked `backchain` attribute to the attribute-group.
    670-
    if feature == "backchain" && llvm_major < 18 {
    671-
    return None;
    672-
    }
    673652
    // ... otherwise though we run through `to_llvm_features` when
    674653
    // passing requests down to LLVM. This means that all in-language
    675654
    // features also work on the command line instead of having two

    compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs

    Lines changed: 12 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1048,7 +1048,18 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
    10481048
    },
    10491049
    );
    10501050

    1051-
    err.span_suggestion(span, msg, "", Applicability::MaybeIncorrect);
    1051+
    if span.is_empty() {
    1052+
    // HACK: Avoid ICE when types with the same name with `derive`s are in the same scope:
    1053+
    // struct NotSM;
    1054+
    // #[derive(PartialEq, Eq)]
    1055+
    // struct NotSM<T>(T);
    1056+
    // With the above code, the suggestion would be to remove the generics of the first
    1057+
    // `NotSM`, which doesn't *have* generics, so we would suggest to remove no code with
    1058+
    // no code, which would trigger an `assert!` later. Ideally, we would do something a
    1059+
    // bit more principled. See closed PR #109082.
    1060+
    } else {
    1061+
    err.span_suggestion(span, msg, "", Applicability::MaybeIncorrect);
    1062+
    }
    10521063
    } else if redundant_lifetime_args && redundant_type_or_const_args {
    10531064
    remove_lifetime_args(err);
    10541065
    remove_type_or_const_args(err);

    compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp

    Lines changed: 0 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -196,14 +196,10 @@ extern "C" LLVMRustResult LLVMRustWriteArchive(
    196196
    }
    197197
    }
    198198

    199-
    #if LLVM_VERSION_LT(18, 0)
    200-
    auto Result = writeArchive(Dst, Members, WriteSymbtab, Kind, true, false);
    201-
    #else
    202199
    auto SymtabMode = WriteSymbtab ? SymtabWritingMode::NormalSymtab
    203200
    : SymtabWritingMode::NoSymtab;
    204201
    auto Result =
    205202
    writeArchive(Dst, Members, SymtabMode, Kind, true, false, nullptr, isEC);
    206-
    #endif
    207203
    if (!Result)
    208204
    return LLVMRustResult::Success;
    209205
    LLVMRustSetLastError(toString(std::move(Result)).c_str());

    compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp

    Lines changed: 3 additions & 10 deletions
    Original file line numberDiff line numberDiff line change
    @@ -58,17 +58,10 @@ fromRust(LLVMRustCounterMappingRegionKind Kind) {
    5858
    return coverage::CounterMappingRegion::GapRegion;
    5959
    case LLVMRustCounterMappingRegionKind::BranchRegion:
    6060
    return coverage::CounterMappingRegion::BranchRegion;
    61-
    #if LLVM_VERSION_GE(18, 0)
    6261
    case LLVMRustCounterMappingRegionKind::MCDCDecisionRegion:
    6362
    return coverage::CounterMappingRegion::MCDCDecisionRegion;
    6463
    case LLVMRustCounterMappingRegionKind::MCDCBranchRegion:
    6564
    return coverage::CounterMappingRegion::MCDCBranchRegion;
    66-
    #else
    67-
    case LLVMRustCounterMappingRegionKind::MCDCDecisionRegion:
    68-
    break;
    69-
    case LLVMRustCounterMappingRegionKind::MCDCBranchRegion:
    70-
    break;
    71-
    #endif
    7265
    }
    7366
    report_fatal_error("Bad LLVMRustCounterMappingRegionKind!");
    7467
    }
    @@ -100,7 +93,7 @@ struct LLVMRustMCDCParameters {
    10093
    // https://github.com/rust-lang/llvm-project/blob/66a2881a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L253-L263
    10194
    // and representations in 19
    10295
    // https://github.com/llvm/llvm-project/blob/843cc474faefad1d639f4c44c1cf3ad7dbda76c8/llvm/include/llvm/ProfileData/Coverage/MCDCTypes.h
    103-
    #if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
    96+
    #if LLVM_VERSION_LT(19, 0)
    10497
    static coverage::CounterMappingRegion::MCDCParameters
    10598
    fromRust(LLVMRustMCDCParameters Params) {
    10699
    auto parameter = coverage::CounterMappingRegion::MCDCParameters{};
    @@ -126,7 +119,7 @@ fromRust(LLVMRustMCDCParameters Params) {
    126119
    }
    127120
    report_fatal_error("Bad LLVMRustMCDCParametersTag!");
    128121
    }
    129-
    #elif LLVM_VERSION_GE(19, 0)
    122+
    #else
    130123
    static coverage::mcdc::Parameters fromRust(LLVMRustMCDCParameters Params) {
    131124
    switch (Params.Tag) {
    132125
    case LLVMRustMCDCParametersTag::None:
    @@ -221,7 +214,7 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
    221214
    RustMappingRegions, NumMappingRegions)) {
    222215
    MappingRegions.emplace_back(
    223216
    fromRust(Region.Count), fromRust(Region.FalseCount),
    224-
    #if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
    217+
    #if LLVM_VERSION_LT(19, 0)
    225218
    // LLVM 19 may move this argument to last.
    226219
    fromRust(Region.MCDCParameters),
    227220
    #endif

    compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

    Lines changed: 4 additions & 38 deletions
    Original file line numberDiff line numberDiff line change
    @@ -26,21 +26,19 @@
    2626
    #include "llvm/Passes/StandardInstrumentations.h"
    2727
    #include "llvm/Support/CBindingWrapping.h"
    2828
    #include "llvm/Support/FileSystem.h"
    29+
    #include "llvm/Support/TimeProfiler.h"
    2930
    #include "llvm/Support/VirtualFileSystem.h"
    3031
    #include "llvm/Target/TargetMachine.h"
    32+
    #include "llvm/TargetParser/Host.h"
    3133
    #include "llvm/Transforms/IPO/AlwaysInliner.h"
    3234
    #include "llvm/Transforms/IPO/FunctionImport.h"
    3335
    #include "llvm/Transforms/IPO/Internalize.h"
    3436
    #include "llvm/Transforms/IPO/LowerTypeTests.h"
    3537
    #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
    36-
    #include "llvm/Transforms/Utils/AddDiscriminators.h"
    37-
    #include "llvm/Transforms/Utils/FunctionImportUtils.h"
    38-
    #if LLVM_VERSION_GE(18, 0)
    39-
    #include "llvm/TargetParser/Host.h"
    40-
    #endif
    41-
    #include "llvm/Support/TimeProfiler.h"
    4238
    #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
    4339
    #include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
    40+
    #include "llvm/Transforms/Utils/AddDiscriminators.h"
    41+
    #include "llvm/Transforms/Utils/FunctionImportUtils.h"
    4442
    #if LLVM_VERSION_GE(19, 0)
    4543
    #include "llvm/Support/PGOOptions.h"
    4644
    #endif
    @@ -240,11 +238,7 @@ enum class LLVMRustCodeGenOptLevel {
    240238
    Aggressive,
    241239
    };
    242240

    243-
    #if LLVM_VERSION_GE(18, 0)
    244241
    using CodeGenOptLevelEnum = llvm::CodeGenOptLevel;
    245-
    #else
    246-
    using CodeGenOptLevelEnum = llvm::CodeGenOpt::Level;
    247-
    #endif
    248242

    249243
    static CodeGenOptLevelEnum fromRust(LLVMRustCodeGenOptLevel Level) {
    250244
    switch (Level) {
    @@ -370,29 +364,23 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
    370364
    }
    371365

    372366
    extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
    373-
    #if LLVM_VERSION_GE(18, 0)
    374367
    const TargetMachine *Target = unwrap(TM);
    375368
    const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
    376369
    const ArrayRef<SubtargetFeatureKV> FeatTable =
    377370
    MCInfo->getAllProcessorFeatures();
    378371
    return FeatTable.size();
    379-
    #else
    380-
    return 0;
    381-
    #endif
    382372
    }
    383373

    384374
    extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
    385375
    const char **Feature,
    386376
    const char **Desc) {
    387-
    #if LLVM_VERSION_GE(18, 0)
    388377
    const TargetMachine *Target = unwrap(TM);
    389378
    const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
    390379
    const ArrayRef<SubtargetFeatureKV> FeatTable =
    391380
    MCInfo->getAllProcessorFeatures();
    392381
    const SubtargetFeatureKV Feat = FeatTable[Index];
    393382
    *Feature = Feat.Key;
    394383
    *Desc = Feat.Desc;
    395-
    #endif
    396384
    }
    397385

    398386
    extern "C" const char *LLVMRustGetHostCPUName(size_t *len) {
    @@ -569,17 +557,9 @@ enum class LLVMRustFileType {
    569557
    static CodeGenFileType fromRust(LLVMRustFileType Type) {
    570558
    switch (Type) {
    571559
    case LLVMRustFileType::AssemblyFile:
    572-
    #if LLVM_VERSION_GE(18, 0)
    573560
    return CodeGenFileType::AssemblyFile;
    574-
    #else
    575-
    return CGFT_AssemblyFile;
    576-
    #endif
    577561
    case LLVMRustFileType::ObjectFile:
    578-
    #if LLVM_VERSION_GE(18, 0)
    579562
    return CodeGenFileType::ObjectFile;
    580-
    #else
    581-
    return CGFT_ObjectFile;
    582-
    #endif
    583563
    default:
    584564
    report_fatal_error("Bad FileType.");
    585565
    }
    @@ -865,11 +845,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
    865845
    // cargo run tests in multhreading mode by default
    866846
    // so use atomics for coverage counters
    867847
    Options.Atomic = true;
    868-
    #if LLVM_VERSION_GE(18, 0)
    869848
    MPM.addPass(InstrProfilingLoweringPass(Options, false));
    870-
    #else
    871-
    MPM.addPass(InstrProfiling(Options, false));
    872-
    #endif
    873849
    });
    874850
    }
    875851

    @@ -1210,19 +1186,13 @@ struct LLVMRustThinLTOData {
    12101186

    12111187
    // Not 100% sure what these are, but they impact what's internalized and
    12121188
    // what's inlined across modules, I believe.
    1213-
    #if LLVM_VERSION_GE(18, 0)
    12141189
    #if LLVM_VERSION_GE(20, 0)
    12151190
    FunctionImporter::ImportListsTy ImportLists;
    12161191
    #else
    12171192
    DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists;
    12181193
    #endif
    12191194
    DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists;
    12201195
    DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;
    1221-
    #else
    1222-
    StringMap<FunctionImporter::ImportMapTy> ImportLists;
    1223-
    StringMap<FunctionImporter::ExportSetTy> ExportLists;
    1224-
    StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries;
    1225-
    #endif
    12261196
    StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
    12271197

    12281198
    LLVMRustThinLTOData() : Index(/* HaveGVs = */ false) {}
    @@ -1274,11 +1244,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules,
    12741244

    12751245
    Ret->ModuleMap[module->identifier] = mem_buffer;
    12761246

    1277-
    #if LLVM_VERSION_GE(18, 0)
    12781247
    if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index)) {
    1279-
    #else
    1280-
    if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index, i)) {
    1281-
    #endif
    12821248
    LLVMRustSetLastError(toString(std::move(Err)).c_str());
    12831249
    return nullptr;
    12841250
    }

    0 commit comments

    Comments
     (0)
    0