Skip to content

Commit 1b0bc59

Browse files
committed
Auto merge of #143582 - jieyouxu:rollup-8t9mhfj, r=jieyouxu
Rollup of 11 pull requests Successful merges: - #143130 (doc(std): clarify `NonZero<T>` usage limitation in doc comment) - #143415 (Get rid of build-powerpc64le-toolchain.sh) - #143464 (Make tests/ui/abi/debug.rs cross-compile) - #143482 (Fix short linker error output) - #143524 (Move `stable_mir` back to its own crate) - #143528 (interpret: rename StackPopCleanup) - #143551 (Dont resolve instance of root in `mir_callgraph_cyclic`) - #143558 (mbe: Refactors and function extractions in `compile_declarative_macro`) - #143563 (std: fix typo in `std::path`) - #143564 (compiler: Deduplicate `must_emit_unwind_tables()` comments) - #143577 (Disable download-rustc for library profile) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 25cf7d1 + 364dbd6 commit 1b0bc59

File tree

100 files changed

+2572
-1562
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

+2572
-1562
lines changed

Cargo.lock

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4553,9 +4553,6 @@ dependencies = [
45534553
"rustc_session",
45544554
"rustc_span",
45554555
"rustc_target",
4556-
"scoped-tls",
4557-
"serde",
4558-
"tracing",
45594556
]
45604557

45614558
[[package]]
@@ -5109,7 +5106,16 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
51095106
name = "stable_mir"
51105107
version = "0.1.0-preview"
51115108
dependencies = [
5109+
"rustc_abi",
5110+
"rustc_hir",
5111+
"rustc_middle",
5112+
"rustc_session",
51125113
"rustc_smir",
5114+
"rustc_span",
5115+
"rustc_target",
5116+
"scoped-tls",
5117+
"serde",
5118+
"tracing",
51135119
]
51145120

51155121
[[package]]

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
370370
};
371371
to_add.extend(inline_attr(cx, inline));
372372

