Skip to content

Commit ec2c291

Browse files
authored
(#684) Fix memory leaks in analysis/test
Fixes #681. This fixes all of the memory leaks in `analysis/test`. There was one that was intentional (`no_owner(0)`), but I freed that in `main_0` immediately after the `no_owner(0)` call instead.
2 parents 7e79f91 + 14d31a0 commit ec2c291

File tree

2 files changed

+91
-60
lines changed

2 files changed

+91
-60
lines changed

analysis/test/src/pointers.rs

+9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub unsafe extern "C" fn recur(x: libc::c_int, s: *mut S) {
6767
#[no_mangle]
6868
pub unsafe extern "C" fn simple() {
6969
let mut x = malloc(mem::size_of::<S>() as c_ulong) as *mut S;
70+
let mut x2 = x;
7071
let y = malloc(mem::size_of::<S>() as c_ulong) as *mut S;
7172
let z = std::ptr::addr_of!((*x).field);
7273
x = y;
@@ -79,6 +80,7 @@ pub unsafe extern "C" fn simple() {
7980
recur(3, x);
8081
let s = *y;
8182
*x = s;
83+
free(x2 as *mut libc::c_void);
8284
}
8385
#[no_mangle]
8486
pub unsafe extern "C" fn simple1() {
@@ -177,6 +179,7 @@ pub unsafe extern "C" fn connection_accepted(
177179
unsafe extern "C" fn connection_close(mut srv: *mut server, mut con: *mut connection) {
178180
fdevent_fdnode_event_del((*srv).ev, (*con).fdn);
179181
fdevent_unregister((*srv).ev, (*con).fd);
182+
free(con as *mut libc::c_void);
180183
}
181184
#[no_mangle]
182185
pub unsafe extern "C" fn fdevent_fdnode_event_del(mut ev: *mut fdevents, mut fdn: *mut fdnode) {
@@ -340,6 +343,7 @@ pub unsafe extern "C" fn test_arg() {
340343
let mut s = malloc(::std::mem::size_of::<S>() as libc::c_ulong);
341344
foo(s);
342345
let t = s;
346+
free(s as *mut libc::c_void);
343347
}
344348
#[no_mangle]
345349
pub unsafe extern "C" fn foo_rec(n: i32, bar: *mut libc::c_void) -> *mut libc::c_void {
@@ -355,6 +359,7 @@ pub unsafe extern "C" fn foo_rec(n: i32, bar: *mut libc::c_void) -> *mut libc::c
355359
pub unsafe extern "C" fn test_arg_rec() {
356360
let mut s = malloc(::std::mem::size_of::<S>() as libc::c_ulong);
357361
let t = foo_rec(3, s);
362+
free(s as *mut libc::c_void);
358363
}
359364
pub fn shared_ref_foo(x: &u8) -> &u8 {
360365
x
@@ -413,9 +418,11 @@ pub unsafe extern "C" fn test_load_addr() {
413418
#[no_mangle]
414419
pub unsafe extern "C" fn test_overwrite() {
415420
let mut s = malloc(::std::mem::size_of::<S>() as libc::c_ulong);
421+
let s2 = s;
416422
let t = malloc(::std::mem::size_of::<S>() as libc::c_ulong);
417423
s = t;
418424
free(s);
425+
free(s2);
419426
}
420427
#[no_mangle]
421428
pub unsafe extern "C" fn test_store_addr() {
@@ -478,6 +485,7 @@ pub unsafe extern "C" fn test_store_value_field() {
478485
let t = malloc(::std::mem::size_of::<S>() as libc::c_ulong) as *mut S;
479486
(*t).field3 = s;
480487
(*s).field3 = (*t).field3;
488+
free(t as *mut libc::c_void);
481489
free(s as *mut libc::c_void);
482490
}
483491
#[no_mangle]
@@ -508,6 +516,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
508516
analysis2();
509517
inter_function_analysis();
510518
no_owner(0i32);
519+
free(global as *mut libc::c_void);
511520
no_owner(1i32);
512521
invalid();
513522
testing();

pdg/src/snapshots/c2rust_pdg__tests__analysis_test_pdg_snapshot_debug.snap

+82-60
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,38 @@ g {
4343
nodes_that_need_write = []
4444

4545
g {
46-
n[0]: alloc _ => _2 @ bb1[2]: fn simple; _2 = malloc(move _3);
47-
n[1]: copy n[0] => _1 @ bb2[1]: fn simple; _1 = move _2 as *mut pointers::S (Misc);
48-
n[2]: field.0 n[1] => _9 @ bb4[5]: fn simple; _9 = &raw const ((*_1).0: i32);
46+
n[0]: alloc _ => _2 @ bb1[2]: fn simple; _2 = malloc(move _3);
47+
n[1]: copy n[0] => _1 @ bb2[1]: fn simple; _1 = move _2 as *mut pointers::S (Misc);
48+
n[2]: copy n[1] => _5 @ bb2[5]: fn simple; _5 = _1;
49+
n[3]: field.0 n[1] => _10 @ bb4[5]: fn simple; _10 = &raw const ((*_1).0: i32);
50+
n[4]: copy n[2] => _22 @ bb5[12]: fn simple; _22 = _5;
51+
n[5]: copy n[4] => _21 @ bb5[13]: fn simple; _21 = move _22 as *mut libc::c_void (Misc);
52+
n[6]: free n[5] => _20 @ bb5[15]: fn simple; _20 = free(move _21);
4953
}
5054
nodes_that_need_write = []
5155

5256
g {
53-
n[0]: alloc _ => _6 @ bb3[2]: fn simple; _6 = malloc(move _7);
54-
n[1]: copy n[0] => _5 @ bb4[1]: fn simple; _5 = move _6 as *mut pointers::S (Misc);
55-
n[2]: copy n[1] => _10 @ bb4[8]: fn simple; _10 = _5;
56-
n[3]: copy n[2] => _1 @ bb4[9]: fn simple; _1 = move _10;
57+
n[0]: alloc _ => _7 @ bb3[2]: fn simple; _7 = malloc(move _8);
58+
n[1]: copy n[0] => _6 @ bb4[1]: fn simple; _6 = move _7 as *mut pointers::S (Misc);
59+
n[2]: copy n[1] => _11 @ bb4[8]: fn simple; _11 = _6;
60+
n[3]: copy n[2] => _1 @ bb4[9]: fn simple; _1 = move _11;
5761
n[4]: field.0 n[3] => _ @ bb4[11]: fn simple; ((*_1).0: i32) = const 10_i32;
5862
n[5]: addr.store n[4] => _ @ bb4[11]: fn simple; ((*_1).0: i32) = const 10_i32;
59-
n[6]: field.0 n[3] => _11 @ bb4[13]: fn simple; _11 = ((*_1).0: i32);
60-
n[7]: addr.load n[6] => _ @ bb4[13]: fn simple; _11 = ((*_1).0: i32);
61-
n[8]: field.0 n[1] => _ @ bb4[14]: fn simple; ((*_5).0: i32) = move _11;
62-
n[9]: addr.store n[8] => _ @ bb4[14]: fn simple; ((*_5).0: i32) = move _11;
63+
n[6]: field.0 n[3] => _12 @ bb4[13]: fn simple; _12 = ((*_1).0: i32);
64+
n[7]: addr.load n[6] => _ @ bb4[13]: fn simple; _12 = ((*_1).0: i32);
65+
n[8]: field.0 n[1] => _ @ bb4[14]: fn simple; ((*_6).0: i32) = move _12;
66+
n[9]: addr.store n[8] => _ @ bb4[14]: fn simple; ((*_6).0: i32) = move _12;
6367
n[10]: field.1 n[3] => _ @ bb4[16]: fn simple; ((*_1).1: u64) = const 9_u64;
6468
n[11]: addr.store n[10] => _ @ bb4[16]: fn simple; ((*_1).1: u64) = const 9_u64;
65-
n[12]: field.0 n[3] => _12 @ bb4[18]: fn simple; _12 = ((*_1).0: i32);
66-
n[13]: addr.load n[12] => _ @ bb4[18]: fn simple; _12 = ((*_1).0: i32);
67-
n[14]: field.1 n[3] => _13 @ bb4[21]: fn simple; _13 = &raw const ((*_1).1: u64);
68-
n[15]: copy n[3] => _14 @ bb4[24]: fn simple; _14 = &raw const (*_1);
69-
n[16]: field.2 n[3] => _ @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _14;
70-
n[17]: addr.store n[16] => _ @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _14;
71-
n[18]: value.store n[15] => _1.*.2 @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _14;
72-
n[19]: copy n[3] => _16 @ bb4[29]: fn simple; _16 = _1;
73-
n[20]: copy n[19] => _2 @ bb0[0]: fn recur; _15 = recur(const 3_i32, move _16);
69+
n[12]: field.0 n[3] => _13 @ bb4[18]: fn simple; _13 = ((*_1).0: i32);
70+
n[13]: addr.load n[12] => _ @ bb4[18]: fn simple; _13 = ((*_1).0: i32);
71+
n[14]: field.1 n[3] => _14 @ bb4[21]: fn simple; _14 = &raw const ((*_1).1: u64);
72+
n[15]: copy n[3] => _15 @ bb4[24]: fn simple; _15 = &raw const (*_1);
73+
n[16]: field.2 n[3] => _ @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _15;
74+
n[17]: addr.store n[16] => _ @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _15;
75+
n[18]: value.store n[15] => _1.*.2 @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _15;
76+
n[19]: copy n[3] => _17 @ bb4[29]: fn simple; _17 = _1;
77+
n[20]: copy n[19] => _2 @ bb0[0]: fn recur; _16 = recur(const 3_i32, move _17);
7478
n[21]: copy n[20] => _13 @ bb8[3]: fn recur; _13 = _2;
7579
n[22]: copy n[21] => _2 @ bb0[0]: fn recur; _9 = recur(move _10, move _13);
7680
n[23]: copy n[22] => _13 @ bb8[3]: fn recur; _13 = _2;
@@ -83,18 +87,18 @@ g {
8387
n[30]: copy n[26] => _14 @ bb9[4]: fn recur; _14 = _2;
8488
n[31]: copy n[26] => _14 @ bb9[4]: fn recur; _14 = _2;
8589
n[32]: copy n[26] => _14 @ bb9[4]: fn recur; _14 = _2;
86-
n[33]: addr.load n[1] => _ @ bb5[3]: fn simple; _17 = (*_5);
87-
n[34]: addr.store n[3] => _ @ bb5[7]: fn simple; (*_1) = move _18;
90+
n[33]: addr.load n[1] => _ @ bb5[3]: fn simple; _18 = (*_6);
91+
n[34]: addr.store n[3] => _ @ bb5[7]: fn simple; (*_1) = move _19;
8892
}
8993
nodes_that_need_write = [34, 17, 16, 11, 10, 9, 8, 5, 4, 3, 2, 1, 0]
9094

9195
g {
92-
n[0]: &_1 _ => _9 @ bb4[5]: fn simple; _9 = &raw const ((*_1).0: i32);
96+
n[0]: &_1 _ => _10 @ bb4[5]: fn simple; _10 = &raw const ((*_1).0: i32);
9397
}
9498
nodes_that_need_write = []
9599

96100
g {
97-
n[0]: &_1 _ => _13 @ bb4[21]: fn simple; _13 = &raw const ((*_1).1: u64);
101+
n[0]: &_1 _ => _14 @ bb4[21]: fn simple; _14 = &raw const ((*_1).1: u64);
98102
}
99103
nodes_that_need_write = []
100104

@@ -336,25 +340,30 @@ nodes_that_need_write = [4, 3, 2, 1, 0]
336340
g {
337341
n[0]: alloc _ => _2 @ bb1[2]: fn no_owner; _2 = malloc(move _3);
338342
n[1]: value.store n[0] => _5.* @ bb2[3]: fn no_owner; (*_5) = move _2 as *mut pointers::S (Misc);
343+
n[2]: value.load _ => _12 @ bb6[6]: fn main_0; _12 = (*_13);
344+
n[3]: copy n[2] => _11 @ bb6[7]: fn main_0; _11 = move _12 as *mut libc::c_void (Misc);
345+
n[4]: free n[3] => _10 @ bb6[9]: fn main_0; _10 = free(move _11);
339346
}
340347
nodes_that_need_write = []
341348

342349
g {
343350
n[0]: copy _ => _5 @ bb2[2]: fn no_owner; _5 = const {alloc8: *mut *mut pointers::S};
344351
n[1]: addr.store n[0] => _ @ bb2[3]: fn no_owner; (*_5) = move _2 as *mut pointers::S (Misc);
345-
n[2]: copy _ => _5 @ bb2[2]: fn no_owner; _5 = const {alloc8: *mut *mut pointers::S};
346-
n[3]: addr.store n[2] => _ @ bb2[3]: fn no_owner; (*_5) = move _2 as *mut pointers::S (Misc);
347-
n[4]: copy _ => _12 @ bb3[4]: fn no_owner; _12 = const {alloc8: *mut *mut pointers::S};
348-
n[5]: addr.load n[4] => _ @ bb3[5]: fn no_owner; _11 = (*_12);
349-
n[6]: copy _ => _6 @ bb2[9]: fn invalid; _6 = const {alloc8: *mut *mut pointers::S};
350-
n[7]: addr.store n[6] => _ @ bb2[10]: fn invalid; (*_6) = move _5;
351-
n[8]: copy _ => _19 @ bb3[17]: fn invalid; _19 = const {alloc8: *mut *mut pointers::S};
352-
n[9]: field.0 n[8] => _18 @ bb3[18]: fn invalid; _18 = ((*(*_19)).0: i32);
353-
n[10]: addr.load n[9] => _ @ bb3[18]: fn invalid; _18 = ((*(*_19)).0: i32);
354-
n[11]: copy _ => _20 @ bb4[6]: fn invalid; _20 = const {alloc8: *mut *mut pointers::S};
355-
n[12]: addr.store n[11] => _ @ bb4[7]: fn invalid; (*_20) = const 0_usize as *mut pointers::S (PointerFromExposedAddress);
356-
}
357-
nodes_that_need_write = [12, 11, 7, 6, 3, 2, 1, 0]
352+
n[2]: copy _ => _13 @ bb6[5]: fn main_0; _13 = const {alloc8: *mut *mut pointers::S};
353+
n[3]: addr.load n[2] => _ @ bb6[6]: fn main_0; _12 = (*_13);
354+
n[4]: copy _ => _5 @ bb2[2]: fn no_owner; _5 = const {alloc8: *mut *mut pointers::S};
355+
n[5]: addr.store n[4] => _ @ bb2[3]: fn no_owner; (*_5) = move _2 as *mut pointers::S (Misc);
356+
n[6]: copy _ => _12 @ bb3[4]: fn no_owner; _12 = const {alloc8: *mut *mut pointers::S};
357+
n[7]: addr.load n[6] => _ @ bb3[5]: fn no_owner; _11 = (*_12);
358+
n[8]: copy _ => _6 @ bb2[9]: fn invalid; _6 = const {alloc8: *mut *mut pointers::S};
359+
n[9]: addr.store n[8] => _ @ bb2[10]: fn invalid; (*_6) = move _5;
360+
n[10]: copy _ => _19 @ bb3[17]: fn invalid; _19 = const {alloc8: *mut *mut pointers::S};
361+
n[11]: field.0 n[10] => _18 @ bb3[18]: fn invalid; _18 = ((*(*_19)).0: i32);
362+
n[12]: addr.load n[11] => _ @ bb3[18]: fn invalid; _18 = ((*(*_19)).0: i32);
363+
n[13]: copy _ => _20 @ bb4[6]: fn invalid; _20 = const {alloc8: *mut *mut pointers::S};
364+
n[14]: addr.store n[13] => _ @ bb4[7]: fn invalid; (*_20) = const 0_usize as *mut pointers::S (PointerFromExposedAddress);
365+
}
366+
nodes_that_need_write = [14, 13, 9, 8, 5, 4, 1, 0]
358367

359368
g {
360369
n[0]: alloc _ => _2 @ bb1[2]: fn no_owner; _2 = malloc(move _3);
@@ -516,6 +525,9 @@ g {
516525
n[18]: addr.load n[17] => _ @ bb0[4]: fn connection_close; _5 = ((*_2).1: *mut pointers::fdnode_st);
517526
n[19]: field.0 n[16] => _8 @ bb1[7]: fn connection_close; _8 = ((*_2).0: i32);
518527
n[20]: addr.load n[19] => _ @ bb1[7]: fn connection_close; _8 = ((*_2).0: i32);
528+
n[21]: copy n[16] => _11 @ bb2[6]: fn connection_close; _11 = _2;
529+
n[22]: copy n[21] => _10 @ bb2[7]: fn connection_close; _10 = move _11 as *mut libc::c_void (Misc);
530+
n[23]: free n[22] => _9 @ bb2[9]: fn connection_close; _9 = free(move _10);
519531
}
520532
nodes_that_need_write = [12, 11, 3, 2, 1, 0]
521533

@@ -582,6 +594,8 @@ g {
582594
n[2]: copy n[1] => _1 @ bb0[0]: fn foo; _4 = foo(move _5);
583595
n[3]: copy n[2] => _2 @ bb0[1]: fn foo; _2 = _1;
584596
n[4]: copy n[2] => _6 @ bb3[3]: fn test_arg; _6 = _1;
597+
n[5]: copy n[2] => _8 @ bb3[7]: fn test_arg; _8 = _1;
598+
n[6]: free n[5] => _7 @ bb3[8]: fn test_arg; _7 = free(move _8);
585599
}
586600
nodes_that_need_write = []
587601

@@ -606,6 +620,8 @@ g {
606620
n[17]: copy n[16] => _12 @ bb4[4]: fn foo_rec; _12 = _7;
607621
n[18]: copy n[17] => _0 @ bb4[6]: fn foo_rec; _0 = _12;
608622
n[19]: copy n[18] => _4 @ bb2[5]: fn test_arg_rec; _4 = foo_rec(const 3_i32, move _5);
623+
n[20]: copy n[0] => _7 @ bb3[4]: fn test_arg_rec; _7 = _1;
624+
n[21]: free n[20] => _6 @ bb3[5]: fn test_arg_rec; _6 = free(move _7);
609625
}
610626
nodes_that_need_write = []
611627

@@ -679,16 +695,19 @@ g {
679695
nodes_that_need_write = []
680696

681697
g {
682-
n[0]: alloc _ => _1 @ bb1[2]: fn test_overwrite; _1 = malloc(move _2);
698+
n[0]: alloc _ => _1 @ bb1[2]: fn test_overwrite; _1 = malloc(move _2);
699+
n[1]: copy n[0] => _4 @ bb2[3]: fn test_overwrite; _4 = _1;
700+
n[2]: copy n[1] => _12 @ bb5[4]: fn test_overwrite; _12 = _4;
701+
n[3]: free n[2] => _11 @ bb5[5]: fn test_overwrite; _11 = free(move _12);
683702
}
684703
nodes_that_need_write = []
685704

686705
g {
687-
n[0]: alloc _ => _4 @ bb3[2]: fn test_overwrite; _4 = malloc(move _5);
688-
n[1]: copy n[0] => _7 @ bb4[3]: fn test_overwrite; _7 = _4;
689-
n[2]: copy n[1] => _1 @ bb4[4]: fn test_overwrite; _1 = move _7;
690-
n[3]: copy n[2] => _9 @ bb4[8]: fn test_overwrite; _9 = _1;
691-
n[4]: free n[3] => _8 @ bb4[9]: fn test_overwrite; _8 = free(move _9);
706+
n[0]: alloc _ => _5 @ bb3[2]: fn test_overwrite; _5 = malloc(move _6);
707+
n[1]: copy n[0] => _8 @ bb4[3]: fn test_overwrite; _8 = _5;
708+
n[2]: copy n[1] => _1 @ bb4[4]: fn test_overwrite; _1 = move _8;
709+
n[3]: copy n[2] => _10 @ bb4[8]: fn test_overwrite; _10 = _1;
710+
n[4]: free n[3] => _9 @ bb4[9]: fn test_overwrite; _9 = free(move _10);
692711
}
693712
nodes_that_need_write = []
694713

@@ -803,19 +822,22 @@ g {
803822
n[5]: field.2 n[1] => _ @ bb4[10]: fn test_store_value_field; ((*_1).2: *const pointers::S) = move _10;
804823
n[6]: addr.store n[5] => _ @ bb4[10]: fn test_store_value_field; ((*_1).2: *const pointers::S) = move _10;
805824
n[7]: value.store n[4] => _1.*.2 @ bb4[10]: fn test_store_value_field; ((*_1).2: *const pointers::S) = move _10;
806-
n[8]: copy n[1] => _13 @ bb4[15]: fn test_store_value_field; _13 = _1;
807-
n[9]: copy n[8] => _12 @ bb4[16]: fn test_store_value_field; _12 = move _13 as *mut libc::c_void (Misc);
808-
n[10]: free n[9] => _11 @ bb4[18]: fn test_store_value_field; _11 = free(move _12);
825+
n[8]: copy n[1] => _16 @ bb5[5]: fn test_store_value_field; _16 = _1;
826+
n[9]: copy n[8] => _15 @ bb5[6]: fn test_store_value_field; _15 = move _16 as *mut libc::c_void (Misc);
827+
n[10]: free n[9] => _14 @ bb5[8]: fn test_store_value_field; _14 = free(move _15);
809828
}
810829
nodes_that_need_write = [6, 5, 1, 0]
811830

812831
g {
813-
n[0]: alloc _ => _6 @ bb3[2]: fn test_store_value_field; _6 = malloc(move _7);
814-
n[1]: copy n[0] => _5 @ bb4[1]: fn test_store_value_field; _5 = move _6 as *mut pointers::S (Misc);
815-
n[2]: field.2 n[1] => _ @ bb4[6]: fn test_store_value_field; ((*_5).2: *const pointers::S) = move _9 as *const pointers::S (Pointer(MutToConstPointer));
816-
n[3]: addr.store n[2] => _ @ bb4[6]: fn test_store_value_field; ((*_5).2: *const pointers::S) = move _9 as *const pointers::S (Pointer(MutToConstPointer));
817-
n[4]: field.2 n[1] => _10 @ bb4[9]: fn test_store_value_field; _10 = ((*_5).2: *const pointers::S);
818-
n[5]: addr.load n[4] => _ @ bb4[9]: fn test_store_value_field; _10 = ((*_5).2: *const pointers::S);
832+
n[0]: alloc _ => _6 @ bb3[2]: fn test_store_value_field; _6 = malloc(move _7);
833+
n[1]: copy n[0] => _5 @ bb4[1]: fn test_store_value_field; _5 = move _6 as *mut pointers::S (Misc);
834+
n[2]: field.2 n[1] => _ @ bb4[6]: fn test_store_value_field; ((*_5).2: *const pointers::S) = move _9 as *const pointers::S (Pointer(MutToConstPointer));
835+
n[3]: addr.store n[2] => _ @ bb4[6]: fn test_store_value_field; ((*_5).2: *const pointers::S) = move _9 as *const pointers::S (Pointer(MutToConstPointer));
836+
n[4]: field.2 n[1] => _10 @ bb4[9]: fn test_store_value_field; _10 = ((*_5).2: *const pointers::S);
837+
n[5]: addr.load n[4] => _ @ bb4[9]: fn test_store_value_field; _10 = ((*_5).2: *const pointers::S);
838+
n[6]: copy n[1] => _13 @ bb4[15]: fn test_store_value_field; _13 = _5;
839+
n[7]: copy n[6] => _12 @ bb4[16]: fn test_store_value_field; _12 = move _13 as *mut libc::c_void (Misc);
840+
n[8]: free n[7] => _11 @ bb4[18]: fn test_store_value_field; _11 = free(move _12);
819841
}
820842
nodes_that_need_write = [3, 2, 1, 0]
821843

@@ -837,13 +859,13 @@ g {
837859
nodes_that_need_write = [2, 0]
838860

839861
g {
840-
n[0]: &_35 _ => _34 @ bb30[4]: fn main_0; _34 = &mut _35;
841-
n[1]: copy n[0] => _40 @ bb30[11]: fn main_0; _40 = &(*_34);
842-
n[2]: copy n[1] => _39 @ bb30[12]: fn main_0; _39 = move _40 as &[i32] (Pointer(Unsize));
843-
n[3]: copy n[2] => _1 @ bb0[0]: fn len; _38 = len(move _39);
844-
n[4]: copy n[0] => _42 @ bb31[5]: fn main_0; _42 = &raw mut (*_34);
845-
n[5]: copy n[4] => _41 @ bb31[6]: fn main_0; _41 = move _42 as *mut i32 (Pointer(ArrayToPointer));
846-
n[6]: copy n[5] => _2 @ bb0[0]: fn insertion_sort; _36 = insertion_sort(move _37, move _41);
862+
n[0]: &_39 _ => _38 @ bb31[4]: fn main_0; _38 = &mut _39;
863+
n[1]: copy n[0] => _44 @ bb31[11]: fn main_0; _44 = &(*_38);
864+
n[2]: copy n[1] => _43 @ bb31[12]: fn main_0; _43 = move _44 as &[i32] (Pointer(Unsize));
865+
n[3]: copy n[2] => _1 @ bb0[0]: fn len; _42 = len(move _43);
866+
n[4]: copy n[0] => _46 @ bb32[5]: fn main_0; _46 = &raw mut (*_38);
867+
n[5]: copy n[4] => _45 @ bb32[6]: fn main_0; _45 = move _46 as *mut i32 (Pointer(ArrayToPointer));
868+
n[6]: copy n[5] => _2 @ bb0[0]: fn insertion_sort; _40 = insertion_sort(move _41, move _45);
847869
n[7]: copy n[6] => _10 @ bb3[3]: fn insertion_sort; _10 = _2;
848870
n[8]: offset[1] n[7] => _9 @ bb3[9]: fn insertion_sort; _9 = offset(move _10, move _11);
849871
n[9]: addr.load n[8] => _ @ bb5[2]: fn insertion_sort; _8 = (*_9);
@@ -928,5 +950,5 @@ g {
928950
nodes_that_need_write = [6, 5, 4, 0]
929951

930952
num_graphs = 64
931-
num_nodes = 669
953+
num_nodes = 691
932954

0 commit comments

Comments
 (0)