Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
da61e9c
Add tests for unsoundness involving alias liveness
jackh726 Oct 3, 2026
816be68
Disable recovery when attribute parser shouldn't emit
JonathanBrouwer Oct 25, 2026
e66afcd
Use a raw pointer for ownership of `LLVMBuilderRef`
Zalathar Oct 15, 2026
7434659
Tweak some SimpleCx lifetimes
Zalathar Oct 23, 2026
3b72d26
Use an invariant lifetime brand for LLVM contexts
Zalathar Oct 15, 2026
d11be6b
fd-views: enable test on Miri
RalfJung Oct 26, 2026
7c12d6c
x86-64-linux-gnu seems to have working f128 now
RalfJung Oct 26, 2026
21f918c
Lex lifetimes using emoji and emit appropriate error
estebank Mar 15, 2026
39d7cc1
docs: Nitpick change in `HashMap`'s `.insert_entry()` doc example
mikwielgus Oct 26, 2026
b6c9f78
core: Split the `resumable_breakpoint` intrinsic and constify it
tgross35 Oct 19, 2026
d0e5a14
std: Re-export core::process::resumable_breakpoint
tgross35 Oct 19, 2026
1b97c28
Add strict methods to `NonZero`
hsanzg Oct 24, 2026
7cd27a6
Add `NonZero::strict_` tests via macro-generated modules
hsanzg Oct 25, 2026
f2614a9
Rollup merge of #164168 - jackh726:alias-liveness-unsoundness-tests, …
tgross35 Oct 27, 2026
ea997df
Rollup merge of #164608 - tgross35:resumable_breakpoint-updates, r=Ma…
tgross35 Oct 27, 2026
da91aa9
Rollup merge of #164787 - Zalathar:llref, r=hanna-kruppe
tgross35 Oct 27, 2026
9d4eafa
Rollup merge of #164966 - RalfJung:x86-linux-f128, r=tgross35
tgross35 Oct 27, 2026
dc1aecd
Rollup merge of #153893 - estebank:emoji-lifetime, r=jdonszelmann,Vey…
tgross35 Oct 27, 2026
777cb3d
Rollup merge of #164848 - hsanzg:strict-nonzero, r=jhpratt
tgross35 Oct 27, 2026
98ebf2b
Rollup merge of #164895 - JonathanBrouwer:disable-recovery, r=mejrs
tgross35 Oct 27, 2026
fe80995
Rollup merge of #164963 - RalfJung:fd-views-miri-test, r=the8472
tgross35 Oct 27, 2026
afd1d7a
Rollup merge of #165004 - mikwielgus:entry-api-nitpick-2, r=aapoalas
tgross35 Oct 27, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4640,6 +4640,7 @@ dependencies = [
"thin-vec",
"tracing",
"unicode-normalization",
"unicode-properties",
"unicode-width 0.2.2",
]

Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_attr_parsing/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,11 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
should_emit: ShouldEmit,
allow_expr_metavar: AllowExprMetavar,
) -> PResult<'sess, MetaItemListParser> {
let mut parser = Parser::new(psess, tokens, None);
if let ShouldEmit::ErrorsAndLints { recovery } = should_emit {
parser = parser.recovery(recovery);
}
let recovery = match should_emit {
ShouldEmit::ErrorsAndLints { recovery } => recovery,
_ => Recovery::Forbidden,
};
let mut parser = Parser::new(psess, tokens, None).recovery(recovery);

