Skip to content

Commit 1dfbc5f

Browse files
committed
Auto merge of #147114 - Zalathar:rollup-vh9cxm0, r=Zalathar
Rollup of 16 pull requests Successful merges: - #142139 (Include additional hashes in src/stage0) - #146745 (Clarified error note for usize range matching) - #146763 (cg_llvm: Replace some DIBuilder wrappers with LLVM-C API bindings (part 5)) - #146788 (chore: removes deprecated discord.) - #146942 ([rustdoc] Finish getting rid of usages `write_str`) - #147002 (rustdoc-search: stringdex update with more packing) - #147061 (fix rebasing cycle heads when not reaching a fixpoint) - #147066 (Fix tracking issue number for feature(macro_attr)) - #147081 (doc: fix a typo in platform-support.md) - #147082 (formatting_options: fix alternate docs 0b/0o mixup) - #147086 (compiletest: Use `PanicHookInfo::payload_as_str` now that it's stable in beta) - #147092 (Do not compute optimized MIR if code does not type-check.) - #147093 (redox: switch to colon as path separator) - #147095 (Library: Remove remaining private `#[repr]` workarounds) - #147098 (Add auto extra-checks in pre-push hook) - #147110 (Fix typo) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c7f6aa2 + 5781e6f commit 1dfbc5f

File tree

45 files changed

+1115
-999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1115
-999
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ bootstrapping, the compiler architecture, source code representation, and more.
3131

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

