summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/debuginfo
AgeCommit message (Collapse)AuthorLines
2021-06-02Respond to review feedbackWesley Wiser-62/+28
2021-06-02Change the type name from `_enum<..>` to `enum$<..>`Wesley Wiser-3/+3
This makes the type name inline with the proposed standard in #85269.
2021-06-02Respond to review feedbackWesley Wiser-3/+33
2021-06-02Make tidy happyWesley Wiser-4/+10
2021-06-02Generate better debuginfo for niche-layout enumsWesley Wiser-72/+127
Previously, we would generate a single struct with the layout of the dataful variant plus an extra field whose name contained the value of the niche (this would only really work for things like `Option<&_>` where we can determine that the `None` case maps to `0` but for enums that have multiple tag only variants, this doesn't work). Now, we generate a union of two structs, one which is the layout of the dataful variant and one which just has a way of reading the discriminant. We also generate an enum which maps the discriminant value to the tag only variants. We also encode information about the range of values which correspond to the dataful variant in the type name and then use natvis to determine which union field we should display to the user. As a result of this change, all niche-layout enums render correctly in WinDbg and Visual Studio!
2021-06-02Remove fallback for containing scopesWesley Wiser-9/+2
This wasn't necessary for msvc and caused issues where different types with the same name such as different instantiations of `Option<T>` would have colliding debuginfo. This confused the debugger which would pick one of the type definitions and use for all types with that name even though they had different layout.
2021-06-02Resolve EnumTagInfo FIXMEWesley Wiser-15/+11
2021-06-02Generate better debuginfo for directly tagged enumsWesley Wiser-4/+5
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-9/+7
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-12Use () for codegen queries.Camille GILLOT-7/+5
2021-05-12Use () for entry_fn.Camille GILLOT-2/+2
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-4/+4
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-05Use local and remapped paths where appropriateAndy Wang-2/+2
2021-05-05Revamp RealFileName public methodsAndy Wang-2/+2
2021-05-05Use RealFileName for Session::working_dir as it may also be remappedAndy Wang-2/+2
2021-05-02Rollup merge of #84752 - lrh2000:generator-debuginfo, r=tmandryDylan DPC-30/+34
Fix debuginfo for generators First, all fields except the discriminant (including `outer_fields`) should be put into structures inside the variant part, which gives an equivalent layout but offers us much better integration with debuggers. Second, artificial flags in generator variants should be removed. - Literally, variants are not artificial. We have `yield` statements, upvars and inner variables in the source code. - Functionally, we don't want debuggers to suppress the variants. It contains the state of the generator, which is useful when debugging. So they shouldn't be marked artificial. - Debuggers may use artificial flags to find the active variant. In this case, marking variants artificial will make debuggers not work properly. Fixes #62572. Fixes #79009. And refer https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Debuginfo.20for.20generators.
2021-04-30Remove artificial flag from generator variantslrh2000-25/+8
- Literally, variants are not artificial. We have `yield` statements, upvars and inner variables in the source code. - Functionally, we don't want debuggers to suppress the variants. It contains the state of the generator, which is useful when debugging. So they shouldn't be marked artificial. - Debuggers may use artificial flags to find the active variant. In this case, marking variants artificial will make debuggers not work properly. Fixes #79009.
2021-04-30Move outer fields of enums into variant parts in debuginfolrh2000-5/+26
All fields except the discriminant (including `outer_fields`) should be put into structures inside the variant part, which gives an equivalent layout but offers us much better integration with debuggers.
2021-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-1/+1
2021-04-05Rollup merge of #80525 - devsnek:wasm64, r=nagisaDylan DPC-2/+2
wasm64 support There is still some upstream llvm work needed before this can land.
2021-04-04wasm64Gus Caplan-2/+2
2021-03-26Use iter::zip in compiler/Josh Stone-9/+4
2021-03-20Cleanup LLVM debuginfo module docsCamelid-14/+15
* Use Markdown list syntax and unindent a bit to prevent Markdown interpreting the nested lists as code blocks * A few more small typographical cleanups
2021-03-20Move debuginfo docs from `doc.rs` module to `doc.md` fileCamelid-181/+180
And use `#[doc = include_str!("doc.md")]` in `mod.rs` so the docs are rendered as if they were inline in the root module.
2021-03-07Auto merge of #82285 - nhwn:nonzero-debug, r=nagisabors-25/+15
Use u32 over Option<u32> in DebugLoc ~~Changes `Option<u32>` fields in `DebugLoc` to `Option<NonZeroU32>`. Since the respective fields (`line` and `col`) are guaranteed to be 1-based, this layout optimization is a freebie.~~ EDIT: Changes `Option<u32>` fields in `DebugLoc` to `u32`. As `@bugadani` pointed out, an `Option<NonZeroU32>` is probably an unnecessary layer of abstraction since the `None` variant is always used as `UNKNOWN_LINE_NUMBER` (which is just `0`). Also, `SourceInfo` in `metadata.rs` already uses a `u32` instead of an `Option<u32>` to encode the same information, so I think this change is warranted. Since `@jyn514` raised some concerns over measuring performance in a similar PR (#82255), does this need a perf run?
2021-03-01Box generator-related Body fieldsDániel Buga-1/+1
2021-02-27Rollup merge of #82057 - upsuper-forks:cstr, r=davidtwco,wesleywiserDylan DPC-3/+3
Replace const_cstr with cstr crate This PR replaces the `const_cstr` macro inside `rustc_data_structures` with `cstr` macro from [cstr](https://crates.io/crates/cstr) crate. The two macros basically serve the same purpose, which is to generate `&'static CStr` from a string literal. `cstr` is better because it validates the literal at compile time, while the existing `const_cstr` does it at runtime when `debug_assertions` is enabled. In addition, the value `cstr` generates can be used in constant context (which is seemingly not needed anywhere currently, though).
2021-02-25fix reviewklensy-5/+4
2021-02-24replaced some map_or with map_or_elseklensy-4/+5
2021-02-20nhwn: use plain u32 in DebugLocNathan Nguyen-26/+15
2021-02-20nhwn: use Option<NonZeroU32> in DebugLocNathan Nguyen-12/+13
2021-02-14Set path of the compile unit to the source directorySimonas Kazlauskas-8/+11
As part of the effort to implement split dwarf debug info, we ended up setting the compile unit location to the output directory rather than the source directory. Furthermore, it seems like we failed to remap the prefixes for this as well! The desired behaviour is to instead set the `DW_AT_GNU_dwo_name` to a path relative to compiler's working directory. This still allows debuggers to find the split dwarf files, while not changing the behaviour of the code that is compiling with regular debug info, and not changing the compiler's behaviour with regards to reproducibility. Fixes #82074
2021-02-14Replace const_cstr with cstr crateXidorn Quan-3/+3
2021-01-29Rollup merge of #79570 - alexcrichton:split-debuginfo, r=bjorn3Yuki Okushi-4/+7
rustc: Stabilize `-Zrun-dsymutil` as `-Csplit-debuginfo` This commit adds a new stable codegen option to rustc, `-Csplit-debuginfo`. The old `-Zrun-dsymutil` flag is deleted and now subsumed by this stable flag. Additionally `-Zsplit-dwarf` is also subsumed by this flag but still requires `-Zunstable-options` to actually activate. The `-Csplit-debuginfo` flag takes one of three values: * `off` - This indicates that split-debuginfo from the final artifact is not desired. This is not supported on Windows and is the default on Unix platforms except macOS. On macOS this means that `dsymutil` is not executed. * `packed` - This means that debuginfo is desired in one location separate from the main executable. This is the default on Windows (`*.pdb`) and macOS (`*.dSYM`). On other Unix platforms this subsumes `-Zsplit-dwarf=single` and produces a `*.dwp` file. * `unpacked` - This means that debuginfo will be roughly equivalent to object files, meaning that it's throughout the build directory rather than in one location (often the fastest for local development). This is not the default on any platform and is not supported on Windows. Each target can indicate its own default preference for how debuginfo is handled. Almost all platforms default to `off` except for Windows and macOS which default to `packed` for historical reasons. Some equivalencies for previous unstable flags with the new flags are: * `-Zrun-dsymutil=yes` -> `-Csplit-debuginfo=packed` * `-Zrun-dsymutil=no` -> `-Csplit-debuginfo=unpacked` * `-Zsplit-dwarf=single` -> `-Csplit-debuginfo=packed` * `-Zsplit-dwarf=split` -> `-Csplit-debuginfo=unpacked` Note that `-Csplit-debuginfo` still requires `-Zunstable-options` for non-macOS platforms since split-dwarf support was *just* implemented in rustc. There's some more rationale listed on #79361, but the main gist of the motivation for this commit is that `dsymutil` can take quite a long time to execute in debug builds and provides little benefit. This means that incremental compile times appear that much worse on macOS because the compiler is constantly running `dsymutil` over every single binary it produces during `cargo build` (even build scripts!). Ideally rustc would switch to not running `dsymutil` by default, but that's a problem left to get tackled another day. Closes #79361
2021-01-28rustc: Stabilize `-Zrun-dsymutil` as `-Csplit-debuginfo`Alex Crichton-4/+7
This commit adds a new stable codegen option to rustc, `-Csplit-debuginfo`. The old `-Zrun-dsymutil` flag is deleted and now subsumed by this stable flag. Additionally `-Zsplit-dwarf` is also subsumed by this flag but still requires `-Zunstable-options` to actually activate. The `-Csplit-debuginfo` flag takes one of three values: * `off` - This indicates that split-debuginfo from the final artifact is not desired. This is not supported on Windows and is the default on Unix platforms except macOS. On macOS this means that `dsymutil` is not executed. * `packed` - This means that debuginfo is desired in one location separate from the main executable. This is the default on Windows (`*.pdb`) and macOS (`*.dSYM`). On other Unix platforms this subsumes `-Zsplit-dwarf=single` and produces a `*.dwp` file. * `unpacked` - This means that debuginfo will be roughly equivalent to object files, meaning that it's throughout the build directory rather than in one location (often the fastest for local development). This is not the default on any platform and is not supported on Windows. Each target can indicate its own default preference for how debuginfo is handled. Almost all platforms default to `off` except for Windows and macOS which default to `packed` for historical reasons. Some equivalencies for previous unstable flags with the new flags are: * `-Zrun-dsymutil=yes` -> `-Csplit-debuginfo=packed` * `-Zrun-dsymutil=no` -> `-Csplit-debuginfo=unpacked` * `-Zsplit-dwarf=single` -> `-Csplit-debuginfo=packed` * `-Zsplit-dwarf=split` -> `-Csplit-debuginfo=unpacked` Note that `-Csplit-debuginfo` still requires `-Zunstable-options` for non-macOS platforms since split-dwarf support was *just* implemented in rustc. There's some more rationale listed on #79361, but the main gist of the motivation for this commit is that `dsymutil` can take quite a long time to execute in debug builds and provides little benefit. This means that incremental compile times appear that much worse on macOS because the compiler is constantly running `dsymutil` over every single binary it produces during `cargo build` (even build scripts!). Ideally rustc would switch to not running `dsymutil` by default, but that's a problem left to get tackled another day. Closes #79361
2021-01-18Use ty::{IntTy,UintTy,FloatTy} in rustcLeSeulArtichaut-18/+17
2021-01-15Rollup merge of #81008 - tmiasko:generator-layout-err, r=tmandryYuki Okushi-2/+3
Don't ICE when computing a layout of a generator tainted by errors Fixes #80998.
2021-01-14Don't ICE when computing a layout of a generator tainted by errorsTomasz Miąsko-2/+3
2021-01-13Remove the unused context from CreateDebugLocationJosh Stone-1/+0
This went unused in commit 88d874de6395, part of #68965.
2020-12-30remove unused return types such as empty Results or Options that would ↵Matthias Krüger-4/+4
always be Some(..) remove unused return type of dropck::check_drop_obligations() don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..) remove redundant return type of back::write::optimize() don't Option-wrap return type of compute_type_parameters() since we always return Some(..) don't return empty Result in assemble_generator_candidates() don't return empty Result in assemble_closure_candidates() don't return empty result in assemble_fn_pointer_candidates() don't return empty result in assemble_candidates_from_impls() don't return empty result in assemble_candidates_from_auto_impls() don't return emtpy result in assemble_candidates_for_trait_alias() don't return empty result in assemble_builtin_bound_candidates() don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait() remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..) remove unused return type of assemble_extension_candidates_for_all_traits()
2020-12-16cg_llvm: split dwarf filename and comp dirDavid Wood-4/+6
llvm-dwp concatenates `DW_AT_comp_dir` with `DW_AT_GNU_dwo_name` (only when `DW_AT_comp_dir` exists), which can result in it failing to find the DWARF object files. In earlier testing, `DW_AT_comp_dir` wasn't present in the final object and the current directory was the output directory. When running tests through compiletest, the working directory of the compilation is different from output directory and that resulted in `DW_AT_comp_dir` being in the object file (and set to the current working directory, rather than the output directory), and `DW_AT_GNU_dwo_name` being set to the full path (rather than just the filename), so llvm-dwp was failing. This commit changes the compilation directory provided to LLVM to match the output directory, where DWARF objects are output; and ensures that only the filename is used for `DW_AT_GNU_dwo_name`. Signed-off-by: David Wood <david@davidtw.co>
2020-12-16cg_llvm: implement split dwarf supportDavid Wood-2/+6
This commit implements Split DWARF support, wiring up the flag (added in earlier commits) to the modified FFI wrapper (also from earlier commits). Signed-off-by: David Wood <david@davidtw.co>
2020-12-16llvm: update ffi bindings for split dwarfDavid Wood-0/+2
This commit modifies the FFI bindings to LLVM required for Split DWARF support in rustc. In particular: - `addPassesToEmitFile`'s wrapper, `LLVMRustWriteOutputFile` now takes a `DwoPath` `const char*`. When disabled, `nullptr` should be provided which will preserve existing behaviour. When enabled, the path to the `.dwo` file should be provided. - `createCompileUnit`'s wrapper, `LLVMRustDIBuilderCreateCompileUnit` now has two additional arguments, for the `DWOId` and to enable `SplitDebugInlining`. `DWOId` should always be zero. - `createTargetMachine`'s wrapper, `LLVMRustCreateTargetMachine` has an additional argument which should be provided the path to the `.dwo` when enabled. Signed-off-by: David Wood <david@davidtw.co>
2020-12-06[mir-opt] Allow debuginfo to be generated for a constant or a PlaceWesley Wiser-2/+3
Prior to this commit, debuginfo was always generated by mapping a name to a Place. This has the side-effect that `SimplifyLocals` cannot remove locals that are only used for debuginfo because their other uses have been const-propagated. To allow these locals to be removed, we now allow debuginfo to point to a constant value. The `ConstProp` pass detects when debuginfo points to a local with a known constant value and replaces it with the value. This allows the later `SimplifyLocals` pass to remove the local.
2020-11-23Use Option::map instead of open coding itLingMan-4/+1
2020-11-16compiler: fold by valueBastian Kauschke-4/+4
2020-11-08Collapse all uses of `target.options.foo` into `target.foo`Vadim Petrochenkov-8/+8
with an eye on merging `TargetOptions` into `Target`. `TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
2020-11-04`u128` truncation and sign extension are not just interpreter relatedoli-2/+1
2020-11-03Rollup merge of #77950 - arlosi:sha256, r=eddybMara Bos-0/+1
Add support for SHA256 source file hashing Adds support for `-Z src-hash-algorithm sha256`, which became available in LLVM 11. Using an older version of LLVM will cause an error `invalid checksum kind` if the hash algorithm is set to sha256. r? `@eddyb` cc #70401 `@est31`
2020-10-30Fix even more clippy warningsJoshua Nelson-1/+1