let mut this =
MetaItemListParserContext { parser: &mut parser, should_emit, allow_expr_metavar };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ index 1e336bf..35e6f54 100644
// tidy-alphabetical-start
#![cfg_attr(not(panic = "abort"), feature(reentrant_lock))]
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
#![feature(abort_immediate)]
#![feature(array_ptr_get)]
#![feature(array_try_from_fn)]
diff --git a/coretests/tests/atomic.rs b/coretests/tests/atomic.rs
index b735957..ea728b6 100644
--- a/coretests/tests/atomic.rs
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
fx.bcx.ins().trap(TrapCode::user(2).unwrap());
return Ok(());
}
sym::breakpoint => {
sym::breakpoint | sym::resumable_breakpoint => {
intrinsic_args!(fx, args => (); intrinsic);

fx.bcx.ins().debugtrap();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
);
return IntrinsicResult::WroteIntoPlace;
}
sym::breakpoint => {
sym::breakpoint | sym::resumable_breakpoint => {
unimplemented!();
}
sym::va_arg => {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ pub(crate) unsafe fn codegen(
}
}

fn create_wrapper_function(
fn create_wrapper_function<'ll>(
tcx: TyCtxt<'_>,
cx: &SimpleCx<'_>,
cx: &SimpleCx<'ll>,
from_name: &str,
to_name: Option<&str>,
args: &[&Type],
output: Option<&Type>,
args: &[&'ll Type],
output: Option<&'ll Type>,
no_return: bool,
attrs: &CodegenFnAttrs,
) {
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ pub(crate) fn sanitize_attrs<'ll, 'tcx>(

/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
#[inline]
pub(crate) fn uwtable_attr(llcx: &llvm::Context, use_sync_unwind: Option<bool>) -> &Attribute {
pub(crate) fn uwtable_attr<'ll>(
llcx: llvm::Context<'ll>,
use_sync_unwind: Option<bool>,
) -> &'ll Attribute {
// NOTE: We should determine if we even need async unwind tables, as they
// take have more overhead and if we can use sync unwind tables we
// probably should.
Expand Down Expand Up @@ -488,7 +491,7 @@ pub(crate) fn default_optimisation_attrs<'ll>(
attrs
}

fn create_alloc_family_attr(llcx: &llvm::Context) -> &llvm::Attribute {
fn create_alloc_family_attr<'ll>(llcx: llvm::Context<'ll>) -> &'ll llvm::Attribute {
llvm::CreateAttrStringValue(llcx, "alloc-family", "__rust_alloc")
}

Expand Down
26 changes: 18 additions & 8 deletions compiler/rustc_codegen_llvm/src/back/llvm_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl CodegenBackend for LlvmCodegenBackend {
}

pub struct ModuleLlvm {
llcx_raw: ptr::NonNull<llvm::Context>,
llcx_raw: ptr::NonNull<llvm::ContextRaw>,
llmod_raw: *const llvm::Module,

// This field is `ManuallyDrop` because it is important that the `TargetMachine`
Expand All @@ -461,12 +461,22 @@ pub struct ModuleLlvm {
// `ModuleLlvm` owns the context and only allows borrowing LLVM objects tied to the context.
unsafe impl Send for ModuleLlvm {}

/// Converts an unbranded pointer-to-context to a lifetime-branded [`llvm::Context`].
///
/// # Safety
/// - The pointer must be a valid LLVM context.
/// - If the context is passed to safe code, its caller-requested lifetime must be distinct
/// from that of any other context, and must not outlive the underlying context.
unsafe fn wrap_llcx<'ll>(llcx_raw: ptr::NonNull<llvm::ContextRaw>) -> llvm::Context<'ll> {
llvm::Context { llcx_raw, _invariant_ll: PhantomData }
}

/// Shared helper to call [`llvm::LLVMContextCreate`] and then configure
/// [`llvm::LLVMContextSetDiscardValueNames`].
fn create_context_and_set_fewer_names(fewer_names: bool) -> ptr::NonNull<llvm::Context> {
fn create_context_and_set_fewer_names(fewer_names: bool) -> ptr::NonNull<llvm::ContextRaw> {
unsafe {
let llcx_raw = llvm::LLVMContextCreate();
llvm::LLVMContextSetDiscardValueNames(llcx_raw.as_ref(), fewer_names.to_llvm_bool());
llvm::LLVMContextSetDiscardValueNames(wrap_llcx(llcx_raw), fewer_names.to_llvm_bool());
llcx_raw
}
}
Expand All @@ -475,7 +485,7 @@ impl ModuleLlvm {
pub(crate) fn new(tcx: TyCtxt<'_>, mod_name: &str) -> Self {
unsafe {
let llcx_raw = create_context_and_set_fewer_names(tcx.sess.fewer_names());
let llmod_raw = context::create_module(tcx, llcx_raw.as_ref(), mod_name);
let llmod_raw = context::create_module(tcx, wrap_llcx(llcx_raw), mod_name);
ModuleLlvm {
llmod_raw,
llcx_raw,
Expand All @@ -488,7 +498,7 @@ impl ModuleLlvm {
pub(crate) fn new_metadata(tcx: TyCtxt<'_>, mod_name: &str) -> Self {
unsafe {
let llcx_raw = create_context_and_set_fewer_names(tcx.sess.fewer_names());
let llmod_raw = context::create_module(tcx, llcx_raw.as_ref(), mod_name);
let llmod_raw = context::create_module(tcx, wrap_llcx(llcx_raw), mod_name);
ModuleLlvm {
llmod_raw,
llcx_raw,
Expand All @@ -507,7 +517,7 @@ impl ModuleLlvm {
) -> Self {
unsafe {
let llcx_raw = create_context_and_set_fewer_names(cgcx.fewer_names);
let llmod_raw = back::lto::parse_module(llcx_raw.as_ref(), name, buffer, dcx);
let llmod_raw = back::lto::parse_module(wrap_llcx(llcx_raw), name, buffer, dcx);
let tm = tm_factory(dcx, TargetMachineFactoryConfig::new(cgcx, name.to_str().unwrap()));

ModuleLlvm {
Expand All @@ -529,7 +539,7 @@ impl ModuleLlvm {
inner_fn: impl for<'ll> FnOnce(ModuleRefs<'ll>) -> R,
) -> R {
inner_fn(ModuleRefs {
llcx: unsafe { self.llcx_raw.as_ref() },
llcx: unsafe { wrap_llcx(self.llcx_raw) },
llmod: unsafe { &*self.llmod_raw },
tm: self.tm.raw(),
_ph: PhantomData,
Expand All @@ -549,7 +559,7 @@ impl Drop for ModuleLlvm {
/// Bundle of references provided by [`ModuleLlvm::with_module_refs`].
#[derive(Clone, Copy)]
pub(crate) struct ModuleRefs<'ll> {
pub(crate) llcx: &'ll llvm::Context,
pub(crate) llcx: llvm::Context<'ll>,
pub(crate) llmod: &'ll llvm::Module,
pub(crate) tm: &'ll llvm::TargetMachine,
/// Make sure `'ll` is invariant, even if no fields happen to require that.
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,14 +854,14 @@ fn module_name_to_str(c_str: &CStr) -> &str {
})
}

pub(crate) fn parse_module<'a>(
cx: &'a llvm::Context,
pub(crate) fn parse_module<'ll>(
llcx: llvm::Context<'ll>,
name: &CStr,
data: &[u8],
dcx: DiagCtxtHandle<'_>,
) -> &'a llvm::Module {
) -> &'ll llvm::Module {
unsafe {
llvm::LLVMRustParseBitcodeForLTO(cx, data.as_ptr(), data.len(), name.as_ptr())
llvm::LLVMRustParseBitcodeForLTO(llcx, data.as_ptr(), data.len(), name.as_ptr())
.unwrap_or_else(|| write::llvm_err(dcx, LlvmError::ParseBitcode))
}
}
24 changes: 14 additions & 10 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ struct DiagnosticHandlerCallbackData<'a> {
shared_emitter: &'a SharedEmitter,
}

pub(crate) struct DiagnosticHandlers<'a> {
llcx: &'a llvm::Context,
pub(crate) struct DiagnosticHandlers<'a, 'll> {
llcx: llvm::Context<'ll>,
old_handler: Option<ptr::NonNull<llvm::DiagnosticHandler>>,

/// Ownership of the box-allocated data that was installed (as a pointer)
Expand All @@ -337,11 +337,11 @@ pub(crate) struct DiagnosticHandlers<'a> {
diagnostic_handler_callback_data: *mut DiagnosticHandlerCallbackData<'a>,
}

impl<'a> DiagnosticHandlers<'a> {
impl<'a, 'll> DiagnosticHandlers<'a, 'll> {
pub(crate) fn new(
cgcx: &'a CodegenContext,
shared_emitter: &'a SharedEmitter,
llcx: &'a llvm::Context,
llcx: llvm::Context<'ll>,
module: &ModuleCodegen<ModuleLlvm>,
stage: CodegenDiagnosticsStage,
) -> Self {
Expand Down Expand Up @@ -396,7 +396,7 @@ impl<'a> DiagnosticHandlers<'a> {
}
}

impl<'a> Drop for DiagnosticHandlers<'a> {
impl<'a, 'll> Drop for DiagnosticHandlers<'a, 'll> {
fn drop(&mut self) {
unsafe {
llvm::LLVMRustContextSetDiagnosticHandler(self.llcx, self.old_handler);
Expand Down Expand Up @@ -654,7 +654,7 @@ pub(crate) unsafe fn llvm_optimize<'ll>(
None
};

fn handle_offload<'ll>(cx: &'ll SimpleCx<'_>, old_fn: &llvm::Value) {
fn handle_offload<'ll>(cx: &SimpleCx<'ll>, old_fn: &'ll llvm::Value) {
let old_fn_ty = cx.get_type_of_global(old_fn);
let old_param_types = cx.func_params_types(old_fn_ty);
let old_param_count = old_param_types.len();
Expand Down Expand Up @@ -1205,10 +1205,10 @@ pub(crate) fn bitcode_section_name(cgcx: &CodegenContext) -> &'static CStr {
}

/// Embed the bitcode of an LLVM module for LTO in the LLVM module itself.
fn embed_bitcode(
fn embed_bitcode<'ll>(
cgcx: &CodegenContext,
llcx: &llvm::Context,
llmod: &llvm::Module,
llcx: llvm::Context<'ll>,
llmod: &'ll llvm::Module,
bitcode: &[u8],
) {
// We're adding custom sections to the output object file, but we definitely
Expand Down Expand Up @@ -1291,7 +1291,11 @@ fn embed_bitcode(
// when using MSVC linker. We do this only for data, as linker can fix up
// code references on its own.
// See #26591, #27438
fn create_msvc_imps(cgcx: &CodegenContext, llcx: &llvm::Context, llmod: &llvm::Module) {
fn create_msvc_imps<'ll>(
cgcx: &CodegenContext,
llcx: llvm::Context<'ll>,
llmod: &'ll llvm::Module,
) {
if !cgcx.msvc_imps_needed {
return;
}
Expand Down
Loading
Loading