From beb017f3d100f157e043e2bbdabdbd7ed26ae2c7 Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Tue, 22 Oct 2024 18:37:55 -0700 Subject: [PATCH] Disable test_ref_field which fails on Darwin --- analysis/tests/misc/src/pointers.rs | 6 +++- ...nalysis_tests_misc_pdg_snapshot_debug.snap | 33 ++++--------------- ...lysis_tests_misc_pdg_snapshot_release.snap | 27 ++++----------- 3 files changed, 18 insertions(+), 48 deletions(-) diff --git a/analysis/tests/misc/src/pointers.rs b/analysis/tests/misc/src/pointers.rs index d704a7d14d..e7366fe999 100644 --- a/analysis/tests/misc/src/pointers.rs +++ b/analysis/tests/misc/src/pointers.rs @@ -746,7 +746,11 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib test_load_value_store_value(); let nums = &mut [2i32, 5i32, 3i32, 1i32, 6i32]; insertion_sort(nums.len() as libc::c_int, nums as *mut libc::c_int); - test_ref_field(); + // TODO: this test is broken on Darwin because the fields structure fields + // alias with locals of other functions, and the locals are different between + // Linux and Darwin. We should re-enable test_ref_field once we track stack + // lifetimes (see https://github.com/immunant/c2rust/issues/1117). + //test_ref_field(); test_addr_taken(); let mut t = T { field: 0i32, diff --git a/pdg/src/snapshots/c2rust_pdg__tests__analysis_tests_misc_pdg_snapshot_debug.snap b/pdg/src/snapshots/c2rust_pdg__tests__analysis_tests_misc_pdg_snapshot_debug.snap index d3f4c5feca..0e01ad109b 100644 --- a/pdg/src/snapshots/c2rust_pdg__tests__analysis_tests_misc_pdg_snapshot_debug.snap +++ b/pdg/src/snapshots/c2rust_pdg__tests__analysis_tests_misc_pdg_snapshot_debug.snap @@ -36,10 +36,8 @@ g is_null=true { n[15]: copy n[10] => _18 @ bb16[4]: fn recur; _18 = _2; n[16]: value.store n[0] => _20.* @ bb4[7]: fn invalid; (*_20) = const 0_usize as *mut pointers::S (PointerFromExposedAddress); n[17]: value.store n[0] => _17.* @ bb8[4]: fn fdevent_unregister; (*_17) = const 0_usize as *mut pointers::fdnode_st (PointerFromExposedAddress); - n[18]: int_to_ptr n[0] => _2 @ bb0[2]: fn test_ref_field; _2 = const 0_usize as *const pointers::S (PointerFromExposedAddress); - n[19]: int_to_ptr n[0] => _5 @ bb0[8]: fn test_ref_field; _5 = const 0_usize as *const pointers::S (PointerFromExposedAddress); - n[20]: int_to_ptr n[0] => _51 @ bb36[3]: fn main_0; _51 = const 0_usize as *const pointers::S (PointerFromExposedAddress); - n[21]: value.store n[0] => _3.*.2 @ bb0[1]: fn test_addr_taken_arg; ((*_3).2: *const pointers::S) = const 0_usize as *const pointers::S (PointerFromExposedAddress); + n[18]: int_to_ptr n[0] => _50 @ bb35[3]: fn main_0; _50 = const 0_usize as *const pointers::S (PointerFromExposedAddress); + n[19]: value.store n[0] => _3.*.2 @ bb0[1]: fn test_addr_taken_arg; ((*_3).2: *const pointers::S) = const 0_usize as *const pointers::S (PointerFromExposedAddress); } nodes_that_need_write = [] @@ -933,9 +931,9 @@ g is_null=false { nodes_that_need_write = [3, 1, 0] g is_null=false { - n[0]: &_40 _ => _ @ bb32[4]: fn main_0; _59 = &raw mut _40; + n[0]: &_40 _ => _ @ bb32[4]: fn main_0; _58 = &raw mut _40; n[1]: addr.store n[0] => _ @ bb32[3]: fn main_0; _40 = [const 2_i32, const 5_i32, const 3_i32, const 1_i32, const 6_i32]; - n[2]: copy n[0] => _39 @ bb32[5]: fn main_0; _39 = &mut (*_59); + n[2]: copy n[0] => _39 @ bb32[5]: fn main_0; _39 = &mut (*_58); n[3]: copy n[2] => _45 @ bb32[12]: fn main_0; _45 = &(*_39); n[4]: copy n[3] => _44 @ bb32[13]: fn main_0; _44 = move _45 as &[i32] (Pointer(Unsize)); n[5]: copy n[4] => _1 @ bb0[0]: fn len; _43 = len(move _44); @@ -1014,25 +1012,6 @@ g is_null=false { } nodes_that_need_write = [77, 76, 75, 68, 67, 66, 65, 64, 63, 56, 55, 54, 47, 46, 45, 35, 34, 33, 29, 28, 27, 17, 16, 15, 8, 7, 6, 2, 1, 0] -g is_null=false { - n[0]: &_4 _ => _ @ bb0[12]: fn test_ref_field; _8 = &raw mut _4; - n[1]: addr.store n[0] => _ @ bb0[11]: fn test_ref_field; _4 = pointers::S { field: const 0_i32, field2: const 0_u64, field3: move _5, field4: move _6 }; - n[2]: copy n[0] => _3 @ bb0[16]: fn test_ref_field; _3 = &mut (*_8); - n[3]: project[3, 3]@48 n[2] => _ @ bb0[18]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32); - n[4]: project[3, 3]@48 n[2] => _ @ bb0[19]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7; -} -nodes_that_need_write = [1, 0] - -g is_null=false { - n[0]: addr.load _ => _ @ bb0[18]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32); -} -nodes_that_need_write = [] - -g is_null=false { - n[0]: addr.store _ => _ @ bb0[19]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7; -} -nodes_that_need_write = [0] - g is_null=false { n[0]: &_1 _ => _ @ bb0[2]: fn test_addr_taken; _10 = &raw mut _1; n[1]: addr.store n[0] => _ @ bb0[1]: fn test_addr_taken; _1 = const 2_i32; @@ -1099,6 +1078,6 @@ g is_null=false { } nodes_that_need_write = [1, 0] -num_graphs = 83 -num_nodes = 764 +num_graphs = 80 +num_nodes = 755 diff --git a/pdg/src/snapshots/c2rust_pdg__tests__analysis_tests_misc_pdg_snapshot_release.snap b/pdg/src/snapshots/c2rust_pdg__tests__analysis_tests_misc_pdg_snapshot_release.snap index 3a21c4a2ff..09e34b8a04 100644 --- a/pdg/src/snapshots/c2rust_pdg__tests__analysis_tests_misc_pdg_snapshot_release.snap +++ b/pdg/src/snapshots/c2rust_pdg__tests__analysis_tests_misc_pdg_snapshot_release.snap @@ -36,10 +36,8 @@ g is_null=true { n[15]: copy n[10] => _17 @ bb15[4]: fn recur; _17 = _2; n[16]: value.store n[0] => _20.* @ bb4[7]: fn invalid; (*_20) = const 0_usize as *mut pointers::S (PointerFromExposedAddress); n[17]: value.store n[0] => _17.* @ bb8[4]: fn fdevent_unregister; (*_17) = const 0_usize as *mut pointers::fdnode_st (PointerFromExposedAddress); - n[18]: int_to_ptr n[0] => _2 @ bb0[2]: fn test_ref_field; _2 = const 0_usize as *const pointers::S (PointerFromExposedAddress); - n[19]: int_to_ptr n[0] => _5 @ bb0[8]: fn test_ref_field; _5 = const 0_usize as *const pointers::S (PointerFromExposedAddress); - n[20]: int_to_ptr n[0] => _51 @ bb36[3]: fn main_0; _51 = const 0_usize as *const pointers::S (PointerFromExposedAddress); - n[21]: value.store n[0] => _3.*.2 @ bb0[1]: fn test_addr_taken_arg; ((*_3).2: *const pointers::S) = const 0_usize as *const pointers::S (PointerFromExposedAddress); + n[18]: int_to_ptr n[0] => _50 @ bb35[3]: fn main_0; _50 = const 0_usize as *const pointers::S (PointerFromExposedAddress); + n[19]: value.store n[0] => _3.*.2 @ bb0[1]: fn test_addr_taken_arg; ((*_3).2: *const pointers::S) = const 0_usize as *const pointers::S (PointerFromExposedAddress); } nodes_that_need_write = [] @@ -929,15 +927,13 @@ g is_null=false { n[2]: addr.load n[1] => _ @ bb2[7]: fn test_load_value_store_value; _5 = (*_4); n[3]: addr.store n[1] => _ @ bb2[8]: fn test_load_value_store_value; (*_4) = move _5; n[4]: addr.load n[1] => _ @ bb2[12]: fn test_load_value_store_value; _7 = (*_4); - n[5]: addr.load n[0] => _ @ bb0[18]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32); - n[6]: addr.store n[0] => _ @ bb0[19]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7; } -nodes_that_need_write = [6, 3, 1, 0] +nodes_that_need_write = [3, 1, 0] g is_null=false { - n[0]: &_40 _ => _ @ bb32[4]: fn main_0; _59 = &raw mut _40; + n[0]: &_40 _ => _ @ bb32[4]: fn main_0; _58 = &raw mut _40; n[1]: addr.store n[0] => _ @ bb32[3]: fn main_0; _40 = [const 2_i32, const 5_i32, const 3_i32, const 1_i32, const 6_i32]; - n[2]: copy n[0] => _39 @ bb32[5]: fn main_0; _39 = &mut (*_59); + n[2]: copy n[0] => _39 @ bb32[5]: fn main_0; _39 = &mut (*_58); n[3]: copy n[2] => _45 @ bb32[12]: fn main_0; _45 = &(*_39); n[4]: copy n[3] => _44 @ bb32[13]: fn main_0; _44 = move _45 as &[i32] (Pointer(Unsize)); n[5]: copy n[4] => _1 @ bb0[0]: fn len; _43 = len(move _44); @@ -1016,15 +1012,6 @@ g is_null=false { } nodes_that_need_write = [77, 76, 75, 68, 67, 66, 65, 64, 63, 56, 55, 54, 47, 46, 45, 35, 34, 33, 29, 28, 27, 17, 16, 15, 8, 7, 6, 2, 1, 0] -g is_null=false { - n[0]: &_4 _ => _ @ bb0[12]: fn test_ref_field; _8 = &raw mut _4; - n[1]: addr.store n[0] => _ @ bb0[11]: fn test_ref_field; _4 = pointers::S { field: const 0_i32, field2: const 0_u64, field3: move _5, field4: move _6 }; - n[2]: copy n[0] => _3 @ bb0[16]: fn test_ref_field; _3 = &mut (*_8); - n[3]: project[3, 3]@48 n[2] => _ @ bb0[18]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32); - n[4]: project[3, 3]@48 n[2] => _ @ bb0[19]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7; -} -nodes_that_need_write = [1, 0] - g is_null=false { n[0]: &_1 _ => _ @ bb0[2]: fn test_addr_taken; _8 = &raw mut _1; n[1]: addr.store n[0] => _ @ bb0[1]: fn test_addr_taken; _1 = const 2_i32; @@ -1091,6 +1078,6 @@ g is_null=false { } nodes_that_need_write = [1, 0] -num_graphs = 81 -num_nodes = 764 +num_graphs = 80 +num_nodes = 755