rust/compiler/rustc_codegen_llvm/src/debuginfo
bors 8b6b15b877 Auto merge of #142771 - dianqk:mir-stmt-debuginfo, r=cjgillot
Introduce debuginfo to statements in MIR

The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix rust-lang/rust#128081.

I don't modify Stable MIR, as I don't think we need debug information when using it.

This PR represents the debug information for the dead reference statement via `#dbg_value`. For example, `let _foo_b = &foo.b` becomes `#dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26)`. You can see this here: https://rust.godbolt.org/z/d43js6adv.

The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR.

The current rules for dropping debug information in this PR are:

- If the LLVM IR cannot represent a reference address, it's replaced with poison or simply dropped. For example, see: https://rust.godbolt.org/z/shGqPec8W. I'm using poison in all such cases now.
- All debuginfos is dropped when merging multiple successor BBs. An example is available here: https://rust.godbolt.org/z/TE1q3Wq6M.

I doesn't drop debuginfos in `MatchBranchSimplification`, because LLVM also pick one branch for it.
2025-10-03 11:49:42 +00:00
..
metadata remove explicit deref of AbiAlign for most methods 2025-09-28 15:02:14 -07:00
create_scope_map.rs Use newtype_index!-generated types more idiomatically 2025-04-14 16:17:06 +00:00
doc.md fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
dwarf_const.rs codegen: Generate dbg_value for the ref statement 2025-10-02 14:55:51 +08:00
gdb.rs port #[debugger_visualizer] to the new attribute system 2025-09-21 21:30:16 -07:00
metadata.rs Extract helper method global_set_metadata_node 2025-10-02 18:06:58 +10:00
mod.rs codegen: Generate dbg_value for the ref statement 2025-10-02 14:55:51 +08:00
namespace.rs Rename llvm::Bool aliases to standard const case 2025-08-24 23:09:54 +10:00
utils.rs Use LLVMDIBuilderGetOrCreateArray 2025-09-19 14:44:54 +10:00