Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3c6c901
move batch
zedddie Jun 1, 2026
01f5cc8
bless batch
zedddie Jun 1, 2026
7092ebf
Integrate `field_names` inside `field_tys`.
cjgillot May 24, 2026
c8ce74a
Simplify `compute_layout`.
cjgillot Jun 2, 2026
2a2e4c9
Split coroutine layout computation to its own file.
cjgillot May 31, 2026
62690a6
Move coroutine.rs to be a mod.rs
cjgillot May 31, 2026
e3468ae
Promotes 5 Thumb-mode bare-metal Arm targets to Tier 2
cezarbbb Jun 2, 2026
ac63a3e
Pacify doc-checker.
cjgillot Jun 2, 2026
9b7623a
Remove -Zemscripten-wasm-eh
bjorn3 May 25, 2026
3a850de
bootstrap: enable `clippy::mem_replace_with_default`
JarlEvanson Jun 2, 2026
3dacac8
compiler: fix `clippy::mem_replace_with_default` warnings
JarlEvanson Jun 2, 2026
c2b9f39
windows: remove division-by-zero checks for performance counters
mathisbot Jun 2, 2026
b6a204f
Rewrite target checking for `#[link]`
JonathanBrouwer Jun 2, 2026
d8698f5
Add a test for `#[link]` on macro calls
JonathanBrouwer Jun 2, 2026
3a552e7
Rollup merge of #155763 - cezarbbb:promote-thumb-to-tier2, r=petroche…
jhpratt Jun 3, 2026
5f81fe9
Rollup merge of #156928 - bjorn3:emscripten_always_wasm_eh, r=TaKO8Ki
jhpratt Jun 3, 2026
33d981a
Rollup merge of #157236 - zedddie:gsoc-batch-3-meow, r=Kivooeo
jhpratt Jun 3, 2026
7e3cec9
Rollup merge of #157294 - cjgillot:split-coroutine-layout, r=oli-obk
jhpratt Jun 3, 2026
ba936e7
Rollup merge of #157328 - mathisbot:opt-std-windows-time, r=ChrisDenton
jhpratt Jun 3, 2026
200201f
Rollup merge of #157331 - JonathanBrouwer:target-link, r=mejrs
jhpratt Jun 3, 2026
025c0a0
Rollup merge of #157336 - JarlEvanson:mem-replace-with-default, r=Jon…
jhpratt Jun 3, 2026
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
3 changes: 2 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/link_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ impl CombineAttributeParser for LinkParser {
r#"name = "...", import_name_type = "decorated|noprefix|undecorated""#,
r#"name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated""#,
], "https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute");
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS); //FIXME Still checked fully in `check_attr.rs`
const ALLOWED_TARGETS: AllowedTargets =
AllowedTargets::AllowListWarnRest(&[Allow(Target::ForeignMod)]);
const STABILITY: AttributeStability = AttributeStability::Stable;

fn extend(
Expand Down
20 changes: 0 additions & 20 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use rustc_session::config::{
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, FunctionReturn, PAuthKey, PacRet,
};
use rustc_span::{DUMMY_SP, Span, Spanned, Symbol, sym};
use rustc_symbol_mangling::mangle_internal_symbol;
use rustc_target::spec::{
Arch, CfgAbi, Env, FramePointer, HasTargetSpec, Os, RelocModel, SmallDataThresholdSupport,
Target, TlsModel,
Expand Down Expand Up @@ -136,7 +135,6 @@ pub(crate) struct FullCx<'ll, 'tcx> {
pub dbg_cx: Option<debuginfo::CodegenUnitDebugContext<'ll, 'tcx>>,

eh_personality: Cell<Option<&'ll Value>>,
eh_catch_typeinfo: Cell<Option<&'ll Value>>,
pub rust_try_fn: Cell<Option<(&'ll Type, &'ll Value)>>,

intrinsics:
Expand Down Expand Up @@ -672,7 +670,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
coverage_cx,
dbg_cx,
eh_personality: Cell::new(None),
eh_catch_typeinfo: Cell::new(None),
rust_try_fn: Cell::new(None),
intrinsics: Default::default(),
local_gen_sym_counter: Cell::new(0),
Expand Down Expand Up @@ -1042,23 +1039,6 @@ impl<'ll> CodegenCx<'ll, '_> {
}
}
}