34-
There are many ways you can get help when you're stuck. Rust has many platforms for this:
35-
[internals], [rust-zulip], and [rust-discord]. It is recommended to ask for help on
34+
There are many ways you can get help when you're stuck. Rust has two platforms for this:
35+
[internals] and [rust-zulip]. It is recommended to ask for help on
3636
the [rust-zulip], but any of these platforms are great ways to seek help and even
3737
find a mentor! You can learn more about asking questions and getting help in the
3838
[Asking Questions](https://rustc-dev-guide.rust-lang.org/getting-started.html#asking-questions) chapter of the [rustc-dev-guide].
@@ -47,5 +47,4 @@ refer to [this section][contributing-bug-reports] and [open an issue][issue temp
4747
[contributing-bug-reports]: https://rustc-dev-guide.rust-lang.org/contributing.html#bug-reports
4848
[issue template]: https://github.com/rust-lang/rust/issues/new/choose
4949
[internals]: https://internals.rust-lang.org
50-
[rust-discord]: http://discord.gg/rust-lang
5150
[rust-zulip]: https://rust-lang.zulipchat.com

Cargo.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ dependencies = [
334334
"anyhow",
335335
"build_helper",
336336
"curl",
337+
"hex",
337338
"indexmap",
338339
"serde",
340+
"sha2",
339341
"toml 0.8.23",
340342
]
341343

@@ -5239,9 +5241,9 @@ dependencies = [
52395241

52405242
[[package]]
52415243
name = "stringdex"
5242-
version = "0.0.1-alpha9"
5244+
version = "0.0.1-alpha10"
52435245
source = "registry+https://github.com/rust-lang/crates.io-index"
5244-
checksum = "7081029913fd7d591c0112182aba8c98ae886b4f12edb208130496cd17dc3c15"
5246+
checksum = "0fa846a7d509d1828a4f90962dc09810e161abcada7fc6a921e92c168d0811d7"
52455247
dependencies = [
52465248
"stacker",
52475249
]

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
117117
.try_to_target_usize(cx.tcx)
118118
.expect("expected monomorphic const in codegen") as c_longlong;
119119

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

123123
let di_node = unsafe {

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ mod utils;
5252
use self::create_scope_map::compute_mir_scopes;
5353
pub(crate) use self::metadata::build_global_var_di_node;
5454

55-
// FIXME(Zalathar): These `DW_TAG_*` constants are fake values that were
56-
// removed from LLVM in 2015, and are only used by our own `RustWrapper.cpp`
57-
// to decide which C++ API to call. Instead, we should just have two separate
58-
// FFI functions and choose the correct one on the Rust side.
59-
#[allow(non_upper_case_globals)]
60-
const DW_TAG_auto_variable: c_uint = 0x100;
61-
#[allow(non_upper_case_globals)]
62-
const DW_TAG_arg_variable: c_uint = 0x101;
63-
6455
/// A context object for maintaining all state needed by the debuginfo module.
6556
pub(crate) struct CodegenUnitDebugContext<'ll, 'tcx> {
6657
llmod: &'ll llvm::Module,
@@ -174,35 +165,38 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
174165

175166
if direct_offset.bytes() > 0 {
176167
addr_ops.push(DW_OP_plus_uconst);
177-
addr_ops.push(direct_offset.bytes() as u64);
168+
addr_ops.push(direct_offset.bytes());
178169
}
179170
for &offset in indirect_offsets {
180171
addr_ops.push(DW_OP_deref);
181172
if offset.bytes() > 0 {
182173
addr_ops.push(DW_OP_plus_uconst);
183-
addr_ops.push(offset.bytes() as u64);
174+
addr_ops.push(offset.bytes());
184175
}
185176
}
186177
if let Some(fragment) = fragment {
187178
// `DW_OP_LLVM_fragment` takes as arguments the fragment's
188179
// offset and size, both of them in bits.
189180
addr_ops.push(DW_OP_LLVM_fragment);
190-
addr_ops.push(fragment.start.bits() as u64);
191-
addr_ops.push((fragment.end - fragment.start).bits() as u64);
181+
addr_ops.push(fragment.start.bits());
182+
addr_ops.push((fragment.end - fragment.start).bits());
192183
}
193184

185+
let di_builder = DIB(self.cx());
186+
let addr_expr = unsafe {
187+
llvm::LLVMDIBuilderCreateExpression(di_builder, addr_ops.as_ptr(), addr_ops.len())
188+
};
194189
unsafe {
195190
// FIXME(eddyb) replace `llvm.dbg.declare` with `llvm.dbg.addr`.
196-
llvm::LLVMRustDIBuilderInsertDeclareAtEnd(
197-
DIB(self.cx()),
191+
llvm::LLVMDIBuilderInsertDeclareRecordAtEnd(
192+
di_builder,
198193
variable_alloca,
199194
dbg_var,
200-
addr_ops.as_ptr(),
201-
addr_ops.len() as c_uint,
195+
addr_expr,
202196
dbg_loc,
203197
self.llbb(),
204-
);
205-
}
198+
)
199+
};
206200
}
207201

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

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

633-
let (argument_index, dwarf_tag) = match variable_kind {
634-
ArgumentVariable(index) => (index as c_uint, DW_TAG_arg_variable),
635-
LocalVariable => (0, DW_TAG_auto_variable),
636-
};
637627
let align = self.align_of(variable_type);
638628

639629
let name = variable_name.as_str();
640-
unsafe {
641-
llvm::LLVMRustDIBuilderCreateVariable(
642-
DIB(self),
643-
dwarf_tag,
644-
scope_metadata,
645-
name.as_c_char_ptr(),
646-
name.len(),
647-
file_metadata,
648-
loc.line,
649-
type_metadata,
650-
true,
651-
DIFlags::FlagZero,
652-
argument_index,
653-
align.bits() as u32,
654-
)
630+
631+
match variable_kind {
632+
ArgumentVariable(arg_index) => unsafe {
633+
llvm::LLVMDIBuilderCreateParameterVariable(
634+
DIB(self),
635+
scope_metadata,
636+
name.as_ptr(),
637+
name.len(),
638+
arg_index as c_uint,
639+
file_metadata,
640+
loc.line,
641+
type_metadata,
642+
llvm::Bool::TRUE, // (preserve descriptor during optimizations)
643+
DIFlags::FlagZero,
644+
)
645+
},
646+
LocalVariable => unsafe {
647+
llvm::LLVMDIBuilderCreateAutoVariable(
648+
DIB(self),
649+
scope_metadata,
650+
name.as_ptr(),
651+
name.len(),
652+
file_metadata,
653+
loc.line,
654+
type_metadata,
655+
llvm::Bool::TRUE, // (preserve descriptor during optimizations)
656+
DIFlags::FlagZero,
657+
align.bits() as u32,
658+
)
659+
},
655660
}
656661
}
657662
}

compiler/rustc_codegen_llvm/src/debuginfo/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn create_DIArray<'ll>(
2828
builder: &DIBuilder<'ll>,
2929
arr: &[Option<&'ll DIDescriptor>],
3030
) -> &'ll DIArray {
31-
unsafe { llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) }
31+
unsafe { llvm::LLVMDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len()) }
3232
}
3333

