Skip to content

Commit 7c5fdb0

Browse files
author
The Miri Cronjob Bot
committed
Merge ref 'b3cfb8faf84c' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: b3cfb8f Filtered ref: 8995aa7743caf019203bc853f27af6006705ae30 Upstream diff: rust-lang/rust@9385c64...b3cfb8f This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 9a1eb85 + b6f8824 commit 7c5fdb0

File tree

501 files changed

+9298
-2885
lines changed

Some content is hidden

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

501 files changed

+9298
-2885
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5152,9 +5152,9 @@ dependencies = [
51525152

51535153
[[package]]
51545154
name = "stringdex"
5155-
version = "0.0.1-alpha4"
5155+
version = "0.0.1-alpha9"
51565156
source = "registry+https://github.com/rust-lang/crates.io-index"
5157-
checksum = "2841fd43df5b1ff1b042e167068a1fe9b163dc93041eae56ab2296859013a9a0"
5157+
checksum = "7081029913fd7d591c0112182aba8c98ae886b4f12edb208130496cd17dc3c15"
51585158
dependencies = [
51595159
"stacker",
51605160
]

bootstrap.example.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,9 @@
856856
# as libstd features, this option can also be used to configure features such as optimize_for_size.
857857
#rust.std-features = ["panic_unwind"]
858858

859+
# Trigger a `DebugBreak` after an internal compiler error during bootstrap on Windows
860+
#rust.break-on-ice = true
861+
859862
# =============================================================================
860863
# Distribution options
861864
#

compiler/rustc_ast/src/token.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ pub enum CommentKind {
2222
Block,
2323
}
2424

25-
// This type must not implement `Hash` due to the unusual `PartialEq` impl below.
26-
#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable_Generic)]
25+
#[derive(Copy, Clone, PartialEq, Debug, Encodable, Decodable, HashStable_Generic)]
2726
pub enum InvisibleOrigin {
2827
// From the expansion of a metavariable in a declarative macro.
2928
MetaVar(MetaVarKind),
@@ -45,20 +44,6 @@ impl InvisibleOrigin {
4544
}
4645
}
4746

48-
impl PartialEq for InvisibleOrigin {
49-
#[inline]
50-
fn eq(&self, _other: &InvisibleOrigin) -> bool {
51-
// When we had AST-based nonterminals we couldn't compare them, and the
52-
// old `Nonterminal` type had an `eq` that always returned false,
53-
// resulting in this restriction:
54-
// https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment
55-
// This `eq` emulates that behaviour. We could consider lifting this
56-
// restriction now but there are still cases involving invisible
57-
// delimiters that make it harder than it first appears.
58-
false
59-
}
60-
}
61-
6247
/// Annoyingly similar to `NonterminalKind`, but the slight differences are important.
6348
#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)]
6449
pub enum MetaVarKind {
@@ -142,7 +127,8 @@ impl Delimiter {
142127
}
143128
}
144129

145-
// This exists because `InvisibleOrigin`s should be compared. It is only used for assertions.
130+
// This exists because `InvisibleOrigin`s should not be compared. It is only used for
131+
// assertions.
146132
pub fn eq_ignoring_invisible_origin(&self, other: &Delimiter) -> bool {
147133
match (self, other) {
148134
(Delimiter::Parenthesis, Delimiter::Parenthesis) => true,

compiler/rustc_attr_parsing/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ attr_parsing_unrecognized_repr_hint =
151151
attr_parsing_unstable_cfg_target_compact =
152152
compact `cfg(target(..))` is experimental and subject to change
153153
154-
attr_parsing_unstable_feature_bound_incompatible_stability = Item annotated with `#[unstable_feature_bound]` should not be stable
154+
attr_parsing_unstable_feature_bound_incompatible_stability = item annotated with `#[unstable_feature_bound]` should not be stable
155155
.help = If this item is meant to be stable, do not use any functions annotated with `#[unstable_feature_bound]`. Otherwise, mark this item as unstable with `#[unstable]`
156156
157157
attr_parsing_unsupported_literal_cfg_boolean =

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ use cranelift_object::{ObjectBuilder, ObjectModule};
1212
use rustc_codegen_ssa::assert_module_sources::CguReuse;
1313
use rustc_codegen_ssa::back::link::ensure_removed;
1414
use rustc_codegen_ssa::base::determine_cgu_reuse;
15-
use rustc_codegen_ssa::{
16-
CodegenResults, CompiledModule, CrateInfo, ModuleKind, errors as ssa_errors,
17-
};
15+
use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, errors as ssa_errors};
1816
use rustc_data_structures::profiling::SelfProfilerRef;
1917
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2018
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
@@ -363,7 +361,6 @@ fn emit_cgu(
363361
invocation_temp,
364362
prof,
365363
product.object,
366-
ModuleKind::Regular,
367364
name.clone(),
368365
producer,
369366
)?;
@@ -372,7 +369,6 @@ fn emit_cgu(
372369
module_regular,
373370
module_global_asm: global_asm_object_file.map(|global_asm_object_file| CompiledModule {
374371
name: format!("{name}.asm"),
375-
kind: ModuleKind::Regular,
376372
object: Some(global_asm_object_file),
377373
dwarf_object: None,
378374
bytecode: None,
@@ -389,7 +385,6 @@ fn emit_module(
389385
invocation_temp: Option<&str>,
390386
prof: &SelfProfilerRef,
391387
mut object: cranelift_object::object::write::Object<'_>,
392-
kind: ModuleKind,
393388
name: String,
394389
producer_str: &str,
395390
) -> Result<CompiledModule, String> {
@@ -430,7 +425,6 @@ fn emit_module(
430425

431426
Ok(CompiledModule {
432427
name,
433-
kind,
434428
object: Some(tmp_file),
435429
dwarf_object: None,
436430
bytecode: None,
@@ -485,7 +479,6 @@ fn reuse_workproduct_for_cgu(
485479
Ok(ModuleCodegenResult {
486480
module_regular: CompiledModule {
487481
name: cgu.name().to_string(),
488-
kind: ModuleKind::Regular,
489482
object: Some(obj_out_regular),
490483
dwarf_object: None,
491484
bytecode: None,
@@ -495,7 +488,6 @@ fn reuse_workproduct_for_cgu(
495488
},
496489
module_global_asm: source_file_global_asm.map(|source_file| CompiledModule {
497490
name: cgu.name().to_string(),
498-
kind: ModuleKind::Regular,
499491
object: Some(obj_out_global_asm),
500492
dwarf_object: None,
501493
bytecode: None,
@@ -651,7 +643,6 @@ fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
651643
tcx.sess.invocation_temp.as_deref(),
652644
&tcx.sess.prof,
653645
product.object,
654-
ModuleKind::Allocator,
655646
"allocator_shim".to_owned(),
656647
&crate::debuginfo::producer(tcx.sess),
657648
) {

compiler/rustc_codegen_gcc/src/back/lto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn fat_lto(
204204
let path = tmp_path.path().to_path_buf().join(&module.name);
205205
let path = path.to_str().expect("path");
206206
let context = &module.module_llvm.context;
207-
let config = cgcx.config(module.kind);
207+
let config = &cgcx.module_config;
208208
// NOTE: we need to set the optimization level here in order for LTO to do its job.
209209
context.set_optimization_level(to_gcc_opt_level(config.opt_level));
210210
context.add_command_line_option("-flto=auto");

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,18 @@ pub(crate) fn apply_to_callsite(callsite: &Value, idx: AttributePlace, attrs: &[
2929
}
3030

3131
/// Get LLVM attribute for the provided inline heuristic.
32-
#[inline]
33-
fn inline_attr<'ll>(cx: &CodegenCx<'ll, '_>, inline: InlineAttr) -> Option<&'ll Attribute> {
32+
pub(crate) fn inline_attr<'ll, 'tcx>(
33+
cx: &CodegenCx<'ll, 'tcx>,
34+
instance: ty::Instance<'tcx>,
35+
) -> Option<&'ll Attribute> {
36+
// `optnone` requires `noinline`
37+
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
38+
let inline = match (codegen_fn_attrs.inline, &codegen_fn_attrs.optimize) {
39+
(_, OptimizeAttr::DoNotOptimize) => InlineAttr::Never,
40+
(InlineAttr::None, _) if instance.def.requires_inline(cx.tcx) => InlineAttr::Hint,
41+
(inline, _) => inline,
42+
};
43+
3444
if !cx.tcx.sess.opts.unstable_opts.inline_llvm {
3545
// disable LLVM inlining
3646
return Some(AttributeKind::NoInline.create_attr(cx.llcx));
@@ -346,14 +356,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
346356
OptimizeAttr::Speed => {}
347357
}
348358

349-
// `optnone` requires `noinline`
350-
let inline = match (codegen_fn_attrs.inline, &codegen_fn_attrs.optimize) {
351-
(_, OptimizeAttr::DoNotOptimize) => InlineAttr::Never,
352-
(InlineAttr::None, _) if instance.def.requires_inline(cx.tcx) => InlineAttr::Hint,
353-
(inline, _) => inline,
354-
};
355-
to_add.extend(inline_attr(cx, inline));
356-
357359
if cx.sess().must_emit_unwind_tables() {
358360
to_add.push(uwtable_attr(cx.llcx, cx.sess().opts.unstable_opts.use_sync_unwind));
359361
}
@@ -488,6 +490,14 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
488490
let function_features =
489491
codegen_fn_attrs.target_features.iter().map(|f| f.name.as_str()).collect::<Vec<&str>>();
490492

493+
// Apply function attributes as per usual if there are no user defined
494+
// target features otherwise this will get applied at the callsite.
495+
if function_features.is_empty() {
496+
if let Some(inline_attr) = inline_attr(cx, instance) {
497+
to_add.push(inline_attr);
498+
}
499+
}
500+
491501
let function_features = function_features
492502
.iter()
493503
// Convert to LLVMFeatures and filter out unavailable ones
@@ -517,6 +527,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
517527
let function_features = function_features.iter().map(|s| s.as_str());
518528
let target_features: String =
519529
global_features.chain(function_features).intersperse(",").collect();
530+
520531
if !target_features.is_empty() {
521532
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features));
522533
}

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use object::{Object, ObjectSection};
1111
use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared};
1212
use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput};
1313
use rustc_codegen_ssa::traits::*;
14-
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
14+
use rustc_codegen_ssa::{ModuleCodegen, looks_like_rust_object_file};
1515
use rustc_data_structures::fx::FxHashMap;
1616
use rustc_data_structures::memmap::Mmap;
1717
use rustc_errors::DiagCtxtHandle;
@@ -43,9 +43,7 @@ fn prepare_lto(
4343
.map(|symbol| CString::new(symbol.to_owned()).unwrap())
4444
.collect::<Vec<CString>>();
4545

46-
if cgcx.regular_module_config.instrument_coverage
47-
|| cgcx.regular_module_config.pgo_gen.enabled()
48-
{
46+
if cgcx.module_config.instrument_coverage || cgcx.module_config.pgo_gen.enabled() {
4947
// These are weak symbols that point to the profile version and the
5048
// profile name, which need to be treated as exported so LTO doesn't nix
5149
// them.
@@ -55,15 +53,15 @@ fn prepare_lto(
5553
symbols_below_threshold.extend(PROFILER_WEAK_SYMBOLS.iter().map(|&sym| sym.to_owned()));
5654
}
5755

58-
if cgcx.regular_module_config.sanitizer.contains(SanitizerSet::MEMORY) {
56+
if cgcx.module_config.sanitizer.contains(SanitizerSet::MEMORY) {
5957
let mut msan_weak_symbols = Vec::new();
6058

6159
// Similar to profiling, preserve weak msan symbol during LTO.
62-
if cgcx.regular_module_config.sanitizer_recover.contains(SanitizerSet::MEMORY) {
60+
if cgcx.module_config.sanitizer_recover.contains(SanitizerSet::MEMORY) {
6361
msan_weak_symbols.push(c"__msan_keep_going");
6462
}
6563

66-
if cgcx.regular_module_config.sanitizer_memory_track_origins != 0 {
64+
if cgcx.module_config.sanitizer_memory_track_origins != 0 {
6765
msan_weak_symbols.push(c"__msan_track_origins");
6866
}
6967

@@ -227,15 +225,9 @@ fn fat_lto(
227225
// All the other modules will be serialized and reparsed into the new
228226
// context, so this hopefully avoids serializing and parsing the largest
229227
// codegen unit.
230-
//
231-
// Additionally use a regular module as the base here to ensure that various
232-
// file copy operations in the backend work correctly. The only other kind
233-
// of module here should be an allocator one, and if your crate is smaller
234-
// than the allocator module then the size doesn't really matter anyway.
235228
let costliest_module = in_memory
236229
.iter()
237230
.enumerate()
238-
.filter(|&(_, module)| module.kind == ModuleKind::Regular)
239231
.map(|(i, module)| {
240232
let cost = unsafe { llvm::LLVMRustModuleCost(module.module_llvm.llmod()) };
241233
(cost, i)
@@ -583,7 +575,7 @@ pub(crate) fn run_pass_manager(
583575
thin: bool,
584576
) {
585577
let _timer = cgcx.prof.generic_activity_with_arg("LLVM_lto_optimize", &*module.name);
586-
let config = cgcx.config(module.kind);
578+
let config = &cgcx.module_config;
587579

588580
// Now we have one massive module inside of llmod. Time to run the
589581
// LTO-specific optimization passes that LLVM provides.
@@ -745,7 +737,7 @@ pub(crate) fn optimize_thin_module(
745737
let module_llvm = ModuleLlvm::parse(cgcx, module_name, thin_module.data(), dcx);
746738
let mut module = ModuleCodegen::new_regular(thin_module.name(), module_llvm);
747739
// Given that the newly created module lacks a thinlto buffer for embedding, we need to re-add it here.
748-
if cgcx.config(ModuleKind::Regular).embed_bitcode() {
740+
if cgcx.module_config.embed_bitcode() {
749741
module.thin_lto_buffer = Some(thin_module.data().to_vec());
750742
}
751743
{

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
13921392
fn call(
13931393
&mut self,
13941394
llty: &'ll Type,
1395-
fn_attrs: Option<&CodegenFnAttrs>,
1395+
fn_call_attrs: Option<&CodegenFnAttrs>,
13961396
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
13971397
llfn: &'ll Value,
13981398
args: &[&'ll Value],
@@ -1409,10 +1409,10 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
14091409
}
14101410

14111411
// Emit CFI pointer type membership test
1412-
self.cfi_type_test(fn_attrs, fn_abi, instance, llfn);
1412+
self.cfi_type_test(fn_call_attrs, fn_abi, instance, llfn);
14131413

14141414
// Emit KCFI operand bundle
1415-
let kcfi_bundle = self.kcfi_operand_bundle(fn_attrs, fn_abi, instance, llfn);
1415+
let kcfi_bundle = self.kcfi_operand_bundle(fn_call_attrs, fn_abi, instance, llfn);
14161416
if let Some(kcfi_bundle) = kcfi_bundle.as_ref().map(|b| b.as_ref()) {
14171417
bundles.push(kcfi_bundle);
14181418
}
@@ -1429,6 +1429,29 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
14291429
c"".as_ptr(),
14301430
)
14311431
};
1432+
1433+
if let Some(instance) = instance {
1434+
// Attributes on the function definition being called
1435+
let fn_defn_attrs = self.cx.tcx.codegen_fn_attrs(instance.def_id());
1436+
if let Some(fn_call_attrs) = fn_call_attrs
1437+
&& !fn_call_attrs.target_features.is_empty()
1438+
// If there is an inline attribute and a target feature that matches
1439+
// we will add the attribute to the callsite otherwise we'll omit
1440+
// this and not add the attribute to prevent soundness issues.
1441+
&& let Some(inlining_rule) = attributes::inline_attr(&self.cx, instance)
1442+
&& self.cx.tcx.is_target_feature_call_safe(
1443+
&fn_call_attrs.target_features,
1444+
&fn_defn_attrs.target_features,
1445+
)
1446+
{
1447+
attributes::apply_to_callsite(
1448+
call,
1449+
llvm::AttributePlace::Function,
1450+
&[inlining_rule],
1451+
);
1452+
}
1453+
}
1454+
14321455
if let Some(fn_abi) = fn_abi {
14331456
fn_abi.apply_attrs_callsite(self, call);
14341457
}

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ pub(crate) unsafe fn create_module<'ll>(
217217
// LLVM 22.0 updated the default layout on avr: https://github.com/llvm/llvm-project/pull/153010
218218
target_data_layout = target_data_layout.replace("n8:16", "n8")
219219
}
220+
if sess.target.arch == "nvptx64" {
221+
// LLVM 22 updated the NVPTX layout to indicate 256-bit vector load/store: https://github.com/llvm/llvm-project/pull/155198
222+
target_data_layout = target_data_layout.replace("-i256:256", "");
223+
}
220224
}
221225

222226
// Ensure the data-layout values hardcoded remain the defaults.

0 commit comments

Comments
 (0)