Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b1a9f23
Use `LLVMDIBuilderGetOrCreateSubrange`
Zalathar Sep 19, 2025
a6d2617
Use `LLVMDIBuilderGetOrCreateArray`
Zalathar Sep 19, 2025
9daa026
Use `LLVMDIBuilder(CreateExpression|InsertDeclareRecordAtEnd)`
Zalathar Sep 19, 2025
e39e5a0
Use `LLVMDIBuilderCreate(Auto|Parameter)Variable`
Zalathar Sep 19, 2025
272d336
Remove some unnecessary `as u64` casts
Zalathar Sep 19, 2025
696add0
chore: fixes #146756
sysrex Sep 19, 2025
741e1e2
Remove unused `LLVMRustDIBuilder(Create|Dispose)`
Zalathar Sep 20, 2025
8d7e637
chore: remove dead links
sysrex Sep 22, 2025
8e37f0f
chore: remove discord references from the std library as well
sysrex Sep 24, 2025
7e58c91
usize/isize range matching error clarification
helldawg Sep 19, 2025
78ff5dd
Remove usages of `write_str` from `render_assoc_items_inner`
yotamofek Sep 23, 2025
82fecf0
Cleanup `notable_traits_decl`
yotamofek Sep 23, 2025
a40032d
Simplify notable traits map serialization
yotamofek Sep 23, 2025
4a0c7cc
fix cycle head usages tracking
lcnr Sep 26, 2025
4e44d58
rename `search_graph::Delegate` fns
lcnr Sep 26, 2025
97f6437
formatting_options: fix alternate docs 0b/0o mixup
danielverkamp Sep 26, 2025
fe3e124
doc: fix a typo in platform-support.md
lasiotus Sep 27, 2025
d8a1edc
Use `PanicHookInfo::payload_as_str` now that it's stable in beta
Zalathar Sep 27, 2025
95c146a
Fix tracking issue number for feature(macro_attr)
SimonSapin Sep 26, 2025
d42acf5
Include additional hashes in src/stage0
erickt Jun 7, 2025
76bb0d1
Update stage0 per previous commmit
Mark-Simulacrum Sep 27, 2025
760ed37
redox: switch to colon as path separator
jackpot51 Sep 27, 2025
35e582f
Library: Remove remaining private `#[repr]` workarounds
fmease Sep 27, 2025
aef976e
Add auto extra-checks in pre-push script
Shunpoco Sep 27, 2025
3a20a4d
Fix typo
SebastianSpeitel Sep 27, 2025
4e9cfc7
Rollup merge of #142139 - erickt:include-hashes, r=Mark-Simulacrum
matthiaskrgr Sep 28, 2025
4eddf64
Rollup merge of #146745 - helldawg:master, r=workingjubilee
matthiaskrgr Sep 28, 2025
e8578c8
Rollup merge of #146763 - Zalathar:di-builder, r=jdonszelmann
matthiaskrgr Sep 28, 2025
0fd9396
Rollup merge of #146788 - sysrex:146756/discord_invite, r=workingjubilee
matthiaskrgr Sep 28, 2025
f349faa
Rollup merge of #146942 - yotamofek:pr/rustdoc/finish_deprecating_wri…
matthiaskrgr Sep 28, 2025
cb4c3ad
Rollup merge of #147061 - lcnr:provisional-cache-woops, r=BoxyUwU
matthiaskrgr Sep 28, 2025
194bd77
Rollup merge of #147066 - SimonSapin:macro_attr-tracking, r=lqd
matthiaskrgr Sep 28, 2025
93fff3d
Rollup merge of #147081 - moturus:fix_md, r=workingjubilee
matthiaskrgr Sep 28, 2025
ad864de
Rollup merge of #147082 - danielverkamp:fmt-alternate-octal-binary-mi…
matthiaskrgr Sep 28, 2025
925951d
Rollup merge of #147086 - Zalathar:payload, r=jieyouxu
matthiaskrgr Sep 28, 2025
f22af64
Rollup merge of #147093 - jackpot51:redox-path, r=bjorn3
matthiaskrgr Sep 28, 2025
641beda
Rollup merge of #147095 - fmease:libprivrepr, r=dtolnay
matthiaskrgr Sep 28, 2025
f31963f
Rollup merge of #147098 - Shunpoco:issue-147088, r=Kobzol
matthiaskrgr Sep 28, 2025
f4032bc
Rollup merge of #147110 - SebastianSpeitel:patch-1, r=saethlin
matthiaskrgr Sep 28, 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
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ bootstrapping, the compiler architecture, source code representation, and more.

