summaryrefslogtreecommitdiff
path: root/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-14 05:31:10 +0000
committerbors <bors@rust-lang.org>2023-05-14 05:31:10 +0000
commitbc888958c9e1fdde09791f15d3421bdc3b6d7d29 (patch)
tree7c58f002e19288e067a691a56b09cb71d7b3ad29 /tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff
parentad6ab11234ae885913229f6de2c4465bdc0d76f3 (diff)
parent8fb888dfaa1618838a288c41a8dc8ad24d1dadd5 (diff)
downloadrust-bc888958c9e1fdde09791f15d3421bdc3b6d7d29.tar.gz
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.
Diffstat (limited to 'tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff')
-rw-r--r--tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff15
1 files changed, 3 insertions, 12 deletions
diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff
index abb89b91dd3..73b9ea46c44 100644
--- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff
+++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff
@@ -21,9 +21,9 @@
let _13: &T; // in scope 1 at $DIR/issue_76432.rs:+3:18: +3:24
let _14: &T; // in scope 1 at $DIR/issue_76432.rs:+3:26: +3:32
scope 2 {
- debug v1 => _12; // in scope 2 at $DIR/issue_76432.rs:+3:10: +3:16
- debug v2 => _13; // in scope 2 at $DIR/issue_76432.rs:+3:18: +3:24
- debug v3 => _14; // in scope 2 at $DIR/issue_76432.rs:+3:26: +3:32
+ debug v1 => &(*_2)[0 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:10: +3:16
+ debug v2 => &(*_2)[1 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:18: +3:24
+ debug v3 => &(*_2)[2 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:26: +3:32
}
}
@@ -52,15 +52,6 @@
}
bb2: {
- StorageLive(_12); // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16
- _12 = &(*_2)[0 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16
- StorageLive(_13); // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24
- _13 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24
- StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32
- _14 = &(*_2)[2 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32
- StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85
- StorageDead(_13); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85
- StorageDead(_12); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85
StorageDead(_5); // scope 0 at $DIR/issue_76432.rs:+6:1: +6:2
StorageDead(_2); // scope 0 at $DIR/issue_76432.rs:+6:1: +6:2
return; // scope 0 at $DIR/issue_76432.rs:+6:2: +6:2