rust/compiler/rustc_codegen_ssa/src
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
..
back Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoerister 2024-09-12 20:37:16 +10:00
debuginfo Also fix if in else 2024-09-11 17:24:01 -04:00
mir Don't leave debug locations for constants sitting on the builder indefinitely. 2024-09-06 23:12:18 +00:00
traits Don't leave debug locations for constants sitting on the builder indefinitely. 2024-09-06 23:12:18 +00:00
assert_module_sources.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
base.rs Rename struct_tail_erasing_lifetimes to struct_tail_for_codegen 2024-08-08 12:15:16 -04:00
codegen_attrs.rs Simplify some nested if statements 2024-09-11 13:45:23 -04:00
common.rs Rollup merge of #128206 - bjorn3:import_lib_writing_refactor, r=jieyouxu 2024-08-07 15:59:35 +02:00
errors.rs Always use ar_archive_writer for import libs 2024-08-17 19:10:46 +00:00
lib.rs Add warn(unreachable_pub) to rustc_codegen_ssa. 2024-08-16 08:46:57 +10:00
meth.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
mono_item.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
size_of_val.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
target_features.rs Disallow enabling features without their implied features 2024-08-07 00:45:00 -04:00