Use the declaration's SourceInfo for FnEntry retags, not the outermost
This commit is contained in:
parent
1e978a3627
commit
cd1a42a95d
@ -66,7 +66,6 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
|
||||
// We need an `AllCallEdges` pass before we can do any work.
|
||||
super::add_call_guards::AllCallEdges.run_pass(tcx, body);
|
||||
|
||||
let (span, arg_count) = (body.span, body.arg_count);
|
||||
let basic_blocks = body.basic_blocks.as_mut();
|
||||
let local_decls = &body.local_decls;
|
||||
let needs_retag = |place: &Place<'tcx>| {
|
||||
@ -90,20 +89,18 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
|
||||
// PART 1
|
||||
// Retag arguments at the beginning of the start block.
|
||||
{
|
||||
// FIXME: Consider using just the span covering the function
|
||||
// argument declaration.
|
||||
let source_info = SourceInfo::outermost(span);
|
||||
// Gather all arguments, skip return value.
|
||||
let places = local_decls
|
||||
.iter_enumerated()
|
||||
.skip(1)
|
||||
.take(arg_count)
|
||||
.map(|(local, _)| Place::from(local))
|
||||
.filter(needs_retag);
|
||||
let places = local_decls.iter_enumerated().skip(1).take(body.arg_count).filter_map(
|
||||
|(local, decl)| {
|
||||
let place = Place::from(local);
|
||||
needs_retag(&place).then_some((place, decl.source_info))
|
||||
},
|
||||
);
|
||||
|
||||
// Emit their retags.
|
||||
basic_blocks[START_BLOCK].statements.splice(
|
||||
0..0,
|
||||
places.map(|place| Statement {
|
||||
places.map(|(place, source_info)| Statement {
|
||||
source_info,
|
||||
kind: StatementKind::Retag(RetagKind::FnEntry, Box::new(place)),
|
||||
}),
|
||||
|
@ -6,7 +6,7 @@
|
||||
let mut _0: (); // return place in scope 0 at $DIR/provenance_soundness.rs:+0:25: +0:25
|
||||
|
||||
bb0: {
|
||||
Retag([fn entry] _1); // scope 0 at $DIR/provenance_soundness.rs:+0:1: +0:27
|
||||
Retag([fn entry] _1); // scope 0 at $DIR/provenance_soundness.rs:+0:11: +0:13
|
||||
_0 = const (); // scope 0 at $DIR/provenance_soundness.rs:+0:25: +0:27
|
||||
return; // scope 0 at $DIR/provenance_soundness.rs:+0:27: +0:27
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ fn bar() -> bool {
|
||||
Retag(_7); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
|
||||
_6 = &(*_7); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
|
||||
Retag(_6); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
|
||||
Retag(_3); // scope 2 at $DIR/inline-retag.rs:16:1: 18:2
|
||||
Retag(_6); // scope 2 at $DIR/inline-retag.rs:16:1: 18:2
|
||||
Retag(_3); // scope 2 at $DIR/inline-retag.rs:16:8: 16:9
|
||||
Retag(_6); // scope 2 at $DIR/inline-retag.rs:16:17: 16:18
|
||||
StorageLive(_11); // scope 2 at $DIR/inline-retag.rs:17:5: 17:7
|
||||
_11 = (*_3); // scope 2 at $DIR/inline-retag.rs:17:5: 17:7
|
||||
StorageLive(_12); // scope 2 at $DIR/inline-retag.rs:17:11: 17:13
|
||||
|
@ -10,7 +10,7 @@ fn main::{closure#0}(_1: &[closure@main::{closure#0}], _2: &i32) -> &i32 {
|
||||
|
||||
bb0: {
|
||||
Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:+0:31: +0:48
|
||||
Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:+0:31: +0:48
|
||||
Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:+0:32: +0:33
|
||||
StorageLive(_3); // scope 0 at $DIR/retag.rs:42:13: 42:15
|
||||
_3 = _2; // scope 0 at $DIR/retag.rs:42:18: 42:19
|
||||
Retag(_3); // scope 0 at $DIR/retag.rs:42:18: 42:19
|
||||
|
@ -7,8 +7,8 @@ fn <impl at $DIR/retag.rs:12:1: 12:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32
|
||||
let mut _3: &mut i32; // in scope 0 at $DIR/retag.rs:+1:9: +1:10
|
||||
|
||||
bb0: {
|
||||
Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:+0:5: +2:6
|
||||
Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:+0:5: +2:6
|
||||
Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:+0:16: +0:21
|
||||
Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:+0:23: +0:24
|
||||
StorageLive(_3); // scope 0 at $DIR/retag.rs:+1:9: +1:10
|
||||
_3 = &mut (*_2); // scope 0 at $DIR/retag.rs:+1:9: +1:10
|
||||
Retag(_3); // scope 0 at $DIR/retag.rs:+1:9: +1:10
|
||||
|
@ -6,8 +6,8 @@ fn <impl at $DIR/retag.rs:12:1: 12:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 {
|
||||
let mut _0: &i32; // return place in scope 0 at $DIR/retag.rs:+0:42: +0:49
|
||||
|
||||
bb0: {
|
||||
Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:+0:5: +2:6
|
||||
Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:+0:5: +2:6
|
||||
Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:+0:20: +0:25
|
||||
Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:+0:27: +0:28
|
||||
_0 = _2; // scope 0 at $DIR/retag.rs:+1:9: +1:10
|
||||
Retag(_0); // scope 0 at $DIR/retag.rs:+1:9: +1:10
|
||||
return; // scope 0 at $DIR/retag.rs:+2:6: +2:6
|
||||
|
Loading…
x
Reference in New Issue
Block a user