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
ec1b2fa
Gracefully handle in case we cannot run the compiler in doctests
GuillaumeGomez Oct 20, 2025
5d0011c
Add regression test when unable to run compiler in doctest
GuillaumeGomez Oct 20, 2025
e207006
Add default sanitizers to TargetOptions
ilovepi Sep 25, 2025
3e8a433
Add -Zannotate-moves for profiler visibility of move/copy operations
jsgf Oct 13, 2025
71e2e0c
Minor fixes to StdNonZeroNumberProvider for gdb
tromey Nov 5, 2025
d2b021c
Add num_children method to some gdb pretty-printers
tromey Nov 5, 2025
2c3c82c
Add new `run_make_support::CompletedProcess::assert_ice` method
GuillaumeGomez Nov 3, 2025
32372bf
Update tests for wasm32
jsgf Nov 5, 2025
0717a39
Fix broken qemu-cskyv2 link
ehuss Nov 5, 2025
dcc11ac
extract s390x `vector` and friends to their own rust feature
folkertdev Aug 20, 2025
131b893
`std_detect`: remove unneeded stability lines from s390x features macro
folkertdev Aug 20, 2025
0965df7
`std_detect`: give s390x features more accurate features / tracking i…
folkertdev Aug 20, 2025
7851102
stabilize `stdarch_s390x_feature_detection`
folkertdev Aug 20, 2025
b32c425
stabilize `s390x_target_feature_vector`
folkertdev Aug 20, 2025
48517d4
Rollup merge of #145656 - folkertdev:stabilize-s390x-vector, r=Amanieu
Zalathar Nov 6, 2025
d929a3f
Rollup merge of #147043 - ilovepi:default-sanitizers, r=petrochenkov
Zalathar Nov 6, 2025
86504a8
Rollup merge of #147803 - jsgf:move-copy-codegen, r=madsmtm,saethlin
Zalathar Nov 6, 2025
d103bc4
Rollup merge of #147912 - GuillaumeGomez:graceful-doctest-error-handl…
Zalathar Nov 6, 2025
c49551a
Rollup merge of #148540 - tromey:non-zero-gdb-cleanup, r=bjorn3
Zalathar Nov 6, 2025
cffc0bb
Rollup merge of #148541 - tromey:add-num-children, r=bjorn3
Zalathar Nov 6, 2025
932e002
Rollup merge of #148549 - ehuss:fix-csky-link, r=Kivooeo
Zalathar Nov 6, 2025
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
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
OperandValue::Ref(place.val)
};

OperandRef { val, layout: place.layout }
OperandRef { val, layout: place.layout, move_annotation: None }
}

fn write_operand_repeatedly(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::context::CodegenCx;
pub(super) const UNKNOWN_LINE_NUMBER: u32 = 0;
pub(super) const UNKNOWN_COLUMN_NUMBER: u32 = 0;

impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
// FIXME(eddyb) find a common convention for all of the debuginfo-related
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
fn dbg_var_addr(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn get_attrs<'ll>(this: &ArgAttributes, cx: &CodegenCx<'ll, '_>) -> SmallVec<[&'
}
}
}
} else if cx.tcx.sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::MEMORY) {
} else if cx.tcx.sess.sanitizers().contains(SanitizerSet::MEMORY) {
// If we're not optimising, *but* memory sanitizer is on, emit noundef, since it affects
// memory sanitizer's behavior.

Expand Down Expand Up @@ -253,7 +253,7 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
);
bx.lifetime_end(llscratch, scratch_size);
}
_ => {
PassMode::Pair(..) | PassMode::Direct { .. } => {
OperandRef::from_immediate_or_packed_pair(bx, val, self.layout).val.store(bx, dst);
}
}
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(crate) fn sanitize_attrs<'ll, 'tcx>(
no_sanitize: SanitizerSet,
) -> SmallVec<[&'ll Attribute; 4]> {
let mut attrs = SmallVec::new();
let enabled = tcx.sess.opts.unstable_opts.sanitizer - no_sanitize;
let enabled = tcx.sess.sanitizers() - no_sanitize;
if enabled.contains(SanitizerSet::ADDRESS) || enabled.contains(SanitizerSet::KERNELADDRESS) {
attrs.push(llvm::AttributeKind::SanitizeAddress.create_attr(cx.llcx));
}
Expand Down Expand Up @@ -240,13 +240,7 @@ fn probestack_attr<'ll, 'tcx>(cx: &SimpleCx<'ll>, tcx: TyCtxt<'tcx>) -> Option<&
// Currently stack probes seem somewhat incompatible with the address
// sanitizer and thread sanitizer. With asan we're already protected from
// stack overflow anyway so we don't really need stack probes regardless.
if tcx
.sess
.opts
.unstable_opts
.sanitizer
.intersects(SanitizerSet::ADDRESS | SanitizerSet::THREAD)
{
if tcx.sess.sanitizers().intersects(SanitizerSet::ADDRESS | SanitizerSet::THREAD) {
return None;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
OperandValue::Ref(place.val)
};

OperandRef { val, layout: place.layout }
OperandRef { val, layout: place.layout, move_annotation: None }
}

fn write_operand_repeatedly(
Expand Down
53 changes: 52 additions & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<'ll> Builder<'_, 'll, '_> {
}
}

impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
impl<'ll, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
// FIXME(eddyb) find a common convention for all of the debuginfo-related
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
fn dbg_var_addr(
Expand Down Expand Up @@ -284,6 +284,57 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
llvm::set_value_name(value, name.as_bytes());
}
}

