rust/compiler/rustc_middle/src
bors bc888958c9 Auto merge of #111440 - cjgillot:refprop-debuginfo, r=oli-obk
Allow MIR debuginfo to point to a variable's address

MIR optimizations currently do not to operate on borrowed locals.

When enabling #106285, many borrows will be left as-is because they are used in debuginfo. This pass allows to replace this pattern directly in MIR debuginfo:
```rust
a => _1
_1 = &raw? mut? _2
```
becomes
```rust
a => &_2
// No statement to borrow _2.
```

This pass is implemented as a drive-by in ReferencePropagation MIR pass.

This transformation allows following following MIR opts to treat _2 as an unborrowed local, and optimize it as such, even in builds with debuginfo.

In codegen, when encountering `a => &..&_2`, we create a list of allocas:
```llvm
store ptr %_2.dbg.spill, ptr %a.ref0.dbg.spill
store ptr %a.ref0.dbg.spill, ptr %a.ref1.dbg.spill
...
call void `@llvm.dbg.declare(metadata` ptr %a.ref{n}.dbg.spill, /* ... */)
```

Caveat: this transformation looses the exact type, we do not differentiate `a` as a immutable, mutable reference or a raw pointer. Everything is declared to `*mut` to codegen. I'm not convinced this is a blocker.
2023-05-14 05:31:10 +00:00
..
dep_graph Allow LocalDefId as the argument to def_path_str 2023-04-21 22:27:20 +00:00
hir introduce DynSend and DynSync auto trait 2023-05-06 09:34:18 +08:00
infer Rollup merge of #110386 - nnethercote:clean-up-traversal-macros, r=lcnr 2023-04-17 18:13:35 +02:00
middle Populate effective visibilities in rustc_privacy 2023-05-11 14:51:01 +03:00
mir Support ConstantIndex in debuginfo. 2023-05-13 10:12:15 +00:00
query Use the opaque_types_defined_by query to cheaply check for whether a hidden type may be registered for an opaque type 2023-05-12 10:26:50 +00:00
thir offset_of 2023-04-21 02:14:02 -07:00
traits Note base types of coercion 2023-05-12 00:10:52 +00:00
ty Auto merge of #111440 - cjgillot:refprop-debuginfo, r=oli-obk 2023-05-14 05:31:10 +00:00
util Restrict From<S> for {D,Subd}iagnosticMessage. 2023-05-03 08:44:39 +10:00
arena.rs Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
error.rs fix(middle): emit error rather than delay bug when reaching limit 2023-04-03 11:08:14 +08:00
lib.rs Switch impl_tag! from explicit tags to ${index()} 2023-04-24 16:48:37 +00:00
lint.rs Restrict From<S> for {D,Subd}iagnosticMessage. 2023-05-03 08:44:39 +10:00
macros.rs Simplify CloneLiftImpls and TrivialTypeTraversalImpls. 2023-04-16 14:19:50 +10:00
metadata.rs rustc_metadata: Remove Span from ModChild 2023-04-18 17:25:04 +03:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs Remove unused TypeFoldable/TypeVisitable impls. 2023-04-26 15:19:50 +10:00
values.rs Avoid ICEing miri on layout query cycles 2023-05-02 16:14:20 +00:00