## [Getting help](https://rustc-dev-guide.rust-lang.org/getting-started.html#asking-questions)

There are many ways you can get help when you're stuck. Rust has many platforms for this:
[internals], [rust-zulip], and [rust-discord]. It is recommended to ask for help on
There are many ways you can get help when you're stuck. Rust has two platforms for this:
[internals] and [rust-zulip]. It is recommended to ask for help on
the [rust-zulip], but any of these platforms are great ways to seek help and even
find a mentor! You can learn more about asking questions and getting help in the
[Asking Questions](https://rustc-dev-guide.rust-lang.org/getting-started.html#asking-questions) chapter of the [rustc-dev-guide].
Expand All @@ -47,5 +47,4 @@ refer to [this section][contributing-bug-reports] and [open an issue][issue temp
[contributing-bug-reports]: https://rustc-dev-guide.rust-lang.org/contributing.html#bug-reports
[issue template]: https://github.com/rust-lang/rust/issues/new/choose
[internals]: https://internals.rust-lang.org
[rust-discord]: http://discord.gg/rust-lang
[rust-zulip]: https://rust-lang.zulipchat.com
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,10 @@ dependencies = [
"anyhow",
"build_helper",
"curl",
"hex",
"indexmap",
"serde",
"sha2",
"toml 0.8.23",
]

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
.try_to_target_usize(cx.tcx)
.expect("expected monomorphic const in codegen") as c_longlong;

let subrange = unsafe { llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
let subrange = unsafe { llvm::LLVMDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
let subscripts = &[subrange];

let di_node = unsafe {
Expand Down
81 changes: 43 additions & 38 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ mod utils;
use self::create_scope_map::compute_mir_scopes;
pub(crate) use self::metadata::build_global_var_di_node;

// FIXME(Zalathar): These `DW_TAG_*` constants are fake values that were
// removed from LLVM in 2015, and are only used by our own `RustWrapper.cpp`
// to decide which C++ API to call. Instead, we should just have two separate
// FFI functions and choose the correct one on the Rust side.
#[allow(non_upper_case_globals)]
const DW_TAG_auto_variable: c_uint = 0x100;
#[allow(non_upper_case_globals)]
const DW_TAG_arg_variable: c_uint = 0x101;

/// A context object for maintaining all state needed by the debuginfo module.
pub(crate) struct CodegenUnitDebugContext<'ll, 'tcx> {
llmod: &'ll llvm::Module,
Expand Down Expand Up @@ -174,35 +165,38 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {

if direct_offset.bytes() > 0 {
addr_ops.push(DW_OP_plus_uconst);
addr_ops.push(direct_offset.bytes() as u64);
addr_ops.push(direct_offset.bytes());
}
for &offset in indirect_offsets {
addr_ops.push(DW_OP_deref);
if offset.bytes() > 0 {
addr_ops.push(DW_OP_plus_uconst);
addr_ops.push(offset.bytes() as u64);
addr_ops.push(offset.bytes());
}
}
if let Some(fragment) = fragment {
// `DW_OP_LLVM_fragment` takes as arguments the fragment's
// offset and size, both of them in bits.
addr_ops.push(DW_OP_LLVM_fragment);
addr_ops.push(fragment.start.bits() as u64);
addr_ops.push((fragment.end - fragment.start).bits() as u64);
addr_ops.push(fragment.start.bits());
addr_ops.push((fragment.end - fragment.start).bits());
}

let di_builder = DIB(self.cx());
let addr_expr = unsafe {
llvm::LLVMDIBuilderCreateExpression(di_builder, addr_ops.as_ptr(), addr_ops.len())
};
unsafe {
// FIXME(eddyb) replace `llvm.dbg.declare` with `llvm.dbg.addr`.
llvm::LLVMRustDIBuilderInsertDeclareAtEnd(
DIB(self.cx()),
llvm::LLVMDIBuilderInsertDeclareRecordAtEnd(
di_builder,
variable_alloca,
dbg_var,
addr_ops.as_ptr(),
addr_ops.len() as c_uint,
addr_expr,
dbg_loc,
self.llbb(),
);
}
)
};
}

fn set_dbg_loc(&mut self, dbg_loc: &'ll DILocation) {
Expand Down Expand Up @@ -630,28 +624,39 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {

let type_metadata = spanned_type_di_node(self, variable_type, span);

let (argument_index, dwarf_tag) = match variable_kind {
ArgumentVariable(index) => (index as c_uint, DW_TAG_arg_variable),
LocalVariable => (0, DW_TAG_auto_variable),
};
let align = self.align_of(variable_type);

let name = variable_name.as_str();
unsafe {
llvm::LLVMRustDIBuilderCreateVariable(
DIB(self),
dwarf_tag,
scope_metadata,
name.as_c_char_ptr(),
name.len(),
file_metadata,
loc.line,
type_metadata,
true,
DIFlags::FlagZero,
argument_index,
align.bits() as u32,
)

match variable_kind {
ArgumentVariable(arg_index) => unsafe {
llvm::LLVMDIBuilderCreateParameterVariable(
DIB(self),
scope_metadata,
name.as_ptr(),
name.len(),
arg_index as c_uint,
file_metadata,
loc.line,
type_metadata,
llvm::Bool::TRUE, // (preserve descriptor during optimizations)
DIFlags::FlagZero,
)
},
LocalVariable => unsafe {
llvm::LLVMDIBuilderCreateAutoVariable(
DIB(self),
scope_metadata,
name.as_ptr(),
name.len(),
file_metadata,
loc.line,
type_metadata,
llvm::Bool::TRUE, // (preserve descriptor during optimizations)
DIFlags::FlagZero,
align.bits() as u32,
)
},
}
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn create_DIArray<'ll>(
builder: &DIBuilder<'ll>,
arr: &[Option<&'ll DIDescriptor>],
) -> &'ll DIArray {
unsafe { llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) }
unsafe { llvm::LLVMDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len()) }
}

#[inline]
Expand Down
97 changes: 57 additions & 40 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use rustc_target::spec::SymbolVisibility;
use super::RustString;
use super::debuginfo::{
DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange,
DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram,
DITemplateTypeParameter, DIType, DebugEmissionKind, DebugNameTableKind,
};
use crate::llvm;

Expand Down Expand Up @@ -807,6 +807,8 @@ unsafe extern "C" {
pub(crate) type Metadata;
pub(crate) type BasicBlock;
pub(crate) type Comdat;
/// `&'ll DbgRecord` represents `LLVMDbgRecordRef`.
pub(crate) type DbgRecord;
}
#[repr(C)]
pub(crate) struct Builder<'a>(InvariantOpaque<'a>);
Expand Down Expand Up @@ -891,7 +893,6 @@ pub(crate) mod debuginfo {
pub(crate) type DIVariable = DIDescriptor;
pub(crate) type DIGlobalVariableExpression = DIDescriptor;
pub(crate) type DIArray = DIDescriptor;
pub(crate) type DISubrange = DIDescriptor;
pub(crate) type DIEnumerator = DIDescriptor;
pub(crate) type DITemplateTypeParameter = DIDescriptor;

Expand Down Expand Up @@ -1992,6 +1993,59 @@ unsafe extern "C" {
Scope: Option<&'ll Metadata>,
AlignInBits: u32, // (optional; default is 0)
) -> &'ll Metadata;

pub(crate) fn LLVMDIBuilderGetOrCreateSubrange<'ll>(
Builder: &DIBuilder<'ll>,
LowerBound: i64,
Count: i64,
) -> &'ll Metadata;

pub(crate) fn LLVMDIBuilderGetOrCreateArray<'ll>(
Builder: &DIBuilder<'ll>,
Data: *const Option<&'ll Metadata>,
NumElements: size_t,
) -> &'ll Metadata;

pub(crate) fn LLVMDIBuilderCreateExpression<'ll>(
Builder: &DIBuilder<'ll>,
Addr: *const u64,
Length: size_t,
) -> &'ll Metadata;

pub(crate) fn LLVMDIBuilderInsertDeclareRecordAtEnd<'ll>(
Builder: &DIBuilder<'ll>,
Storage: &'ll Value,
VarInfo: &'ll Metadata,
Expr: &'ll Metadata,
DebugLoc: &'ll Metadata,
Block: &'ll BasicBlock,
) -> &'ll DbgRecord;

pub(crate) fn LLVMDIBuilderCreateAutoVariable<'ll>(
Builder: &DIBuilder<'ll>,
Scope: &'ll Metadata,
Name: *const c_uchar, // See "PTR_LEN_STR".
NameLen: size_t,
File: &'ll Metadata,
LineNo: c_uint,
Ty: &'ll Metadata,
AlwaysPreserve: llvm::Bool, // "If true, this descriptor will survive optimizations."
Flags: DIFlags,
AlignInBits: u32,
) -> &'ll Metadata;