/// Annotate move/copy operations with debug info for profiling.
///
/// This creates a temporary debug scope that makes the move/copy appear as an inlined call to
/// `compiler_move<T, SIZE>()` or `compiler_copy<T, SIZE>()`. The provided closure is executed
/// with this temporary debug location active.
///
/// The `instance` parameter should be the monomorphized instance of the `compiler_move` or
/// `compiler_copy` function with the actual type and size.
fn with_move_annotation<R>(
&mut self,
instance: ty::Instance<'tcx>,
f: impl FnOnce(&mut Self) -> R,
) -> R {
// Save the current debug location
let saved_loc = self.get_dbg_loc();

// Create a DIScope for the compiler_move/compiler_copy function
// We use the function's FnAbi for debug info generation
let fn_abi = self
.cx()
.tcx
.fn_abi_of_instance(
self.cx().typing_env().as_query_input((instance, ty::List::empty())),
)
.unwrap();

let di_scope = self.cx().dbg_scope_fn(instance, fn_abi, None);

// Create an inlined debug location:
// - scope: the compiler_move/compiler_copy function
// - inlined_at: the current location (where the move/copy actually occurs)
// - span: use the function's definition span
let fn_span = self.cx().tcx.def_span(instance.def_id());
let inlined_loc = self.cx().dbg_loc(di_scope, saved_loc, fn_span);

// Set the temporary debug location
self.set_dbg_loc(inlined_loc);

// Execute the closure (which will generate the memcpy)
let result = f(self);

// Restore the original debug location
if let Some(loc) = saved_loc {
self.set_dbg_loc(loc);
} else {
self.clear_dbg_loc();
}

result
}
}

/// A source code location used to generate debug information.
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ fn add_sanitizer_libraries(
return;
}

let sanitizer = sess.opts.unstable_opts.sanitizer;
let sanitizer = sess.sanitizers();
if sanitizer.contains(SanitizerSet::ADDRESS) {
link_sanitizer_runtime(sess, flavor, linker, "asan");
}
Expand Down Expand Up @@ -2497,11 +2497,7 @@ fn add_order_independent_options(
&& crate_type == CrateType::Executable
&& !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))
{
let prefix = if sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::ADDRESS) {
"asan/"
} else {
""
};
let prefix = if sess.sanitizers().contains(SanitizerSet::ADDRESS) { "asan/" } else { "" };
cmd.link_arg(format!("--dynamic-linker={prefix}ld.so.1"));
}

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 @@ -176,7 +176,7 @@ impl ModuleConfig {
debug_info_for_profiling: sess.opts.unstable_opts.debug_info_for_profiling,
instrument_coverage: if_regular!(sess.instrument_coverage(), false),

sanitizer: if_regular!(sess.opts.unstable_opts.sanitizer, SanitizerSet::empty()),
sanitizer: if_regular!(sess.sanitizers(), SanitizerSet::empty()),
sanitizer_dataflow_abilist: if_regular!(
sess.opts.unstable_opts.sanitizer_dataflow_abilist.clone(),
Vec::new()
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let op = match self.locals[mir::RETURN_PLACE] {
LocalRef::Operand(op) => op,
LocalRef::PendingOperand => bug!("use of return before def"),
LocalRef::Place(cg_place) => {
OperandRef { val: Ref(cg_place.val), layout: cg_place.layout }
}
LocalRef::Place(cg_place) => OperandRef {
val: Ref(cg_place.val),
layout: cg_place.layout,
move_annotation: None,
},
LocalRef::UnsizedPlace(_) => bug!("return type must be sized"),
};
let llslot = match op.val {
Expand Down Expand Up @@ -1155,7 +1157,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
| (&mir::Operand::Constant(_), Ref(PlaceValue { llextra: None, .. })) => {
let tmp = PlaceRef::alloca(bx, op.layout);
bx.lifetime_start(tmp.val.llval, tmp.layout.size);
op.val.store(bx, tmp);
op.store_with_annotation(bx, tmp);
op.val = Ref(tmp.val);
lifetime_ends_after_call.push((tmp.val.llval, tmp.layout.size));
}
Expand Down Expand Up @@ -1563,13 +1565,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
};
let scratch = PlaceValue::alloca(bx, arg.layout.size, required_align);
bx.lifetime_start(scratch.llval, arg.layout.size);
op.val.store(bx, scratch.with_type(arg.layout));
op.store_with_annotation(bx, scratch.with_type(arg.layout));
lifetime_ends_after_call.push((scratch.llval, arg.layout.size));
(scratch.llval, scratch.align, true)
}
PassMode::Cast { .. } => {
let scratch = PlaceRef::alloca(bx, arg.layout);
op.val.store(bx, scratch);
op.store_with_annotation(bx, scratch);
(scratch.val.llval, scratch.val.align, true)
}
_ => (op.immediate_or_packed_pair(bx), arg.layout.align.abi, false),
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
return local(OperandRef {
val: OperandValue::Pair(a, b),
layout: arg.layout,
move_annotation: None,
});
}
_ => {}
Expand Down Expand Up @@ -552,6 +553,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
fx.caller_location = Some(OperandRef {
val: OperandValue::Immediate(bx.get_param(llarg_idx)),
layout: arg.layout,
move_annotation: None,
});
}

Expand Down
Loading
Loading