about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/debuginfo
AgeCommit message (Collapse)AuthorLines
2025-10-03Auto merge of #142771 - dianqk:mir-stmt-debuginfo, r=cjgillotbors-2/+54
Introduce debuginfo to statements in MIR The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix rust-lang/rust#128081. I don't modify Stable MIR, as I don't think we need debug information when using it. This PR represents the debug information for the dead reference statement via `#dbg_value`. For example, `let _foo_b = &foo.b` becomes `#dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26)`. You can see this here: https://rust.godbolt.org/z/d43js6adv. The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR. The current rules for dropping debug information in this PR are: - If the LLVM IR cannot represent a reference address, it's replaced with poison or simply dropped. For example, see: https://rust.godbolt.org/z/shGqPec8W. I'm using poison in all such cases now. - All debuginfos is dropped when merging multiple successor BBs. An example is available here: https://rust.godbolt.org/z/TE1q3Wq6M. I doesn't drop debuginfos in `MatchBranchSimplification`, because LLVM also pick one branch for it.
2025-10-02Extract helper method `global_set_metadata_node`Zalathar-5/+2
2025-10-02Extract helper method `global_add_metadata_node`Zalathar-6/+3
2025-10-02codegen: Generate `dbg_value` for the ref statementdianqk-2/+54
2025-09-30Replace `MetadataType` with the `MetadataKindId` constantsZalathar-6/+2
2025-09-28remove explicit deref of AbiAlign for most methodsJubilee Young-3/+3
Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed. For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference.
2025-09-28Rollup merge of #146763 - Zalathar:di-builder, r=jdonszelmannMatthias Krüger-40/+45
cg_llvm: Replace some DIBuilder wrappers with LLVM-C API bindings (part 5) - Part of rust-lang/rust#134001 - Follow-up to rust-lang/rust#146673 --- This is another batch of LLVMDIBuilder binding migrations, replacing some our own LLVMRust bindings with bindings to upstream LLVM-C APIs. Some of these are a little more complex than most of the previous migrations, because they split one LLVMRust binding into multiple LLVM bindings, but nothing too fancy. This appears to be the last of the low-hanging fruit. As noted in https://github.com/rust-lang/rust/issues/134001#issuecomment-2524979268, the remaining bindings are difficult or impossible to migrate at present.
2025-09-26Rollup merge of #146704 - jdonszelmann:port-debug-visualizer, r=petrochenkovMatthias Krüger-1/+1
port `#[debugger_visualizer]` to the new attribute system
2025-09-25Rollup merge of #146667 - calebzulawski:simd-mono-lane-limit, r=lcnr,RalfJungStuart Cook-4/+6
Add an attribute to check the number of lanes in a SIMD vector after monomorphization Allows std::simd to drop the `LaneCount<N>: SupportedLaneCount` trait and maintain good error messages. Also, extends rust-lang/rust#145967 by including spans in layout errors for all ADTs. r? ``@RalfJung`` cc ``@workingjubilee`` ``@programmerjake``
2025-09-23Including spans in layout errors for all ADTsCaleb Zulawski-4/+6
2025-09-21port `#[debugger_visualizer]` to the new attribute systemJana Dönszelmann-1/+1
2025-09-19Remove some unnecessary `as u64` castsZalathar-4/+4
In each of these casts, the LHS is already `u64`.
2025-09-19Use `LLVMDIBuilderCreate(Auto|Parameter)Variable`Zalathar-28/+30
2025-09-19Use `LLVMDIBuilder(CreateExpression|InsertDeclareRecordAtEnd)`Zalathar-6/+9
2025-09-19Use `LLVMDIBuilderGetOrCreateArray`Zalathar-1/+1
2025-09-19Use `LLVMDIBuilderGetOrCreateSubrange`Zalathar-1/+1
2025-09-17Use `LLVMDIBuilderCreateTypedef`Zalathar-4/+5
2025-09-17Use `LLVMDIBuilderCreateQualifiedType`Zalathar-3/+5
2025-09-17Use `LLVMDIBuilderCreateStaticMemberType`Zalathar-21/+44
2025-09-17Use `LLVMDIBuilderCreateMemberType`Zalathar-2/+2
2025-09-17Use `LLVMDIBuilderCreateStructType`Zalathar-7/+7
2025-09-17Use `LLVMDIBuilderCreatePointerType`Zalathar-33/+35
2025-09-17Use `LLVMDIBuilderCreateBasicType`Zalathar-2/+3
2025-09-17Use `LLVMDIBuilderCreateArrayType`Zalathar-8/+6
2025-09-17Use `LLVMDIBuilderCreateUnionType`Zalathar-5/+8
2025-09-17Use `LLVMDIBuilderCreateSubroutineType`Zalathar-7/+15
2025-09-09Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnrbors-2/+2
rename erase_regions to erase_and_anonymize_regions I find it consistently confusing that `erase_regions` does more than replacing regions with `'erased`. it also makes some code look real goofy to be writing manual folders to erase regions with a comment saying "we cant use erase regions" :> or code that re-calls erase_regions on types with regions already erased just to anonymize all the bound regions. r? lcnr idk how i feel about the name being almost twice as long now
2025-09-09erase_regions to erase_and_anonymize_regionsBoxy-2/+2
2025-08-30compiler: Include span of too huge array with `-Cdebuginfo=2`Martin Nordholts-3/+4
We have a few ui tests to ensure we emit an error if we encounter too big arrays. Before this fix, compiling the tests with `-Cdebuginfo=2` would not include the spans of the instantiation sites, because the error is then emitted from a different code path that does not include the span. Propagate the span to the error also in the debuginfo case, so the tests passes regardless of debuginfo level.
2025-08-28compiler: Include span of too huge enum with -Cdebuginfo=2Martin Nordholts-6/+19
We have a ui test to ensure we emit an error if we encounter too big enums. Before this fix, compiling the test with `-Cdebuginfo=2` would not include the span of the instantiation site, because the error is then emitted from a different code path that does not include the span. Propagate the span to the error also in the debuginfo case, so the test passes regardless of debuginfo level.
2025-08-24Rename `llvm::Bool` aliases to standard const caseZalathar-2/+2
This avoids the need for `#![allow(non_upper_case_globals)]`.
2025-08-21Rollup merge of #145297 - adwinwhite:recursive-debuginfo, r=wesleywiserJacob Pratt-16/+38
fix(debuginfo): handle false positives in overflow check Fixes rust-lang/rust#144636. Duplicate wrappers and normal recursive types can lead to false positives. ```rust struct Recursive { a: Box<Box<Recursive>>, } ``` The ADT stack can be: - `Box<Recursive>` - `Recursive` - `Box<Box<Recursive>>` (`Box` now detected as expanding) We can filter them out by tracing the generic arg back through the stack, as true expanding recursive types must have their expanding arg used as generic arg throughout. r? ````@wesleywiser````
2025-08-13Cleanup assoc parent utilsCameron Steffen-24/+19
2025-08-12fix(debuginfo): handle false positives in overflow checkAdwin White-16/+38
2025-08-06Revert "Preserve the .debug_gdb_scripts section"bjorn3-38/+28
This reverts commit 868bdde25b030e0b71a29a5dbc04a891036e702e.
2025-08-06Revert "Embed GDB pretty printers in rlibs and dylibs"bjorn3-11/+32
This reverts commit b4d923cea0509933b1fb859930cb20784251f9be.
2025-08-06Embed GDB pretty printers in rlibs and dylibsSebastian Poeplau-32/+11
Instead of collecting pretty printers transitively when building executables/staticlibs/cdylibs, let the debugger find each crate's pretty printers via its .debug_gdb_scripts section. This covers the case where libraries defining custom pretty printers are loaded dynamically.
2025-08-05Preserve the .debug_gdb_scripts sectionSebastian Poeplau-28/+38
Make sure that compiler and linker don't optimize the section's contents away by adding the global holding the data to "llvm.used". The volatile load in the main shim is retained because "llvm.used", which translates to SHF_GNU_RETAIN on ELF targets, requires a reasonably recent linker; emitting the volatile load ensures compatibility with older linkers, at least when libstd is used. Pretty printers in dylib dependencies are now emitted by the main crate instead of the dylib; apart from matching how rlibs are handled, this approach has the advantage that `omit_gdb_pretty_printer_section` keeps working with dylib dependencies.
2025-08-01Remove the omit_gdb_pretty_printer_section attributebjorn3-7/+1
Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-1/+2
2025-07-29Rollup merge of #144407 - godzie44:godzie44/fix_dwarf_inconsistency, ↵Stuart Cook-2/+2
r=wesleywiser fix(debuginfo): disable overflow check for recursive non-enum types Commit b10edb4 introduce an overflow check when generating debuginfo for expanding recursive types. While this check works correctly for enums, it can incorrectly prune valid debug information for structures. For example see rust-lang/rust#143241 (https://github.com/rust-lang/rust/issues/143241#issuecomment-3073721477). Furthermore, for structures such check does not make sense, since structures with recursively expanding types simply will not compile (there is a `hir_analysis_recursive_generic_parameter` for that). closes rust-lang/rust#143241
2025-07-28Rename impl_of_method -> impl_of_assocCameron Steffen-1/+1
2025-07-27fix(debuginfo): disable overflow check forgodzie44-2/+2
recursive non-enum types
2025-07-16Rollup merge of #143920 - oli-obk:cg-llvm-safety, r=jieyouxuSamuel Tardieu-8/+4
Make more of codegen_llvm safe Best reviewed commit-by-commit.
2025-07-14Eliminate all direct uses of LLVMMDStringInContext2Oli Scherer-1/+1
2025-07-14Use context methods instead of directly calling FFIOli Scherer-6/+2
2025-07-14Avoid a bunch of unnecessary `unsafe` blocks in cg_llvmOli Scherer-2/+2
2025-07-12Port `#[omit_gdb_pretty_printer_section]` to the new attribute parsing ↵Jonathan Brouwer-3/+2
infrastructure Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-07compiler: Parse `p-` specs in datalayout string, allow definition of custom ↵Edoardo Marangoni-5/+9
default data address space
2025-06-03Change `tag_field` to `FieldIdx` in `Variants::Multiple`Scott McMurray-8/+8
It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.