3434
#[inline]

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use rustc_target::spec::SymbolVisibility;
2525
use super::RustString;
2626
use super::debuginfo::{
2727
DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
28-
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange,
29-
DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
28+
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram,
29+
DITemplateTypeParameter, DIType, DebugEmissionKind, DebugNameTableKind,
3030
};
3131
use crate::llvm;
3232

@@ -807,6 +807,8 @@ unsafe extern "C" {
807807
pub(crate) type Metadata;
808808
pub(crate) type BasicBlock;
809809
pub(crate) type Comdat;
810+
/// `&'ll DbgRecord` represents `LLVMDbgRecordRef`.
811+
pub(crate) type DbgRecord;
810812
}
811813
#[repr(C)]
812814
pub(crate) struct Builder<'a>(InvariantOpaque<'a>);
@@ -891,7 +893,6 @@ pub(crate) mod debuginfo {
891893
pub(crate) type DIVariable = DIDescriptor;
892894
pub(crate) type DIGlobalVariableExpression = DIDescriptor;
893895
pub(crate) type DIArray = DIDescriptor;
894-
pub(crate) type DISubrange = DIDescriptor;
895896
pub(crate) type DIEnumerator = DIDescriptor;
896897
pub(crate) type DITemplateTypeParameter = DIDescriptor;
897898

@@ -1992,6 +1993,59 @@ unsafe extern "C" {
19921993
Scope: Option<&'ll Metadata>,
19931994
AlignInBits: u32, // (optional; default is 0)
19941995
) -> &'ll Metadata;
1996+
1997+
pub(crate) fn LLVMDIBuilderGetOrCreateSubrange<'ll>(
1998+
Builder: &DIBuilder<'ll>,
1999+
LowerBound: i64,
2000+
Count: i64,
2001+
) -> &'ll Metadata;
2002+
2003+
pub(crate) fn LLVMDIBuilderGetOrCreateArray<'ll>(
2004+
Builder: &DIBuilder<'ll>,
2005+
Data: *const Option<&'ll Metadata>,
2006+
NumElements: size_t,
2007+
) -> &'ll Metadata;
2008+
2009+
pub(crate) fn LLVMDIBuilderCreateExpression<'ll>(
2010+
Builder: &DIBuilder<'ll>,
2011+
Addr: *const u64,
2012+
Length: size_t,
2013+
) -> &'ll Metadata;
2014+
2015+
pub(crate) fn LLVMDIBuilderInsertDeclareRecordAtEnd<'ll>(
2016+
Builder: &DIBuilder<'ll>,
2017+
Storage: &'ll Value,
2018+
VarInfo: &'ll Metadata,
2019+
Expr: &'ll Metadata,
2020+
DebugLoc: &'ll Metadata,
2021+
Block: &'ll BasicBlock,
2022+
) -> &'ll DbgRecord;
2023+
2024+
pub(crate) fn LLVMDIBuilderCreateAutoVariable<'ll>(
2025+
Builder: &DIBuilder<'ll>,
2026+
Scope: &'ll Metadata,
2027+
Name: *const c_uchar, // See "PTR_LEN_STR".
2028+
NameLen: size_t,
2029+
File: &'ll Metadata,
2030+
LineNo: c_uint,
2031+
Ty: &'ll Metadata,
2032+
AlwaysPreserve: llvm::Bool, // "If true, this descriptor will survive optimizations."
2033+
Flags: DIFlags,
2034+
AlignInBits: u32,
2035+
) -> &'ll Metadata;
2036+
2037+
pub(crate) fn LLVMDIBuilderCreateParameterVariable<'ll>(
2038+
Builder: &DIBuilder<'ll>,
2039+
Scope: &'ll Metadata,
2040+
Name: *const c_uchar, // See "PTR_LEN_STR".
2041+
NameLen: size_t,
2042+
ArgNo: c_uint,
2043+
File: &'ll Metadata,
2044+
LineNo: c_uint,
2045+
Ty: &'ll Metadata,
2046+
AlwaysPreserve: llvm::Bool, // "If true, this descriptor will survive optimizations."
2047+
Flags: DIFlags,
2048+
) -> &'ll Metadata;
19952049
}
19962050

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

