Commit Graph

85 Commits

Author SHA1 Message Date
bors 5e842953cc Auto merge of #130052 - khuey:clear-dilocation-after-const-emission, r=michaelwoerister
Don't leave debug locations for constants sitting on the builder indefinitely

Because constants are currently emitted *before* the prologue, leaving the debug location on the IRBuilder spills onto other instructions in the prologue and messes up both line numbers as well as the point LLVM chooses to be the prologue end.

Example LLVM IR (irrelevant IR elided):
Before:
```
define internal { i64, i64 } `@_ZN3tmp3Foo18var_return_opt_try17he02116165b0fc08cE(ptr` align 8 %self) !dbg !347 { start:
  %self.dbg.spill = alloca [8 x i8], align 8
  %_0 = alloca [16 x i8], align 8
  %residual.dbg.spill = alloca [0 x i8], align 1
    #dbg_declare(ptr %residual.dbg.spill, !353, !DIExpression(), !357)
  store ptr %self, ptr %self.dbg.spill, align 8, !dbg !357
    #dbg_declare(ptr %self.dbg.spill, !350, !DIExpression(), !358)
```
After:
```
define internal { i64, i64 } `@_ZN3tmp3Foo18var_return_opt_try17h00b17d08874ddd90E(ptr` align 8 %self) !dbg !347 { start:
  %self.dbg.spill = alloca [8 x i8], align 8
  %_0 = alloca [16 x i8], align 8
  %residual.dbg.spill = alloca [0 x i8], align 1
    #dbg_declare(ptr %residual.dbg.spill, !353, !DIExpression(), !357)
  store ptr %self, ptr %self.dbg.spill, align 8
    #dbg_declare(ptr %self.dbg.spill, !350, !DIExpression(), !358)
```
Note in particular how !357 from %residual.dbg.spill's dbg_declare no longer falls through onto the store to %self.dbg.spill. This fixes argument values at entry when the constant is a ZST (e.g. `<Option as Try>::Residual`). This fixes #130003 (but note that it does *not* fix issues with argument values and non-ZST constants, which emit their own stores that have debug info on them, like #128945).

r? `@michaelwoerister`
2024-09-13 08:57:41 +00:00
Scott McMurray d2309c2a9d Ban non-array SIMD 2024-09-09 19:39:43 -07:00
Kyle Huey 7ed9f945a2 Don't leave debug locations for constants sitting on the builder indefinitely.
Because constants are currently emitted *before* the prologue, leaving the
debug location on the IRBuilder spills onto other instructions in the prologue
and messes up both line numbers as well as the point LLVM chooses to be the
prologue end.

Example LLVM IR (irrelevant IR elided):
Before:

define internal { i64, i64 } @_ZN3tmp3Foo18var_return_opt_try17he02116165b0fc08cE(ptr align 8 %self) !dbg !347 {
start:
  %self.dbg.spill = alloca [8 x i8], align 8
  %_0 = alloca [16 x i8], align 8
  %residual.dbg.spill = alloca [0 x i8], align 1
    #dbg_declare(ptr %residual.dbg.spill, !353, !DIExpression(), !357)
  store ptr %self, ptr %self.dbg.spill, align 8, !dbg !357
    #dbg_declare(ptr %self.dbg.spill, !350, !DIExpression(), !358)

After:

define internal { i64, i64 } @_ZN3tmp3Foo18var_return_opt_try17h00b17d08874ddd90E(ptr align 8 %self) !dbg !347 {
start:
  %self.dbg.spill = alloca [8 x i8], align 8
  %_0 = alloca [16 x i8], align 8
  %residual.dbg.spill = alloca [0 x i8], align 1
    #dbg_declare(ptr %residual.dbg.spill, !353, !DIExpression(), !357)
  store ptr %self, ptr %self.dbg.spill, align 8
    #dbg_declare(ptr %self.dbg.spill, !350, !DIExpression(), !358)

Note in particular how !357 from %residual.dbg.spill's dbg_declare no longer
falls through onto the store to %self.dbg.spill. This fixes argument values
at entry when the constant is a ZST (e.g. <Option as Try>::Residual). This
fixes #130003 (but note that it does *not* fix issues with argument values and
non-ZST constants, which emit their own stores that have debug info on them,
like #128945).
2024-09-06 23:12:18 +00:00
Mateusz Mikuła 4ee58db2f1 Upgrade CI's mingw-w64 toolchain 2024-09-01 12:37:26 +02:00
Ben Kimock 1a2ec2634e Make option-like-enum.rs UB-free and portable 2024-08-27 19:12:14 -04:00
Matthias Krüger dea325e583
Rollup merge of #128627 - khuey:DUMMY_SP-line-no, r=nnethercote
Special case DUMMY_SP to emit line 0/column 0 locations on DWARF platforms.

Line 0 has a special meaning in DWARF. From the version 5 spec:

    The compiler may emit the value 0 in cases
    where an instruction cannot be attributed to any
    source line.

DUMMY_SP spans cannot be attributed to any line. However, because rustc internally stores line numbers starting at zero, lookup_debug_loc() adjusts every line number by one. Special casing DUMMY_SP to actually emit line 0 ensures rustc communicates to the debugger that there's no meaningful source code for this instruction, rather than telling the debugger to jump to line 1 randomly.
2024-08-21 18:15:01 +02:00
Kyle Huey 3c735a00f7 Add a test. 2024-08-19 17:10:43 -07:00
Ben Kimock b2dae987f8 Fixup tests 2024-08-18 17:41:01 -04:00
Ben Kimock 22ed23d680 Convert lldbg- to lldb- 2024-08-18 17:00:33 -04:00
Ben Kimock 41d06f4115 Delete lldbr annotations 2024-08-18 16:59:58 -04:00
Ben Kimock c5fdc90a73 Delete min-lldb-version: 310 2024-08-18 16:58:26 -04:00
Ben Kimock 156088f8a8 Delete redundant gdb-version requirements and related comments 2024-08-18 16:58:25 -04:00
Ben Kimock e93e610329 Grep for enabled and clean up those hits 2024-08-18 16:58:00 -04:00
Ben Kimock 95ae9b8c84 Fix up a special case 2024-08-18 12:39:07 -04:00
Ben Kimock fa0e8585d4 Replace gdbr with gdbg 2024-08-18 12:39:07 -04:00
Ben Kimock 4314661671 Delete gdbg commands 2024-08-18 12:39:06 -04:00
Ben Kimock 70320c1936 Enable more debuginfo tests on Windows 2024-08-16 21:14:45 -04:00
Ben Kimock c6815c04cb Re-enable debuginfo tests on freebsd 2024-08-16 10:37:16 -04:00
bors d626fbdc66 Auto merge of #128913 - saethlin:unignore-debuginfo-tests, r=compiler-errors
Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in https://github.com/rust-lang/rust/pull/124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: https://github.com/rust-lang/rust/issues/128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: https://github.com/rust-lang/rust/issues/128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: https://github.com/rust-lang/rust/issues/128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: https://github.com/rust-lang/rust/issues/128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.
2024-08-16 06:41:16 +00:00
Ben Kimock 23273e03d7 Disable macro-stepping on current lldb 2024-08-15 17:04:26 -04:00
Ben Kimock b89d1976d1 Require gdb version on some tests 2024-08-13 18:20:48 -04:00
beetrees fe4fa2f1da
Use the `enum2$` Natvis visualiser for repr128 C-style enums 2024-08-13 19:53:21 +01:00
Ben Kimock 28a8301de9 Fix debuginfo providers/tests 2024-08-11 16:51:22 -04:00
Ben Kimock a561484b81 Enable debuginfo tests that have been temporarily disabled for years 2024-08-11 14:20:15 -04:00
Ben Kimock d6c0ebef50 Polymorphize RawVec 2024-08-09 20:06:26 -04:00
Urgau c0c57b3e29 Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
beetrees b058de90a3
Add Natvis visualiser and debuginfo tests for `f16` 2024-07-09 03:47:50 +01:00
Dario Nieuwenhuis b89a0a7838 Add debuginfo tests for collapse_debuginfo for statics. 2024-06-13 16:04:31 +02:00
Boxy 3a6b606ad9 remove const arg windows debug info tests 2024-06-05 22:39:42 +01:00
Michael Goulet 2e082677a6 Fix function-names.rs test 2024-06-05 22:25:42 +01:00
Boxy f74119a2e4 Bless tests and handle tests/crashes 2024-06-05 22:25:42 +01:00
Mark Rousskov dd9c8cc467 Increase vtable layout size
This improves LLVM's codegen by allowing vtable loads to be hoisted out
of loops (as just one example).
2024-06-01 07:42:05 -04:00
Nicholas Nethercote 4654e87d4c Fix `tests/debuginfo/strings-and-strs`.
It fails on my machine because it embeds pointer addresses in the
expected output.

This commit replaces the addresses with `0x[...]`.
2024-05-20 15:01:59 +10:00
Vladimir Makayev 330ce83a8d lldb-formatters: Use StdSliceSyntheticProvider for &str 2024-05-11 12:11:55 -07:00
Vladimir Makayev fb2d9cdfc5 Implement lldb formattter for "clang encoded" enums (LLDB 18.1+)
Summary:
I landed a fix last year to enable `DW_TAG_variant_part` encoding in LLDBs (https://reviews.llvm.org/D149213). This PR is a corresponding fix in synthetic formatters to decode that information.
This is in no way perfect implementation but at least it improves the status quo. But most types of enums will be visible and debuggable in some way.
I've also updated most of the existing tests that touch enums and re-enabled test cases based on LLDB for enums.

Test Plan:
ran tests `./x test tests/debuginfo/`. Also tested manually in LLDB CLI and LLDB VSCode

Other Thoughs
A better approach would probably be adopting [formatters from codelldb](https://github.com/vadimcn/codelldb/blob/master/formatters/rust.py). There is some neat hack that hooks up summary provider via synthetic provider which can ultimately fix more display issues for Rust types and enums too. But getting it to work well might take more time that I have right now.
2024-05-05 17:53:02 -07:00
Vadim Petrochenkov 683ad6b607 Update lldb only tests 2024-04-26 04:11:05 +03:00
Vadim Petrochenkov 98804c1786 debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and `#[collapse_debuginfo]`
`-Z debug-macros` is "stabilized" by enabling it by default and removing.

`-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`.
It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no.

Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local).
`#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
2024-04-25 22:14:47 +03:00
Oli Scherer aef0f4024a Error on using `yield` without also using `#[coroutine]` on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00
Markus Reiter 33e68aadc9
Stabilize generic `NonZero`. 2024-04-22 18:48:47 +02:00
Rémy Rakic 6e19f82160 disable two debuginfo tests under gdb 15
it seems gdb 15 regresses some of our debuginfo tests. disable them
temporarily so that CI doesn't randomly start failing soon.
2024-04-15 12:46:22 +00:00
Nathan Henrie 41e97a0a3f Add rust-lldb pretty printing for Path and PathBuf
Fixes https://github.com/rust-lang/rust/issues/120553
Fixes https://github.com/rust-lang/rust/issues/48462
2024-03-29 18:02:26 -06:00
bors a615cea333 Auto merge of #121885 - reitermarkus:generic-nonzero-inner, r=oli-obk,wesleywiser
Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to inner type.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? `@dtolnay`
2024-03-17 02:27:52 +00:00
Markus Reiter e4b27a2a5b
Fix unknown `dwim-print` command. 2024-03-15 21:08:06 +01:00
Markus Reiter 3ee1219088
Fix remaining LLDB commands. 2024-03-15 20:30:45 +01:00
Markus Reiter 96431e4b82
Use explicit LLDB commands instead of `print`/`p` aliases. 2024-03-15 15:38:03 +01:00
Markus Reiter 75fba9d574
Remove LLDB persistent results in `compiletest`. 2024-03-14 17:34:58 +01:00
Markus Reiter 4a799082fe
Fix `StdNonZeroNumberSummaryProvider`. 2024-03-14 17:34:58 +01:00
Markus Reiter ecee730c45
Try fixing `debuginfo` test. 2024-03-14 17:34:58 +01:00
joboet 22a5267c83
std: move `Once` implementations to `sys` 2024-03-12 15:41:06 +01:00
Chris Denton 2a09857729
Update debuginfo tests 2024-03-05 00:19:44 +00:00