Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d33b74b
Add `desktop` method to `CommandExt`
Jul 6, 2026
c266bb2
get number of devices intrinisc
Sa4dUs Jun 17, 2026
efbb356
Add device arg to offload intrinisc
Sa4dUs Aug 13, 2026
ed486fb
Add a regression test for a panicking proc macro used as an inner att…
jakubadamw Aug 16, 2026
652eb84
Add a regression test for a `macro_rules!` generated by another crate…
jakubadamw Aug 16, 2026
d9d3a21
Add a regression test for full LTO against `rustc_private`
jakubadamw Aug 16, 2026
f18340b
Add a regression test for eliding the middle of a span containing har…
jakubadamw Aug 16, 2026
dd69e6b
std: don't panic on long-elapsed deadlines for `sleep_until`
joboet Aug 18, 2026
1675872
Add regression test for inconsistent import resolution from issue 147208
lybang-lab Aug 18, 2026
d448db8
Add a regression test for wrapping arithmetic under MIR optimisations
jakubadamw Aug 16, 2026
ceeaac0
Add regression test for nested RPIT not-an-iterator ICE
zakrad Aug 18, 2026
8ac67c5
Cleanup: Move impl of `#[rustc_dump_object_lifetime_defaults]`
fmease Aug 19, 2026
eae69d8
Add file path to some archive build errors
bjorn3 Aug 19, 2026
f151cb9
diagnostics: fix `let x: vec![]` suggestion pointing into stdlib
Rohan-Singla Jul 7, 2026
d827d44
Uplift rustfmt macro formatting fix
Manishearth Aug 19, 2026
3777642
Update with macro and some tweaks
Sa4dUs Aug 14, 2026
f11d76f
Allow running EC2 jobs locally
JonathanBrouwer Aug 19, 2026
6c99f69
Fix obvious copy/paste bug in `State::fmt_diff_with`
nnethercote Aug 19, 2026
dffe277
Remove unnecessary arg from `FlowSensitiveAnalysis::new`
nnethercote Aug 19, 2026
c7ead52
Factor out duplicated code in `Qualifs`
nnethercote Aug 19, 2026
6229d6d
Remove defaults for `Qualif` assoc consts
nnethercote Aug 19, 2026
bb9cd32
Pre-adjust visibility of pub items in `lib.rs`
Zalathar Aug 18, 2026
651d501
Pre-adjust visibility of default-visibility items in `lib.rs`
Zalathar Aug 17, 2026
72e9e0e
Pre-adjust imports from the crate root
Zalathar Aug 17, 2026
f068a50
Temporarily rename `lib.rs` to `session.rs`
Zalathar Aug 18, 2026
91374a5
Move all non-module items out of the crate root
Zalathar Aug 18, 2026
0ff906a
Configure LLM policy URL for triagebot
Kobzol Aug 20, 2026
ac623ff
Double-word align `_Unwind_Exception`
hsanzg Aug 19, 2026
ed151ed
std: update definitions on Fuchsia
joboet Feb 14, 2026
95d6b37
std: implement `sleep_until` for Fuchsia
joboet Feb 14, 2026
1c0a0d9
std: update `sleep_until` syscall table
joboet May 21, 2026
2d28ce9
std: add a comment about elapsed deadlines for `sleep_until`
joboet Aug 20, 2026
7c619a0
Rollup merge of #152617 - joboet:fuchsia_sleep_until, r=nia-e
JonathanBrouwer Aug 20, 2026
388a477
Rollup merge of #158934 - Rohan-Singla:fix/158492, r=jackh726
JonathanBrouwer Aug 20, 2026
357c660
Rollup merge of #161277 - Zalathar:session, r=Kobzol
JonathanBrouwer Aug 20, 2026
264c3b4
Rollup merge of #161295 - joboet:sleep_until-long-elapsed, r=tgross35
JonathanBrouwer Aug 20, 2026
93170db
Rollup merge of #161368 - hsanzg:uw-ex-align, r=bjorn3,tgross35
JonathanBrouwer Aug 20, 2026
3746a2e
Rollup merge of #161370 - Manishearth:rustfmt-macro-fix, r=ytmimi
JonathanBrouwer Aug 20, 2026
d33d4cf
Rollup merge of #161378 - nnethercote:FlowSensitiveAnalysis-cleanups,…
JonathanBrouwer Aug 20, 2026
532c204
Rollup merge of #158032 - Sa4dUs:offload-device-selection, r=ZuseZ4
JonathanBrouwer Aug 20, 2026
b3db0e3
Rollup merge of #158855 - Krakoer:feat/commandext-desktop, r=ChrisDenton
JonathanBrouwer Aug 20, 2026
814910f
Rollup merge of #161302 - KevinA-cpu:regression-test-147208, r=khyperia
JonathanBrouwer Aug 20, 2026
7cce797
Rollup merge of #161329 - jakubadamw:e-needs-test, r=jackh726
JonathanBrouwer Aug 20, 2026
cfefc48
Rollup merge of #161330 - zakrad:regr-test-159559, r=JohnTitor
JonathanBrouwer Aug 20, 2026
548cf05
Rollup merge of #161351 - fmease:mv-impl-dump-obj-lt-defs, r=Jonathan…
JonathanBrouwer Aug 20, 2026
8a40258
Rollup merge of #161355 - bjorn3:archive_error_message, r=mu001999
JonathanBrouwer Aug 20, 2026
96ea187
Rollup merge of #161373 - JonathanBrouwer:ec2-local, r=Mark-Simulacrum
JonathanBrouwer Aug 20, 2026
46d99d2
Rollup merge of #161393 - Kobzol:llm-policy-url, r=Urgau
JonathanBrouwer Aug 20, 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
26 changes: 17 additions & 9 deletions compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,20 @@ fn generate_launcher<'ll>(cx: &CodegenCx<'ll, '_>) -> (&'ll llvm::Value, &'ll ll
(tgt_decl, tgt_fn_ty)
}

