Skip to content

Commit 384f858

Browse files
committed
Auto merge of rust-lang#3793 - rust-lang:rustup-2024-08-07, r=RalfJung
Automatic Rustup
2 parents c755314 + 630ad88 commit 384f858

File tree

100 files changed

+2618
-1604
lines changed

Some content is hidden

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

100 files changed

+2618
-1604
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -646,22 +646,6 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
646646
}
647647
}
648648

649-
// This is a workaround for a LLVM bug that doesn't implicitly enable
650-
// `simd128` when `relaxed-simd` is.
651-
// See <https://github.com/llvm/llvm-project/pull/99803>, which didn't make
652-
// it into a released version of LLVM yet.
653-
//
654-
// This doesn't use the "implicit target feature" system because it is only
655-
// used for function attributes in other targets, which fixes this bug as
656-
// well on the function attribute level.
657-
if sess.target.families.contains(&"wasm".into()) {
658-
if features.iter().any(|f| f == "+relaxed-simd")
659-
&& !features.iter().any(|f| f == "+simd128")
660-
{
661-
features.push("+simd128".into());
662-
}
663-
}
664-
665649
if diagnostics && let Some(f) = check_tied_features(sess, &featsmap) {
666650
sess.dcx().emit_err(TargetFeatureDisableOrEnable {
667651
features: f,

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast::ast;
22
use rustc_attr::InstructionSetAttr;
3-
use rustc_data_structures::fx::FxIndexSet;
4-
use rustc_data_structures::unord::UnordMap;
3+
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
4+
use rustc_data_structures::unord::{ExtendUnord, UnordMap, UnordSet};
55
use rustc_errors::Applicability;
66
use rustc_hir::def::DefKind;
77
use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
@@ -30,6 +30,7 @@ pub fn from_target_feature(
3030
.emit();
3131
};
3232
let rust_features = tcx.features();
33+
let mut added_target_features = Vec::new();
3334
for item in list {
3435
// Only `enable = ...` is accepted in the meta-item list.
3536
if !item.has_name(sym::enable) {
@@ -44,7 +45,7 @@ pub fn from_target_feature(
4445
};
4546

4647
// We allow comma separation to enable multiple features.
47-
target_features.extend(value.as_str().split(',').filter_map(|feature| {
48+
added_target_features.extend(value.as_str().split(',').filter_map(|feature| {
4849
let Some(feature_gate) = supported_target_features.get(feature) else {
4950
let msg = format!("the feature named `{feature}` is not valid for this target");
5051
let mut err = tcx.dcx().struct_span_err(item.span(), msg);
@@ -98,13 +99,14 @@ pub fn from_target_feature(
9899
}));
99100
}
100101

101-
for (feature, requires) in tcx.sess.target.implicit_target_features() {
102-
if target_features.iter().any(|f| f.as_str() == *feature)
103-
&& !target_features.iter().any(|f| f.as_str() == *requires)
104-
{
105-
target_features.push(Symbol::intern(requires));
106-
}
102+
// Add both explicit and implied target features, using a set to deduplicate
103+
let mut target_features_set = UnordSet::new();
104+
for feature in added_target_features.iter() {
105+
target_features_set
106+
.extend_unord(tcx.implied_target_features(*feature).clone().into_items());
107107
}
108+
target_features_set.extend(added_target_features);
109+
target_features.extend(target_features_set.into_sorted_stable_ord())
108110
}
109111

110112
/// Computes the set of target features used in a function for the purposes of
@@ -162,6 +164,28 @@ pub(crate) fn provide(providers: &mut Providers) {
162164
.collect()
163165
}
164166
},
167+
implied_target_features: |tcx, feature| {
168+
let implied_features = tcx
169+
.sess
170+
.target
171+
.implied_target_features()
172+
.iter()
173+
.map(|(f, i)| (Symbol::intern(f), i))
174+
.collect::<FxHashMap<_, _>>();
175+
176+
// implied target features have their own implied target features, so we traverse the
177+
// map until there are no more features to add
178+
let mut features = UnordSet::new();
179+
let mut new_features = vec![feature];
180+
while let Some(new_feature) = new_features.pop() {
181+
if features.insert(new_feature) {
182+
if let Some(implied_features) = implied_features.get(&new_feature) {
183+
new_features.extend(implied_features.iter().copied().map(Symbol::intern))
184+
}
185+
}
186+
}
187+
features
188+
},
165189
asm_target_features,
166190
..*providers
167191
}

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
7373
cid.promoted.map_or_else(String::new, |p| format!("::{p:?}"))
7474
);
7575

76-
ecx.push_stack_frame(
76+
// This can't use `init_stack_frame` since `body` is not a function,
77+
// so computing its ABI would fail. It's also not worth it since there are no arguments to pass.
78+
ecx.push_stack_frame_raw(
7779
cid.instance,
7880
body,
7981
&ret.clone().into(),

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ use crate::errors::{LongRunning, LongRunningWarn};
2424
use crate::fluent_generated as fluent;
2525
use crate::interpret::{
2626
self, compile_time_machine, err_ub, throw_exhaust, throw_inval, throw_ub_custom, throw_unsup,
27-
throw_unsup_format, AllocId, AllocRange, ConstAllocation, CtfeProvenance, FnArg, FnVal, Frame,
27+
throw_unsup_format, AllocId, AllocRange, ConstAllocation, CtfeProvenance, FnArg, Frame,
2828
GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar,
29+
StackPopCleanup,
2930
};
3031

3132
/// When hitting this many interpreted terminators we emit a deny by default lint
@@ -306,17 +307,15 @@ impl<'tcx> CompileTimeInterpCx<'tcx> {
306307
let align = ImmTy::from_uint(target_align, args[1].layout).into();
307308
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty())?;
308309

309-
// We replace the entire function call with a "tail call".
310-
// Note that this happens before the frame of the original function
311-
// is pushed on the stack.
312-
self.eval_fn_call(
313-
FnVal::Instance(instance),
314-
(CallAbi::Rust, fn_abi),
310+
// Push the stack frame with our own adjusted arguments.
311+
self.init_stack_frame(
312+
instance,
313+
self.load_mir(instance.def, None)?,
314+
fn_abi,
315315
&[FnArg::Copy(addr), FnArg::Copy(align)],
316316
/* with_caller_location = */ false,
317317
dest,
318-
ret,
319-
mir::UnwindAction::Unreachable,
318+
StackPopCleanup::Goto { ret, unwind: mir::UnwindAction::Unreachable },
320319
)?;
321320
Ok(ControlFlow::Break(()))
322321
} else {

0 commit comments

Comments
 (0)