2361-
pub(crate) fn LLVMRustDIBuilderCreateVariable<'a>(
2362-
Builder: &DIBuilder<'a>,
2363-
Tag: c_uint,
2364-
Scope: &'a DIDescriptor,
2365-
Name: *const c_char,
2366-
NameLen: size_t,
2367-
File: &'a DIFile,
2368-
LineNo: c_uint,
2369-
Ty: &'a DIType,
2370-
AlwaysPreserve: bool,
2371-
Flags: DIFlags,
2372-
ArgNo: c_uint,
2373-
AlignInBits: u32,
2374-
) -> &'a DIVariable;
2375-
2376-
pub(crate) fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
2377-
Builder: &DIBuilder<'a>,
2378-
Lo: i64,
2379-
Count: i64,
2380-
) -> &'a DISubrange;
2381-
2382-
pub(crate) fn LLVMRustDIBuilderGetOrCreateArray<'a>(
2383-
Builder: &DIBuilder<'a>,
2384-
Ptr: *const Option<&'a DIDescriptor>,
2385-
Count: c_uint,
2386-
) -> &'a DIArray;
2387-
2388-
pub(crate) fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
2389-
Builder: &DIBuilder<'a>,
2390-
Val: &'a Value,
2391-
VarInfo: &'a DIVariable,
2392-
AddrOps: *const u64,
2393-
AddrOpsCount: c_uint,
2394-
DL: &'a DILocation,
2395-
InsertAtEnd: &'a BasicBlock,
2396-
);
2397-
23982415
pub(crate) fn LLVMRustDIBuilderCreateEnumerator<'a>(
23992416
Builder: &DIBuilder<'a>,
24002417
Name: *const c_char,

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ declare_features! (
550550
/// Allows fused `loop`/`match` for direct intraprocedural jumps.
551551
(incomplete, loop_match, "1.90.0", Some(132306)),
552552
/// Allow `macro_rules!` attribute rules
553-
(unstable, macro_attr, "1.91.0", Some(83527)),
553+
(unstable, macro_attr, "1.91.0", Some(143547)),
554554
/// Allow `macro_rules!` derive rules
555555
(unstable, macro_derive, "1.91.0", Some(143549)),
556556
/// Give access to additional metadata about declarative macro meta-variables.

compiler/rustc_interface/src/passes.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,18 +1122,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
11221122

11231123
sess.time("layout_testing", || layout_test::test_layout(tcx));
11241124
sess.time("abi_testing", || abi_test::test_abi(tcx));
1125-
1126-
// If `-Zvalidate-mir` is set, we also want to compute the final MIR for each item
1127-
// (either its `mir_for_ctfe` or `optimized_mir`) since that helps uncover any bugs
1128-
// in MIR optimizations that may only be reachable through codegen, or other codepaths
1129-
// that requires the optimized/ctfe MIR, coroutine bodies, or evaluating consts.
1130-
if tcx.sess.opts.unstable_opts.validate_mir {
1131-
sess.time("ensuring_final_MIR_is_computable", || {
1132-
tcx.par_hir_body_owners(|def_id| {
1133-
tcx.instance_mir(ty::InstanceKind::Item(def_id.into()));
1134-
});
1135-
});
1136-
}
11371125
}
11381126

11391127
/// Runs the type-checking, region checking and other miscellaneous analysis
@@ -1199,6 +1187,20 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) {
11991187
// we will fail to emit overlap diagnostics. Thus we invoke it here unconditionally.
12001188
let _ = tcx.all_diagnostic_items(());
12011189
});
1190+
1191+
// If `-Zvalidate-mir` is set, we also want to compute the final MIR for each item
1192+
// (either its `mir_for_ctfe` or `optimized_mir`) since that helps uncover any bugs
1193+
// in MIR optimizations that may only be reachable through codegen, or other codepaths
1194+
// that requires the optimized/ctfe MIR, coroutine bodies, or evaluating consts.
1195+
// Nevertheless, wait after type checking is finished, as optimizing code that does not
1196+
// type-check is very prone to ICEs.
1197+
if tcx.sess.opts.unstable_opts.validate_mir {
1198+
sess.time("ensuring_final_MIR_is_computable", || {
1199+
tcx.par_hir_body_owners(|def_id| {
1200+
tcx.instance_mir(ty::InstanceKind::Item(def_id.into()));
1201+
});
1202+
});
1203+
}
12021204
}
12031205

12041206
/// Runs the codegen backend, after which the AST and analysis can

0 commit comments

Comments
 (0)