pub(crate) fn LLVMDIBuilderCreateParameterVariable<'ll>(
Builder: &DIBuilder<'ll>,
Scope: &'ll Metadata,
Name: *const c_uchar, // See "PTR_LEN_STR".
NameLen: size_t,
ArgNo: c_uint,
File: &'ll Metadata,
LineNo: c_uint,
Ty: &'ll Metadata,
AlwaysPreserve: llvm::Bool, // "If true, this descriptor will survive optimizations."
Flags: DIFlags,
) -> &'ll Metadata;
}

#[link(name = "llvm-wrapper", kind = "static")]
Expand Down Expand Up @@ -2358,43 +2412,6 @@ unsafe extern "C" {
AlignInBits: u32,
) -> &'a DIGlobalVariableExpression;

pub(crate) fn LLVMRustDIBuilderCreateVariable<'a>(
Builder: &DIBuilder<'a>,
Tag: c_uint,
Scope: &'a DIDescriptor,
Name: *const c_char,
NameLen: size_t,
File: &'a DIFile,
LineNo: c_uint,
Ty: &'a DIType,
AlwaysPreserve: bool,
Flags: DIFlags,
ArgNo: c_uint,
AlignInBits: u32,
) -> &'a DIVariable;

pub(crate) fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
Builder: &DIBuilder<'a>,
Lo: i64,
Count: i64,
) -> &'a DISubrange;