/// Declares the `omp_get_num_devices` runtime function and returns the
/// declaration together with its type.
pub(crate) fn declare_omp_get_num_devices<'ll>(
cx: &CodegenCx<'ll, '_>,
) -> (&'ll llvm::Value, &'ll llvm::Type) {
let ti32 = cx.type_i32();
let tgt_fn_ty = cx.type_func(&[], ti32);
let name = "omp_get_num_devices";
let tgt_decl = declare_offload_fn(&cx, name, tgt_fn_ty);
let nounwind = llvm::AttributeKind::NoUnwind.create_attr(cx.llcx);
attributes::apply_to_llfn(tgt_decl, Function, &[nounwind]);
(tgt_decl, tgt_fn_ty)
}

// What is our @1 here? A magic global, used in our data_{begin/update/end}_mapper:
// @0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1
// @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @0 }, align 8
Expand Down Expand Up @@ -591,6 +605,7 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
offload_globals: &OffloadGlobals<'ll>,
offload_dims: &OffloadKernelDims<'ll>,
dyn_cache: &'ll Value,
device_id: &'ll Value,
) {
let cx = builder.cx;
let OffloadKernelGlobals {
Expand Down Expand Up @@ -775,15 +790,8 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
builder.store(value.2, ptr, value.0);
}

let args = vec![
s_ident_t,
// FIXME(offload) give users a way to select which GPU to use.
cx.get_const_i64(u64::MAX), // MAX == -1.
num_workgroups,
threads_per_block,
region_id,
a5,
];
let device_id = builder.sext(device_id, cx.type_i64());
let args = vec![s_ident_t, device_id, num_workgroups, threads_per_block, region_id, a5];
builder.call(tgt_target_kernel_ty, None, None, tgt_decl, &args, None, None);
// %41 = call i32 @__tgt_target_kernel(ptr @1, i64 -1, i32 2097152, i32 256, ptr @.kernel_1.region_id, ptr %kernel_args)

Expand Down
21 changes: 17 additions & 4 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::abi::FnAbiLlvmExt;
use crate::builder::Builder;
use crate::builder::autodiff::{adjust_activity_to_abi, generate_enzyme_call};
use crate::builder::gpu_offload::{
OffloadKernelDims, gen_call_handling, gen_define_handling, register_offload,
self, OffloadKernelDims, declare_omp_get_num_devices, register_offload,
};
use crate::context::CodegenCx;
use crate::declare::declare_raw_fn;
Expand Down Expand Up @@ -241,6 +241,13 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
// offload *has* a return type, but somehow works without mentioning the place
return IntrinsicResult::WroteIntoPlace;
}
sym::offload_get_num_devices => {
let (fn_decl, fn_ty) = declare_omp_get_num_devices(self.cx);

let llval = self.call(fn_ty, None, None, fn_decl, &[], None, None);

return IntrinsicResult::Operand(OperandValue::Immediate(llval));
},
sym::is_val_statically_known => {
if let OperandValue::Immediate(imm) = args[0].val {
self.call_intrinsic(
Expand Down Expand Up @@ -1851,7 +1858,11 @@ fn codegen_offload<'ll, 'tcx>(
OperandValue::Immediate(val) => val,
_ => panic!("unparsable"),
};
let args = get_args_from_tuple(bx, args[4], fn_target);
let device_id = match args[4].val {
OperandValue::Immediate(val) => val,
_ => panic!("unparsable"),
};
let args = get_args_from_tuple(bx, args[5], fn_target);
let target_symbol = mangle_offload_export(tcx, fn_target);

let sig = tcx.fn_sig(fn_target.def_id()).instantiate(tcx, fn_target.args).skip_norm_wip();
Expand Down Expand Up @@ -1882,8 +1893,9 @@ fn codegen_offload<'ll, 'tcx>(
}
};
register_offload(cx);
let offload_data = gen_define_handling(&cx, &metadata, target_symbol, offload_globals);
gen_call_handling(
let offload_data =
gpu_offload::gen_define_handling(&cx, &metadata, target_symbol, offload_globals);
gpu_offload::gen_call_handling(
bx,
&offload_data,
&args,
Expand All @@ -1892,6 +1904,7 @@ fn codegen_offload<'ll, 'tcx>(
offload_globals,
&offload_dims,
&dyn_cache,
&device_id,
);
}

Expand Down
20 changes: 14 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,9 @@ impl<'a> ArArchiveBuilder<'a> {
io::Error::new(
io::ErrorKind::InvalidData,
format!(
"archive member at offset {start} with size {} \
"archive member of {} at offset {start} with size {} \
exceeds archive size {} in `{}`",
src_archive.0.display(),
file_range.1,
archive_data.len(),
src_archive.0.display(),
Expand All @@ -642,11 +643,18 @@ impl<'a> ArArchiveBuilder<'a> {
}
}
ArchiveEntrySource::File(file) => unsafe {
let mmap = Mmap::map(
File::open(file)
.map_err(|err| io_error_context("failed to open object file", err))?,
)
.map_err(|err| io_error_context("failed to map object file", err))?;
let mmap = Mmap::map(File::open(&file).map_err(|err| {
io_error_context(
&format!("failed to open object file {}", file.display()),
err,
)
})?)
.map_err(|err| {
io_error_context(
&format!("failed to map object file {}", file.display()),
err,
)
})?;
if entry.kind == ArchiveEntryKind::RustObj
&& let Some(sym) = &symbols
{
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
| sym::atomic_fence
| sym::atomic_singlethreadfence
| sym::caller_location
| sym::offload_get_num_devices
| sym::return_address => {}
_ => {
span_bug!(
Expand Down
105 changes: 32 additions & 73 deletions compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,91 +49,33 @@ pub(crate) struct Qualifs<'mir, 'tcx> {
}

impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
/// Returns `true` if `local` is `NeedsDrop` at the given `Location`.
///
/// Only updates the cursor if absolutely necessary
pub(crate) fn needs_drop(
&mut self,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,
location: Location,
) -> bool {
let ty = ccx.body.local_decls[local].ty;
// Peeking into opaque types causes cycles if the current function declares said opaque
// type. Thus we avoid short circuiting on the type and instead run the more expensive
// analysis that looks at the actual usage within this function
if !ty.has_opaque_types() && !NeedsDrop::in_any_value_of_ty(ccx, ty) {
return false;
}

let needs_drop = self.needs_drop.get_or_insert_with(|| {
let ConstCx { tcx, body, .. } = *ccx;

FlowSensitiveAnalysis::new(NeedsDrop, ccx)
.iterate_to_fixpoint(tcx, body, None)
.into_results_cursor(body)
});

needs_drop.seek_before_primary_effect(location);
needs_drop.get().contains(local)
}

/// Returns `true` if `local` is `NeedsNonConstDrop` at the given `Location`.
///
/// Only updates the cursor if absolutely necessary
pub(crate) fn needs_non_const_drop(
&mut self,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,
location: Location,
) -> bool {
let ty = ccx.body.local_decls[local].ty;
// Peeking into opaque types causes cycles if the current function declares said opaque
// type. Thus we avoid short circuiting on the type and instead run the more expensive
// analysis that looks at the actual usage within this function
if !ty.has_opaque_types() && !NeedsNonConstDrop::in_any_value_of_ty(ccx, ty) {
return false;
}

let needs_non_const_drop = self.needs_non_const_drop.get_or_insert_with(|| {
let ConstCx { tcx, body, .. } = *ccx;

FlowSensitiveAnalysis::new(NeedsNonConstDrop, ccx)
.iterate_to_fixpoint(tcx, body, None)
.into_results_cursor(body)
});

needs_non_const_drop.seek_before_primary_effect(location);
needs_non_const_drop.get().contains(local)
}

/// Returns `true` if `local` is `HasMutInterior` at the given `Location`.
/// Does `Q` hold for the `local` at the given `Location`?
///
/// Only updates the cursor if absolutely necessary.
fn has_mut_interior(
&mut self,
fn in_local<Q: Qualif>(
qualif_results: &mut Option<QualifResults<'mir, 'tcx, Q>>,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,
location: Location,
) -> bool {
let ty = ccx.body.local_decls[local].ty;
// Peeking into opaque types causes cycles if the current function declares said opaque
// type. Thus we avoid short circuiting on the type and instead run the more expensive
// analysis that looks at the actual usage within this function
if !ty.has_opaque_types() && !HasMutInterior::in_any_value_of_ty(ccx, ty) {
// analysis that looks at the actual usage within this function.
if !ty.has_opaque_types() && !Q::in_any_value_of_ty(ccx, ty) {
return false;
}

let has_mut_interior = self.has_mut_interior.get_or_insert_with(|| {
let qualif_results = qualif_results.get_or_insert_with(|| {
let ConstCx { tcx, body, .. } = *ccx;

FlowSensitiveAnalysis::new(HasMutInterior, ccx)
FlowSensitiveAnalysis::new(ccx)
.iterate_to_fixpoint(tcx, body, None)
.into_results_cursor(body)
});

has_mut_interior.seek_before_primary_effect(location);
has_mut_interior.get().contains(local)
qualif_results.seek_before_primary_effect(location);
qualif_results.get().contains(local)
}

fn in_return_place(
Expand Down Expand Up @@ -161,9 +103,19 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
let return_loc = ccx.body.terminator_loc(return_block);

ConstQualifs {
needs_drop: self.needs_drop(ccx, RETURN_PLACE, return_loc),
needs_non_const_drop: self.needs_non_const_drop(ccx, RETURN_PLACE, return_loc),
has_mut_interior: self.has_mut_interior(ccx, RETURN_PLACE, return_loc),
needs_drop: Self::in_local(&mut self.needs_drop, ccx, RETURN_PLACE, return_loc),
needs_non_const_drop: Self::in_local(
&mut self.needs_non_const_drop,
ccx,
RETURN_PLACE,
return_loc,
),
has_mut_interior: Self::in_local(
&mut self.has_mut_interior,
ccx,
RETURN_PLACE,
return_loc,
),
tainted_by_errors,
}
}
Expand Down Expand Up @@ -435,7 +387,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
let ty_of_dropped_place = dropped_place.ty(self.body, self.tcx).ty;

let needs_drop = if let Some(local) = dropped_place.as_local() {
self.qualifs.needs_drop(self.ccx, local, location)
Qualifs::in_local(&mut self.qualifs.needs_drop, self.ccx, local, location)
} else {
qualifs::NeedsDrop::in_any_value_of_ty(self.ccx, ty_of_dropped_place)
};
Expand All @@ -448,7 +400,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
let needs_non_const_drop = if let Some(local) = dropped_place.as_local() {
// Use the span where the local was declared as the span of the drop error.
err_span = self.body.local_decls[local].source_info.span;
self.qualifs.needs_non_const_drop(self.ccx, local, location)
Qualifs::in_local(&mut self.qualifs.needs_non_const_drop, self.ccx, local, location)
} else {
qualifs::NeedsNonConstDrop::in_any_value_of_ty(self.ccx, ty_of_dropped_place)
};
Expand Down Expand Up @@ -602,7 +554,14 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
| Rvalue::RawPtr(RawPtrKind::Const, place) => {
let borrowed_place_has_mut_interior = qualifs::in_place::<HasMutInterior, _>(
self.ccx,
&mut |local| self.qualifs.has_mut_interior(self.ccx, local, location),
&mut |local| {
Qualifs::in_local(
&mut self.qualifs.has_mut_interior,
self.ccx,
local,
location,
)
},
place.as_ref(),
);

Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ pub trait Qualif {
const ANALYSIS_NAME: &'static str;

/// Whether this `Qualif` is cleared when a local is moved from.
const IS_CLEARED_ON_MOVE: bool = false;
const IS_CLEARED_ON_MOVE: bool;

/// Whether this `Qualif` might be evaluated after the promotion and can encounter a promoted.
const ALLOW_PROMOTED: bool = false;
const ALLOW_PROMOTED: bool;

/// Extracts the field of `ConstQualifs` that corresponds to this `Qualif`.
fn in_qualifs(qualifs: &ConstQualifs) -> bool;
Expand Down Expand Up @@ -79,6 +79,8 @@ pub struct HasMutInterior;

impl Qualif for HasMutInterior {
const ANALYSIS_NAME: &'static str = "flow_has_mut_interior";
const IS_CLEARED_ON_MOVE: bool = false;
const ALLOW_PROMOTED: bool = false;

fn in_qualifs(qualifs: &ConstQualifs) -> bool {
qualifs.has_mut_interior
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/check_consts/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl<'mir, 'tcx, Q> FlowSensitiveAnalysis<'mir, 'tcx, Q>
where
Q: Qualif,
{
pub(super) fn new(_: Q, ccx: &'mir ConstCx<'mir, 'tcx>) -> Self {
pub(super) fn new(ccx: &'mir ConstCx<'mir, 'tcx>) -> Self {
FlowSensitiveAnalysis { ccx, _qualif: PhantomData }
}

Expand Down Expand Up @@ -309,7 +309,7 @@ impl<C> DebugWithContext<C> for State {

if self.borrow != old.borrow {
f.write_str("borrow: ")?;
self.qualif.fmt_diff_with(&old.borrow, ctxt, f)?;
self.borrow.fmt_diff_with(&old.borrow, ctxt, f)?;
f.write_str("\n")?;
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
| sym::needs_drop
| sym::non_exhaustive
| sym::offload
| sym::offload_get_num_devices
| sym::offset_of
| sym::overflow_checks
| sym::powf16
Expand Down Expand Up @@ -384,10 +385,12 @@ pub(crate) fn check_intrinsic_type(
Ty::new_array_with_const_len(tcx, tcx.types.u32, Const::from_target_usize(tcx, 3)),
Ty::new_array_with_const_len(tcx, tcx.types.u32, Const::from_target_usize(tcx, 3)),
tcx.types.u32,
tcx.types.i32,
param(1),
],
param(2),
),
sym::offload_get_num_devices => (0, 0, vec![], tcx.types.i32),
sym::offset => (2, 0, vec![param(0), param(1)], param(0)),
sym::arith_offset => (
1,
Expand Down
Loading
Loading