373-
// The `uwtable` attribute according to LLVM is:
374-
//
375-
// This attribute indicates that the ABI being targeted requires that an
376-
// unwind table entry be produced for this function even if we can show
377-
// that no exceptions passes by it. This is normally the case for the
378-
// ELF x86-64 abi, but it can be disabled for some compilation units.
379-
//
380-
// Typically when we're compiling with `-C panic=abort` (which implies this
381-
// `no_landing_pads` check) we don't need `uwtable` because we can't
382-
// generate any exceptions! On Windows, however, exceptions include other
383-
// events such as illegal instructions, segfaults, etc. This means that on
384-
// Windows we end up still needing the `uwtable` attribute even if the `-C
385-
// panic=abort` flag is passed.
386-
//
387-
// You can also find more info on why Windows always requires uwtables here:
388-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
389373
if cx.sess().must_emit_unwind_tables() {
390374
to_add.push(uwtable_attr(cx.llcx, cx.sess().opts.unstable_opts.use_sync_unwind));
391375
}

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
457457
} else if arg.as_encoded_bytes().ends_with(b".rlib") {
458458
let rlib_path = Path::new(&arg);
459459
let dir = rlib_path.parent().unwrap();
460-
let filename = rlib_path.file_name().unwrap().to_owned();
460+
let filename = rlib_path.file_stem().unwrap().to_owned();
461461
if let Some(ArgGroup::Rlibs(parent, rlibs)) = args.last_mut() {
462462
if parent == dir {
463463
rlibs.push(filename);
@@ -471,7 +471,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
471471
args.push(ArgGroup::Regular(arg));
472472
}
473473
}
474-
let crate_hash = regex::bytes::Regex::new(r"-[0-9a-f]+\.rlib$").unwrap();
474+
let crate_hash = regex::bytes::Regex::new(r"-[0-9a-f]+").unwrap();
475475
self.command.args(args.into_iter().map(|arg_group| {
476476
match arg_group {
477477
// SAFETY: we are only matching on ASCII, not any surrogate pairs, so any replacements we do will still be valid.
@@ -494,7 +494,11 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
494494
Err(_) => false,
495495
};
496496
let mut arg = dir.into_os_string();
497-
arg.push("/{");
497+
arg.push("/");
498+
let needs_braces = rlibs.len() >= 2;
499+
if needs_braces {
500+
arg.push("{");
501+
}
498502
let mut first = true;
499503
for mut rlib in rlibs {
500504
if !first {
@@ -513,7 +517,10 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
513517
}
514518
arg.push(rlib);
515519
}
516-
arg.push("}.rlib");
520+
if needs_braces {
521+
arg.push("}");
522+
}
523+
arg.push(".rlib");
517524
arg
518525
}
519526
}

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::{CanAccessMutGlobal, CompileTimeInterpCx, CompileTimeMachine};
1919
use crate::const_eval::CheckAlignment;
2020
use crate::interpret::{
2121
CtfeValidationMode, GlobalId, Immediate, InternKind, InternResult, InterpCx, InterpErrorKind,
22-
InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, StackPopCleanup, create_static_alloc,
22+
InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, ReturnContinuation, create_static_alloc,
2323
intern_const_alloc_recursive, interp_ok, throw_exhaust,
2424
};
2525
use crate::{CTRL_C_RECEIVED, errors};
@@ -76,7 +76,7 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
7676
cid.instance,
7777
body,
7878
&ret.clone().into(),
79-
StackPopCleanup::Root { cleanup: false },
79+
ReturnContinuation::Stop { cleanup: false },
8080
)?;
8181
ecx.storage_live_for_always_live_locals()?;
8282

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use tracing::{info, instrument, trace};
1515

1616
use super::{
1717
CtfeProvenance, FnVal, ImmTy, InterpCx, InterpResult, MPlaceTy, Machine, OpTy, PlaceTy,
18-
Projectable, Provenance, ReturnAction, Scalar, StackPopCleanup, StackPopInfo, interp_ok,
18+
Projectable, Provenance, ReturnAction, ReturnContinuation, Scalar, StackPopInfo, interp_ok,
1919
throw_ub, throw_ub_custom, throw_unsup_format,
2020
};
2121
use crate::fluent_generated as fluent;
@@ -340,7 +340,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
340340
args: &[FnArg<'tcx, M::Provenance>],
341341
with_caller_location: bool,
342342
destination: &PlaceTy<'tcx, M::Provenance>,
343-
mut stack_pop: StackPopCleanup,
343+
mut cont: ReturnContinuation,
344344
) -> InterpResult<'tcx> {
345345
// Compute callee information.
346346
// FIXME: for variadic support, do we have to somehow determine callee's extra_args?
@@ -365,15 +365,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
365365

366366
if !callee_fn_abi.can_unwind {
367367
// The callee cannot unwind, so force the `Unreachable` unwind handling.
368-
match &mut stack_pop {
369-
StackPopCleanup::Root { .. } => {}
370-
StackPopCleanup::Goto { unwind, .. } => {
368+
match &mut cont {
369+
ReturnContinuation::Stop { .. } => {}
370+
ReturnContinuation::Goto { unwind, .. } => {
371371
*unwind = mir::UnwindAction::Unreachable;
372372
}
373373
}
374374
}
375375

376-
self.push_stack_frame_raw(instance, body, destination, stack_pop)?;
376+
self.push_stack_frame_raw(instance, body, destination, cont)?;
377377

378378
// If an error is raised here, pop the frame again to get an accurate backtrace.
379379
// To this end, we wrap it all in a `try` block.
@@ -617,7 +617,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
617617
&args,
618618
with_caller_location,
619619
destination,
620-
StackPopCleanup::Goto { ret: target, unwind },
620+
ReturnContinuation::Goto { ret: target, unwind },
621621
)
622622
}
623623
// `InstanceKind::Virtual` does not have callable MIR. Calls to `Virtual` instances must be
@@ -755,16 +755,16 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
755755
// Note that we are using `pop_stack_frame_raw` and not `return_from_current_stack_frame`,
756756
// as the latter "executes" the goto to the return block, but we don't want to,
757757
// only the tail called function should return to the current return block.
758-
let StackPopInfo { return_action, return_to_block, return_place } = self
759-
.pop_stack_frame_raw(false, |_this, _return_place| {
758+
let StackPopInfo { return_action, return_cont, return_place } =
759+
self.pop_stack_frame_raw(false, |_this, _return_place| {
760760
// This function's return value is just discarded, the tail-callee will fill in the return place instead.
761761
interp_ok(())
762762
})?;
763763

764764
assert_eq!(return_action, ReturnAction::Normal);
765765

766766
// Take the "stack pop cleanup" info, and use that to initiate the next call.
767-
let StackPopCleanup::Goto { ret, unwind } = return_to_block else {
767+
let ReturnContinuation::Goto { ret, unwind } = return_cont else {
768768
bug!("can't tailcall as root");
769769
};
770770

@@ -896,23 +896,23 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
896896
// Normal return, figure out where to jump.
897897
if unwinding {
898898
// Follow the unwind edge.
899-
match stack_pop_info.return_to_block {
900-
StackPopCleanup::Goto { unwind, .. } => {
899+
match stack_pop_info.return_cont {
900+
ReturnContinuation::Goto { unwind, .. } => {
901901
// This must be the very last thing that happens, since it can in fact push a new stack frame.
902902
self.unwind_to_block(unwind)
903903
}
904-
StackPopCleanup::Root { .. } => {
905-
panic!("encountered StackPopCleanup::Root when unwinding!")
904+
ReturnContinuation::Stop { .. } => {
905+
panic!("encountered ReturnContinuation::Stop when unwinding!")
906906
}
907907
}
908908
} else {
909909
// Follow the normal return edge.
910-
match stack_pop_info.return_to_block {
911-
StackPopCleanup::Goto { ret, .. } => self.return_to_block(ret),
912-
StackPopCleanup::Root { .. } => {
910+
match stack_pop_info.return_cont {
911+
ReturnContinuation::Goto { ret, .. } => self.return_to_block(ret),
912+
ReturnContinuation::Stop { .. } => {
913913
assert!(
914914
self.stack().is_empty(),
915-
"only the bottommost frame can have StackPopCleanup::Root"
915+
"only the bottommost frame can have ReturnContinuation::Stop"
916916
);
917917
interp_ok(())
918918
}

compiler/rustc_const_eval/src/interpret/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub use self::operand::{ImmTy, Immediate, OpTy};
3636
pub use self::place::{MPlaceTy, MemPlaceMeta, PlaceTy, Writeable};
3737
use self::place::{MemPlace, Place};
3838
pub use self::projection::{OffsetMode, Projectable};
39-
pub use self::stack::{Frame, FrameInfo, LocalState, StackPopCleanup, StackPopInfo};
39+
pub use self::stack::{Frame, FrameInfo, LocalState, ReturnContinuation, StackPopInfo};
4040
pub(crate) use self::util::create_static_alloc;
4141
pub use self::validity::{CtfeValidationMode, RangeSet, RefTracking};
4242
pub use self::visitor::ValueVisitor;

compiler/rustc_const_eval/src/interpret/stack.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
7272
////////////////////////////////////////////////////////////////////////////////
7373
// Return place and locals
7474
////////////////////////////////////////////////////////////////////////////////
75-
/// Work to perform when returning from this function.
76-
return_to_block: StackPopCleanup,
75+
/// Where to continue when returning from this function.
76+
return_cont: ReturnContinuation,
7777

7878
/// The location where the result of the current stack frame should be written to,
7979
/// and its layout in the caller. This place is to be interpreted relative to the
@@ -106,19 +106,19 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
106106
pub(super) loc: Either<mir::Location, Span>,
107107
}
108108

109+
/// Where and how to continue when returning/unwinding from the current function.
109110
#[derive(Clone, Copy, Eq, PartialEq, Debug)] // Miri debug-prints these
110-
pub enum StackPopCleanup {
111+
pub enum ReturnContinuation {
111112
/// Jump to the next block in the caller, or cause UB if None (that's a function
112-
/// that may never return). Also store layout of return place so
113-
/// we can validate it at that layout.
113+
/// that may never return).
114114
/// `ret` stores the block we jump to on a normal return, while `unwind`
115115
/// stores the block used for cleanup during unwinding.
116116
Goto { ret: Option<mir::BasicBlock>, unwind: mir::UnwindAction },
117-
/// The root frame of the stack: nowhere else to jump to.
117+
/// The root frame of the stack: nowhere else to jump to, so we stop.
118118
/// `cleanup` says whether locals are deallocated. Static computation
119119
/// wants them leaked to intern what they need (and just throw away
120120
/// the entire `ecx` when it is done).
121-
Root { cleanup: bool },
121+
Stop { cleanup: bool },
122122
}
123123

124124
/// Return type of [`InterpCx::pop_stack_frame_raw`].
@@ -127,8 +127,8 @@ pub struct StackPopInfo<'tcx, Prov: Provenance> {
127127
/// stack frame.
128128
pub return_action: ReturnAction,
129129

130-
/// [`return_to_block`](Frame::return_to_block) of the popped stack frame.
131-
pub return_to_block: StackPopCleanup,
130+
/// [`return_cont`](Frame::return_cont) of the popped stack frame.
131+
pub return_cont: ReturnContinuation,
132132

133133
/// [`return_place`](Frame::return_place) of the popped stack frame.
134134
pub return_place: PlaceTy<'tcx, Prov>,
@@ -255,7 +255,7 @@ impl<'tcx, Prov: Provenance> Frame<'tcx, Prov> {
255255
Frame {
256256
body: self.body,
257257
instance: self.instance,
258-
return_to_block: self.return_to_block,
258+
return_cont: self.return_cont,
259259
return_place: self.return_place,
260260
locals: self.locals,
261261
loc: self.loc,
@@ -350,20 +350,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
350350
/// the arguments or local variables.
351351
///
352352
/// The high-level version of this is `init_stack_frame`.
353-
#[instrument(skip(self, body, return_place, return_to_block), level = "debug")]
353+
#[instrument(skip(self, body, return_place, return_cont), level = "debug")]
354354
pub(crate) fn push_stack_frame_raw(
355355
&mut self,
356356
instance: ty::Instance<'tcx>,
357357
body: &'tcx mir::Body<'tcx>,
358358
return_place: &PlaceTy<'tcx, M::Provenance>,
359-
return_to_block: StackPopCleanup,
359+
return_cont: ReturnContinuation,
360360
) -> InterpResult<'tcx> {
361361
trace!("body: {:#?}", body);
362362

363363
// We can push a `Root` frame if and only if the stack is empty.
364364
debug_assert_eq!(
365365
self.stack().is_empty(),
366-
matches!(return_to_block, StackPopCleanup::Root { .. })
366+
matches!(return_cont, ReturnContinuation::Stop { .. })
367367
);
368368

369369
// First push a stack frame so we have access to `instantiate_from_current_frame` and other
@@ -373,7 +373,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
373373
let pre_frame = Frame {
374374
body,
375375
loc: Right(body.span), // Span used for errors caused during preamble.
376-
return_to_block,
376+
return_cont,
377377
return_place: return_place.clone(),
378378
locals,
379379
instance,
@@ -429,15 +429,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
429429
copy_ret_val(self, &frame.return_place)?;
430430
}
431431

432-
let return_to_block = frame.return_to_block;
432+
let return_cont = frame.return_cont;
433433
let return_place = frame.return_place.clone();
434434

435435
// Cleanup: deallocate locals.
436436
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
437437
// We do this while the frame is still on the stack, so errors point to the callee.
438-
let cleanup = match return_to_block {
439-
StackPopCleanup::Goto { .. } => true,
440-
StackPopCleanup::Root { cleanup, .. } => cleanup,
438+
let cleanup = match return_cont {
439+
ReturnContinuation::Goto { .. } => true,
440+
ReturnContinuation::Stop { cleanup, .. } => cleanup,
441441
};
442442

443443
let return_action = if cleanup {
@@ -455,7 +455,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
455455
ReturnAction::NoCleanup
456456
};
457457

458-
interp_ok(StackPopInfo { return_action, return_to_block, return_place })
458+
interp_ok(StackPopInfo { return_action, return_cont, return_place })
459459
}
460460

461461
/// In the current stack frame, mark all locals as live that are not arguments and don't have

0 commit comments

Comments
 (0)