Commit e87a205
committed
Auto merge of rust-lang#56231 - eddyb:mir-debuginfo, r=oli-obk
rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo.
This PR introduces a MIR "user variable" debuginfo system, which amounts to mapping a variable name, in some `SourceScope`, to a `Place`, so that:
* each name can appear multiple times (e.g. due to macro hygiene), even in the same scope
* each `Place` can appear multiple times (e.g. in the future from optimizations like NRVO, which collapse multiple MIR locals into one)
* the `Place`s aren't limited to just locals, so they can describe the (right now quite ad-hoc) closure upvars and generator saved state fields, and can be properly transformed by optimizations (e.g. inlining - see `src/test/mir-opt/inline-closure-captures.rs`)
The main motivation for this was that rust-lang#48300 and further optimizations were blocked on being able to describe complex debuginfo transformations (see rust-lang#48300 (comment)).
<hr/>
In the textual representation, the "user variable" debuginfo can be found in each scope, and consists of `debug NAME => PLACE;` "declarations", e.g. the MIR for `let x = ...; let y = ...; ...` is now:
```rust
let _1: T; // in scope 0 at ...
scope 1 {
debug x => _1; // in scope 1 at ...
let _2: T; // in scope 1 at ...
scope 2 {
debug y => _2; // in scope 2 at ...
}
}
```
For reference, this is how the information was represented before this PR:
(notably, the scopes in which the variables are visible for debuginfo weren't even shown anywhere, making `scope 2` look pointless, and user variable names were part of MIR locals)
```rust
let _1: T; // "x" in scope 0 at ...
scope 1 {
let _2: T; // "y" in scope 1 at ...
scope 2 {
}
}
```
cc @nikomatsakis @michaelwoeristerFile tree
49 files changed
+780
-480
lines changed- src
- librustc_codegen_llvm/debuginfo
- librustc_codegen_ssa/mir
- librustc_mir
- borrow_check
- nll
- explain_borrow
- region_infer
- error_reporting
- build
- expr
- matches
- transform
- util
- librustc/mir
- test
- incremental/hashes
- mir-opt
- nll
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
49 files changed
+780
-480
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 144 | + | |
| 145 | + | |
152 | 146 | | |
153 | 147 | | |
154 | 148 | | |
| |||
170 | 164 | | |
171 | 165 | | |
172 | 166 | | |
173 | | - | |
174 | 167 | | |
175 | 168 | | |
176 | 169 | | |
177 | | - | |
| 170 | + | |
178 | 171 | | |
179 | 172 | | |
180 | 173 | | |
| |||
191 | 184 | | |
192 | 185 | | |
193 | 186 | | |
194 | | - | |
| 187 | + | |
195 | 188 | | |
196 | 189 | | |
197 | 190 | | |
198 | 191 | | |
199 | 192 | | |
200 | | - | |
201 | 193 | | |
| 194 | + | |
202 | 195 | | |
203 | 196 | | |
204 | 197 | | |
| |||
280 | 273 | | |
281 | 274 | | |
282 | 275 | | |
283 | | - | |
| 276 | + | |
284 | 277 | | |
285 | 278 | | |
286 | 279 | | |
| |||
728 | 721 | | |
729 | 722 | | |
730 | 723 | | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | 724 | | |
738 | 725 | | |
739 | 726 | | |
| |||
785 | 772 | | |
786 | 773 | | |
787 | 774 | | |
788 | | - | |
789 | | - | |
790 | | - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
791 | 778 | | |
792 | 779 | | |
793 | 780 | | |
| |||
806 | 793 | | |
807 | 794 | | |
808 | 795 | | |
809 | | - | |
| 796 | + | |
810 | 797 | | |
811 | 798 | | |
812 | 799 | | |
813 | | - | |
| 800 | + | |
814 | 801 | | |
815 | 802 | | |
816 | 803 | | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | 804 | | |
822 | 805 | | |
823 | 806 | | |
| |||
955 | 938 | | |
956 | 939 | | |
957 | 940 | | |
958 | | - | |
959 | 941 | | |
960 | | - | |
961 | 942 | | |
962 | 943 | | |
963 | 944 | | |
| |||
974 | 955 | | |
975 | 956 | | |
976 | 957 | | |
977 | | - | |
978 | 958 | | |
979 | 959 | | |
980 | | - | |
981 | 960 | | |
982 | 961 | | |
983 | 962 | | |
984 | 963 | | |
985 | 964 | | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
990 | 969 | | |
991 | | - | |
992 | | - | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
993 | 979 | | |
994 | 980 | | |
995 | 981 | | |
| |||
2758 | 2744 | | |
2759 | 2745 | | |
2760 | 2746 | | |
2761 | | - | |
2762 | | - | |
2763 | | - | |
2764 | | - | |
2765 | | - | |
2766 | | - | |
2767 | | - | |
2768 | | - | |
2769 | | - | |
2770 | | - | |
2771 | 2747 | | |
2772 | 2748 | | |
2773 | 2749 | | |
| |||
2946 | 2922 | | |
2947 | 2923 | | |
2948 | 2924 | | |
2949 | | - | |
2950 | 2925 | | |
2951 | 2926 | | |
2952 | 2927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
224 | 229 | | |
225 | 230 | | |
226 | 231 | | |
| |||
279 | 284 | | |
280 | 285 | | |
281 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
282 | 291 | | |
283 | 292 | | |
284 | 293 | | |
| |||
687 | 696 | | |
688 | 697 | | |
689 | 698 | | |
690 | | - | |
691 | 699 | | |
692 | | - | |
693 | 700 | | |
694 | 701 | | |
695 | 702 | | |
| |||
703 | 710 | | |
704 | 711 | | |
705 | 712 | | |
706 | | - | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
707 | 730 | | |
708 | 731 | | |
709 | 732 | | |
| |||
1029 | 1052 | | |
1030 | 1053 | | |
1031 | 1054 | | |
| 1055 | + | |
| 1056 | + | |
1032 | 1057 | | |
1033 | 1058 | | |
1034 | 1059 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 28 | + | |
| 29 | + | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
0 commit comments