pub(crate) fn eh_catch_typeinfo(&self) -> &'ll Value {
if let Some(eh_catch_typeinfo) = self.eh_catch_typeinfo.get() {
return eh_catch_typeinfo;
}
let tcx = self.tcx;
assert!(self.sess().target.os == Os::Emscripten);
let eh_catch_typeinfo = match tcx.lang_items().eh_catch_typeinfo() {
Some(def_id) => self.get_static(def_id),
_ => {
let ty = self.type_struct(&[self.type_ptr(), self.type_ptr()], false);
self.declare_global(&mangle_internal_symbol(self.tcx, "rust_eh_catch_typeinfo"), ty)
}
};
self.eh_catch_typeinfo.set(Some(eh_catch_typeinfo));
eh_catch_typeinfo
}
}

impl CodegenCx<'_, '_> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
.map(|field_index| {
let coroutine_saved_local = coroutine_layout.variant_fields[variant_index]
[FieldIdx::from_usize(field_index)];
let field_name_maybe = coroutine_layout.field_names[coroutine_saved_local];
let field_name_maybe =
coroutine_layout.field_tys[coroutine_saved_local].debuginfo_name;
let field_name = field_name_maybe
.as_ref()
.map(|s| Cow::from(s.as_str()))
Expand Down
85 changes: 1 addition & 84 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rustc_session::lint::builtin::DEPRECATED_LLVM_INTRINSIC;
use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};
use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate};
use rustc_target::callconv::PassMode;
use rustc_target::spec::{Arch, Os};
use rustc_target::spec::Arch;
use tracing::debug;

use crate::abi::FnAbiLlvmExt;
Expand Down Expand Up @@ -1356,8 +1356,6 @@ fn catch_unwind_intrinsic<'ll, 'tcx>(
codegen_msvc_try(bx, try_func, data, catch_func)
} else if wants_wasm_eh(bx.sess()) {
codegen_wasm_try(bx, try_func, data, catch_func)
} else if bx.sess().target.os == Os::Emscripten {
codegen_emcc_try(bx, try_func, data, catch_func)
} else {
codegen_gnu_try(bx, try_func, data, catch_func)
}
Expand Down Expand Up @@ -1654,87 +1652,6 @@ fn codegen_gnu_try<'ll, 'tcx>(
ret
}

// Variant of codegen_gnu_try used for emscripten where Rust panics are
// implemented using C++ exceptions. Here we use exceptions of a specific type
// (`struct rust_panic`) to represent Rust panics.
fn codegen_emcc_try<'ll, 'tcx>(
bx: &mut Builder<'_, 'll, 'tcx>,
try_func: &'ll Value,
data: &'ll Value,
catch_func: &'ll Value,
) -> &'ll Value {
let (llty, llfn) = get_rust_try_fn(bx, &mut |mut bx| {
// Codegens the shims described above:
//
// bx:
// invoke %try_func(%data) normal %normal unwind %catch
//
// normal:
// ret 0
//
// catch:
// (%ptr, %selector) = landingpad
// %rust_typeid = @llvm.eh.typeid.for(@_ZTI10rust_panic)
// %is_rust_panic = %selector == %rust_typeid
// %catch_data = alloca { i8*, i8 }
// %catch_data[0] = %ptr
// %catch_data[1] = %is_rust_panic
// call %catch_func(%data, %catch_data)
// ret 1
let then = bx.append_sibling_block("then");
let catch = bx.append_sibling_block("catch");

let try_func = llvm::get_param(bx.llfn(), 0);
let data = llvm::get_param(bx.llfn(), 1);
let catch_func = llvm::get_param(bx.llfn(), 2);
let try_func_ty = bx.type_func(&[bx.type_ptr()], bx.type_void());
bx.invoke(try_func_ty, None, None, try_func, &[data], then, catch, None, None);

bx.switch_to_block(then);
bx.ret(bx.const_bool(false));

// Type indicator for the exception being thrown.
//
// The first value in this tuple is a pointer to the exception object
// being thrown. The second value is a "selector" indicating which of
// the landing pad clauses the exception's type had been matched to.
bx.switch_to_block(catch);
let tydesc = bx.eh_catch_typeinfo();
let lpad_ty = bx.type_struct(&[bx.type_ptr(), bx.type_i32()], false);
let vals = bx.landing_pad(lpad_ty, bx.eh_personality(), 2);
bx.add_clause(vals, tydesc);
bx.add_clause(vals, bx.const_null(bx.type_ptr()));
let ptr = bx.extract_value(vals, 0);
let selector = bx.extract_value(vals, 1);

// Check if the typeid we got is the one for a Rust panic.
let rust_typeid = bx.call_intrinsic("llvm.eh.typeid.for", &[bx.val_ty(tydesc)], &[tydesc]);
let is_rust_panic = bx.icmp(IntPredicate::IntEQ, selector, rust_typeid);
let is_rust_panic = bx.zext(is_rust_panic, bx.type_bool());

// We need to pass two values to catch_func (ptr and is_rust_panic), so
// create an alloca and pass a pointer to that.
let ptr_size = bx.tcx().data_layout.pointer_size();
let ptr_align = bx.tcx().data_layout.pointer_align().abi;
let i8_align = bx.tcx().data_layout.i8_align;
// Required in order for there to be no padding between the fields.
assert!(i8_align <= ptr_align);
let catch_data = bx.alloca(2 * ptr_size, ptr_align);
bx.store(ptr, catch_data, ptr_align);
let catch_data_1 = bx.inbounds_ptradd(catch_data, bx.const_usize(ptr_size.bytes()));
bx.store(is_rust_panic, catch_data_1, i8_align);

let catch_ty = bx.type_func(&[bx.type_ptr(), bx.type_ptr()], bx.type_void());
bx.call(catch_ty, None, None, catch_func, &[data, catch_data], None, None);
bx.ret(bx.const_bool(true));
});