pub(crate) fn LLVMRustDIBuilderGetOrCreateArray<'a>(
Builder: &DIBuilder<'a>,
Ptr: *const Option<&'a DIDescriptor>,
Count: c_uint,
) -> &'a DIArray;

pub(crate) fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
Builder: &DIBuilder<'a>,
Val: &'a Value,
VarInfo: &'a DIVariable,
AddrOps: *const u64,
AddrOpsCount: c_uint,
DL: &'a DILocation,
InsertAtEnd: &'a BasicBlock,
);

pub(crate) fn LLVMRustDIBuilderCreateEnumerator<'a>(
Builder: &DIBuilder<'a>,
Name: *const c_char,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ declare_features! (
/// Allows fused `loop`/`match` for direct intraprocedural jumps.
(incomplete, loop_match, "1.90.0", Some(132306)),
/// Allow `macro_rules!` attribute rules
(unstable, macro_attr, "1.91.0", Some(83527)),
(unstable, macro_attr, "1.91.0", Some(143547)),
/// Allow `macro_rules!` derive rules
(unstable, macro_derive, "1.91.0", Some(143549)),
/// Give access to additional metadata about declarative macro meta-variables.
Expand Down
53 changes: 0 additions & 53 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,14 +990,6 @@ extern "C" void LLVMRustGlobalAddMetadata(LLVMValueRef Global, unsigned Kind,
unwrap<GlobalObject>(Global)->addMetadata(Kind, *unwrap<MDNode>(MD));
}

extern "C" LLVMDIBuilderRef LLVMRustDIBuilderCreate(LLVMModuleRef M) {
return wrap(new DIBuilder(*unwrap(M)));
}

extern "C" void LLVMRustDIBuilderDispose(LLVMDIBuilderRef Builder) {
delete unwrap(Builder);
}

extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
LLVMDIBuilderRef Builder, unsigned Lang, LLVMMetadataRef FileRef,
const char *Producer, size_t ProducerLen, bool isOptimized,
Expand Down Expand Up @@ -1129,51 +1121,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
return wrap(VarExpr);
}

extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Scope,
const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo,
LLVMMetadataRef Ty, bool AlwaysPreserve, LLVMDIFlags Flags, unsigned ArgNo,
uint32_t AlignInBits) {
if (Tag == 0x100) { // DW_TAG_auto_variable
return wrap(unwrap(Builder)->createAutoVariable(
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), AlwaysPreserve,
fromRust(Flags), AlignInBits));
} else {
return wrap(unwrap(Builder)->createParameterVariable(
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ArgNo,
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), AlwaysPreserve,
fromRust(Flags)));
}
}

extern "C" LLVMMetadataRef
LLVMRustDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t Lo,
int64_t Count) {
return wrap(unwrap(Builder)->getOrCreateSubrange(Lo, Count));
}

extern "C" LLVMMetadataRef
LLVMRustDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder,
LLVMMetadataRef *Ptr, unsigned Count) {
Metadata **DataValue = unwrap(Ptr);
return wrap(unwrap(Builder)
->getOrCreateArray(ArrayRef<Metadata *>(DataValue, Count))
.get());
}

extern "C" void
LLVMRustDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef V,
LLVMMetadataRef VarInfo, uint64_t *AddrOps,
unsigned AddrOpsCount, LLVMMetadataRef DL,
LLVMBasicBlockRef InsertAtEnd) {
unwrap(Builder)->insertDeclare(
unwrap(V), unwrap<DILocalVariable>(VarInfo),
unwrap(Builder)->createExpression(
llvm::ArrayRef<uint64_t>(AddrOps, AddrOpsCount)),
DebugLoc(cast<MDNode>(unwrap(DL))), unwrap(InsertAtEnd));
}

extern "C" LLVMMetadataRef
LLVMRustDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder, const char *Name,
size_t NameLen, const uint64_t Value[2],
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,13 +1275,13 @@ fn report_non_exhaustive_match<'p, 'tcx>(
if ty.is_ptr_sized_integral() {
if ty.inner() == cx.tcx.types.usize {
err.note(format!(
"`{ty}` does not have a fixed maximum value, so half-open ranges are \
necessary to match exhaustively",
"`{ty}::MAX` is not treated as exhaustive, \
so half-open ranges are necessary to match exhaustively",
));
} else if ty.inner() == cx.tcx.types.isize {
err.note(format!(
"`{ty}` does not have fixed minimum and maximum values, so half-open \
ranges are necessary to match exhaustively",
"`{ty}::MIN` and `{ty}::MAX` are not treated as exhaustive, \
so half-open ranges are necessary to match exhaustively",
));
}
} else if ty.inner() == cx.tcx.types.str_ {
Expand Down
Loading
Loading