about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/debuginfo
AgeCommit message (Collapse)AuthorLines
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.
2025-06-03Remove get_dbg_loc from DebugInfoBuilderMethodsbjorn3-4/+6
It is only used within cg_llvm.
2025-05-04Initial support for dynamically linked cratesBryanskiy-1/+5
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-6/+3
async_drop_in_place::{closure}, scoped async drop added.
2025-04-18Rollup merge of #138599 - adwinwhite:recursive-overflow, r=wesleywiserMatthias Krüger-0/+50
avoid overflow when generating debuginfo for expanding recursive types Fixes #135093 Fixes #121538 Fixes #107362 Fixes #100618 Fixes #115994 The overflow happens because expanding recursive types keep creating new nested types when recurring into sub fields. I fixed that by returning an empty stub node when expanding recursion is detected.
2025-04-15Revert "Deduplicate template parameter creation"Vadim Petrochenkov-26/+45
This reverts commit 6adc2c1fd6ecde7bf83c8b8fbc71f402ced87054.
2025-04-14Use `newtype_index!`-generated types more idiomaticallyYotam Ofek-3/+1
2025-04-07Prepend temp files with a string per invocation of rustcMichael Goulet-0/+1
2025-04-07Simplify temp path creation a bitMichael Goulet-1/+1
2025-03-18Create a safe wrapper around `LLVMRustDIBuilderCreateMemberType`Oli Scherer-42/+60
2025-03-18Avoid splitting up a layoutOli Scherer-22/+24
2025-03-17Create a safe wrapper around `LLVMRustDIBuilderCreateBasicType`Oli Scherer-31/+36
2025-03-17Create a safe wrapper function around `LLVMRustDIBuilderCreateFile`Oli Scherer-33/+26
2025-03-17Create a safe wrapper around `LLVMRustDIBuilderCreateSubroutineType`Oli Scherer-12/+13
2025-03-17Deduplicate template parameter creationOli Scherer-45/+26
2025-03-17Immediately create an `Option` instead of reallocating for it laterOli Scherer-6/+6
2025-03-17Create a safe wrapper around LLVMRustDIBuilderCreateTemplateTypeParameterOli Scherer-23/+24
2025-03-17fix(debuginfo): avoid overflow when handling expanding recursive typeAdwin White-0/+50
2025-02-19Rollup merge of #137210 - workingjubilee:fixup-passmode-import, r=RalfJungMatthias Krüger-9/+11
compiler: Stop reexporting stuff in cg_llvm::abi The reexports confuse tooling like rustdoc into thinking cg_llvm is the source of key types that originate in rustc_target.
2025-02-18compiler: Stop reexporting stuff in cg_llvm::abiJubilee Young-9/+11
The reexports confuse tooling like rustdoc into thinking cg_llvm is the source of key types that originate in rustc_target.
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-1/+1
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-13Rollup merge of #136895 - maurer:fix-enum-discr, r=nikicJubilee-1/+7
debuginfo: Set bitwidth appropriately in enum variant tags Previously, we unconditionally set the bitwidth to 128-bits, the largest an enum would possibly be. Then, LLVM would cut down the constant by chopping off leading zeroes before emitting the DWARF. LLVM only supported 64-bit enumerators, so this would also have occasionally resulted in truncated data. LLVM added support for 128-bit enumerators in llvm/llvm-project#125578 That patchset trusts the constant to describe how wide the variant tag is, so the high 64-bits of zeros are considered potentially load-bearing. As a result, we went from emitting tags that looked like: DW_AT_discr_value (0xfe) (because `dwarf::BestForm` selected `data1`) to emitting tags that looked like: DW_AT_discr_value (<0x10> fe ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ) This makes the `DW_AT_discr_value` encode at the bitwidth of the tag, which: 1. Is probably closer to our intentions in terms of describing the data. 2. Doesn't invoke the 128-bit support which may not be supported by all debuggers / downstream tools. 3. Will result in smaller debug information.
2025-02-12debuginfo: Set bitwidth appropriately in enum variant tagsMatthew Maurer-1/+7
Previously, we unconditionally set the bitwidth to 128-bits, the largest an discrimnator would possibly be. Then, LLVM would cut down the constant by chopping off leading zeroes before emitting the DWARF. LLVM only supported 64-bit descriminators, so this would also have occasionally resulted in truncated data (or an assert) if more than 64-bits were used. LLVM added support for 128-bit enumerators in llvm/llvm-project#125578 That patchset also trusts the constant to describe how wide the variant tag is. As a result, we went from emitting tags that looked like: DW_AT_discr_value (0xfe) (`form1`) to emitting tags that looked like: DW_AT_discr_value (<0x10> fe ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ) This makes the `DW_AT_discr_value` encode at the bitwidth of the tag, which: 1. Is probably closer to our intentions in terms of describing the data. 2. Doesn't invoke the 128-bit support which may not be supported by all debuggers / downstream tools. 3. Will result in smaller debug information.
2025-02-11Document some safety constraints and use more safe wrappersOli Scherer-1/+1
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-8/+11
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
2025-02-09Rollup merge of #136659 - wesleywiser:dwarf_version_lto_merge_behavior, ↵Urgau-1/+5
r=jieyouxu Pick the max DWARF version when LTO'ing modules with different versions Currently, when rustc compiles code with `-Clto` enabled that was built with different choices for `-Zdwarf-version`, a warning will be reported. It's very easy to observe this by compiling most anything (eg, "hello world") and specifying `-Clto -Zdwarf-version=5` since the standard library is distributed with `-Zdwarf-version=4`. This behavior isn't actually useful for a few reasons: - From observation, LLVM chooses to pick the highest DWARF version anyway after issuing the warning. - Clang specifies that in this case, the max version should be picked without a warning and as a general principle, we want to support x-lang LTO with Clang which implies using the same module flag merge behaviors. - Debuggers need to be able to handle a variety of versions within the same debugging session as you can easily have some parts of a binary (or some dynamic libraries within an application) all compiled with different DWARF versions. This commit changes the module flag merge behavior to match Clang and use the highest version of DWARF. It also adds a test to ensure this behavior is respected in the case of two crates being LTO'd together and adds a test to ensure no warning is printed. Fixes #130041 which fails due to these warnings being printed cc #103057
2025-02-08Rustfmtbjorn3-8/+11