// Note that no invoke is used here because by definition this function
// can't panic (that's what it's catching).
let ret = bx.call(llty, None, None, llfn, &[try_func, data, catch_func], None, None);
ret
}

// Helper function to give a Block to a closure to codegen a shim function.
// This is currently primarily used for the `try` intrinsic functions above.
fn gen_fn<'a, 'll, 'tcx>(
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ unsafe fn configure_llvm(sess: &Session) {
add("-wasm-enable-eh", false);
}

if sess.target.os == Os::Emscripten
&& !sess.opts.unstable_opts.emscripten_wasm_eh
&& sess.panic_strategy().unwinds()
{
add("-enable-emscripten-cxx-exceptions", false);
}

// HACK(eddyb) LLVM inserts `llvm.assume` calls to preserve align attributes
// during inlining. Unfortunately these may block other optimizations.
add("-preserve-alignment-assumptions-during-inlining=false", false);
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_codegen_llvm/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
}
}
impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
pub(crate) fn type_bool(&self) -> &'ll Type {
self.type_i8()
}

pub(crate) fn type_int_from_ty(&self, t: ty::IntTy) -> &'ll Type {
match t {
ty::IntTy::Isize => self.type_isize(),
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2774,13 +2774,7 @@ fn add_order_independent_options(
}

if sess.target.os == Os::Emscripten {
cmd.cc_arg(if sess.opts.unstable_opts.emscripten_wasm_eh {
"-fwasm-exceptions"
} else if sess.panic_strategy().unwinds() {
"-sDISABLE_EXCEPTION_CATCHING=0"
} else {
"-sDISABLE_EXCEPTION_CATCHING=1"
});
cmd.cc_arg("-fwasm-exceptions");
}

if flavor == LinkerFlavor::Llbc {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ impl Emitter for SharedEmitter {
assert_eq!(diag.is_lint, None);
// No sensible check for `diag.emitted_at`.

let args = mem::replace(&mut diag.args, DiagArgMap::default());
let args = mem::take(&mut diag.args);
drop(
self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
span: diag.span.primary_spans().iter().map(|span| span.data()).collect::<Vec<_>>(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ pub(crate) fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// us
pub fn wants_wasm_eh(sess: &Session) -> bool {
sess.target.is_like_wasm
&& (sess.target.os != Os::Emscripten || sess.opts.unstable_opts.emscripten_wasm_eh)
}

/// Returns `true` if this session's target will use SEH-based unwinding.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const GATED_CFGS: &[GatedCfg] = &[
(sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
// this is consistent with naming of the compiler flag it's for
(sym::fmt_debug, sym::fmt_debug, Features::fmt_debug),
(sym::emscripten_wasm_eh, sym::cfg_emscripten_wasm_eh, Features::cfg_emscripten_wasm_eh),
(
sym::target_has_reliable_f16,
sym::cfg_target_has_reliable_f16_f128,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ declare_features! (
(internal, allow_internal_unstable, "1.0.0", None),
/// Allows using anonymous lifetimes in argument-position impl-trait.
(unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None),
/// Allows access to the emscripten_wasm_eh config, used by panic_unwind and unwind
(internal, cfg_emscripten_wasm_eh, "1.86.0", None),
/// Allows checking whether or not the backend correctly supports unstable float types.
(internal, cfg_target_has_reliable_f16_f128, "1.88.0", None),
/// Allows identifying the `compiler_builtins` crate.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ language_item_table! {
Start, sym::start, start_fn, Target::Fn, GenericRequirement::Exact(1);

EhPersonality, sym::eh_personality, eh_personality, Target::Fn, GenericRequirement::None;
EhCatchTypeinfo, sym::eh_catch_typeinfo, eh_catch_typeinfo, Target::Static, GenericRequirement::None;

// Profiling markers for move/copy operations (used by -Z annotate-moves)
CompilerMove, sym::compiler_move, compiler_move_fn, Target::Fn, GenericRequirement::Exact(2);
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ macro_rules! weak_lang_items {
weak_lang_items! {
PanicImpl, rust_begin_unwind;
EhPersonality, rust_eh_personality;
EhCatchTypeinfo, rust_eh_catch_typeinfo;
}
1 change: 0 additions & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(dwarf_version, Some(5));
tracked!(embed_metadata, false);
tracked!(embed_source, true);
tracked!(emscripten_wasm_eh, false);
tracked!(export_executable_symbols, true);
tracked!(fewer_names, Some(true));
tracked!(fixed_x18, true);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/dep_graph/serialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ impl EncoderState {
// Prevent more indices from being allocated on this thread.
local.remaining_node_index = 0;

let data = mem::replace(&mut local.encoder.data, Vec::new());
let data = mem::take(&mut local.encoder.data);
self.file.lock().as_mut().unwrap().emit_raw_bytes(&data);

LocalEncoderResult {
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_middle/src/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ impl<'tcx> TyCtxt<'tcx> {
/// the case of panic=abort. In these situations some lang items are injected by
/// crates and don't actually need to be defined in libstd.
pub fn required(tcx: TyCtxt<'_>, lang_item: LangItem) -> bool {
// If we're not compiling with unwinding, we won't actually need these
// symbols. Other panic runtimes ensure that the relevant symbols are
// If we're not compiling with unwinding, we won't actually need this
// symbol. Other panic runtimes ensure that the relevant symbols are
// available to link things together, but they're never exercised.
match tcx.sess.panic_strategy() {
PanicStrategy::Abort => {
lang_item != LangItem::EhPersonality && lang_item != LangItem::EhCatchTypeinfo
}
PanicStrategy::Abort => lang_item != LangItem::EhPersonality,
PanicStrategy::Unwind => true,
PanicStrategy::ImmediateAbort => false,
}
Expand Down
17 changes: 6 additions & 11 deletions compiler/rustc_middle/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ fn write_scope_tree(

// Coroutine debuginfo.
if let Some(layout) = body.coroutine_layout_raw() {
for (field, name) in layout.field_names.iter_enumerated() {
let source_info = layout.field_tys[field].source_info;
if let Some(name) = name
for (field, field_decl) in layout.field_tys.iter_enumerated() {
let source_info = field_decl.source_info;
if let Some(name) = field_decl.debuginfo_name
&& source_info.scope == parent
{
let indented_debug_info =
Expand Down Expand Up @@ -559,17 +559,12 @@ fn write_coroutine_layout<'tcx>(
w: &mut dyn io::Write,
options: PrettyPrintMirOptions,
) -> io::Result<()> {
let CoroutineLayout {
field_tys,
field_names: _, // Dumped in scope tree with debug info.
variant_fields,
variant_source_info,
storage_conflicts,
} = layout;
let CoroutineLayout { field_tys, variant_fields, variant_source_info, storage_conflicts } =
layout;

writeln!(w, "{INDENT}coroutine layout {{")?;

for (field, CoroutineSavedTy { ty, source_info, ignore_for_traits }) in
for (field, CoroutineSavedTy { ty, source_info, ignore_for_traits, debuginfo_name: _ }) in
field_tys.iter_enumerated()
{
let ignore_for_traits = if *ignore_for_traits { " (ignored for traits)" } else { "" };
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_middle/src/mir/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub struct CoroutineSavedTy<'tcx> {
pub source_info: SourceInfo,
/// Whether the local should be ignored for trait bound computations.
pub ignore_for_traits: bool,
/// The name for debuginfo.
pub debuginfo_name: Option<Symbol>,
}

/// The layout of coroutine state.
Expand All @@ -36,9 +38,6 @@ pub struct CoroutineLayout<'tcx> {
/// The type of every local stored inside the coroutine.
pub field_tys: IndexVec<CoroutineSavedLocal, CoroutineSavedTy<'tcx>>,

/// The name for debuginfo.
pub field_names: IndexVec<CoroutineSavedLocal, Option<Symbol>>,

/// Which of the above fields are in each variant. Note that one field may
/// be stored in multiple variants.
pub variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, CoroutineSavedLocal>>,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,6 @@ impl<'tcx> TyCtxt<'tcx> {
iter::repeat(source_info).take(CoroutineArgs::RESERVED_VARIANTS).collect();
let proxy_layout = CoroutineLayout {
field_tys: [].into(),
field_names: [].into(),
variant_fields,
variant_source_info,
storage_conflicts: BitMatrix::new(0, 0),
Expand Down
Loading
Loading