Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miri: rename "undef" -> "uninit" #71193

Closed
RalfJung opened this issue Apr 16, 2020 · 30 comments
Closed

Miri: rename "undef" -> "uninit" #71193

RalfJung opened this issue Apr 16, 2020 · 30 comments
Labels
A-miri Area: The miri tool C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

RalfJung commented Apr 16, 2020

For historic reasons, Miri calls uninitialized memory and the value that you get when reading it "undef(ined)". This is potentially derived from LLVM undef. However, that is actually a misnomer -- Miri's "undef" is much more like LLVM's poison. Also, the docs and user-visible message usually speak about "uninitialized memory/values", and I think that terminology makes much more sense.

We should thus rename all "undef" in Miri to "uninit". In particular, but not limited to:

  • InvalidUndefBytes
  • ScalarMaybeUndef
  • UndefMask

Cc @oli-obk

@RalfJung RalfJung added C-cleanup Category: PRs that clean code up or issues documenting cleanup. A-miri Area: The miri tool labels Apr 16, 2020
@RalfJung RalfJung added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Apr 16, 2020
@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 16, 2020
@sanbox-irl
Copy link

@rustbot claim

@rustbot rustbot self-assigned this Apr 16, 2020
@hbina
Copy link
Contributor

hbina commented Apr 21, 2020

This will be quite a large change, especially if tests needs to be updated too. And what about the stuff in llvm-project/?

@RalfJung
Copy link
Member Author

RalfJung commented Apr 21, 2020

I don't think any tests need to be updated, as there should be no user-visible change. And we're not renaming LLVM, just our own Miri types and fields!

If you are grepping for this, only grep in src/librustc_middle/mir/interpret and src/librustc_mir/interpret.

hbina added a commit to hbina/rust that referenced this issue Apr 22, 2020
1. InvalidUndefBytes -> InvalidUninitBytes
2. ScalarMaybeUndef -> ScalarMaybeUninit
3. UndefMask -> UninitMask

Resolves rust-lang#71193
@hbina
Copy link
Contributor

hbina commented Apr 22, 2020

This test will fail

Check compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 90 tests
................F............................F................F.F.................FF......
failures:

---- [mir-opt] mir-opt/const_prop/control-flow-simplification.rs stdout ----
51                                                 // + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }
52                                                 // ty::Const
53                                                 // + ty: &str
-                                                  // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 })
+                                                  // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 })
55                                                 // mir::Constant
56                                                 // + span: $SRC_DIR/libstd/macros.rs:LL:COL
-                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
+                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
58            }
59        }
60        

thread '[mir-opt] mir-opt/const_prop/control-flow-simplification.rs' panicked at 'Actual MIR output differs from expected MIR output /home/hbinadesk/git/rust/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff', src/tools/compiletest/src/runtest.rs:3165:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- [mir-opt] mir-opt/inline/inline-into-box-place.rs stdout ----
24      -                                          // + ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new}
25      -                                          // + val: Value(Scalar(<ZST>))
26      +                                          // + ty: alloc::raw_vec::RawVec<u32>
-       +                                          // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } })
+       +                                          // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } })
28                                                 // mir::Constant
29      -                                          // + span: $DIR/inline-into-box-place.rs:8:33: 8:41
30      -                                          // + user_ty: UserType(1)

41      -         _0 = const ();                   // bb2[2]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2
42      +                                          // + span: $SRC_DIR/liballoc/vec.rs:LL:COL
43      +                                          // + user_ty: UserType(0)
-       +                                          // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
+       +                                          // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
45      +         ((*_4).1: usize) = const 0usize; // bb0[5]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL
46                                                 // ty::Const
47      +                                          // + ty: usize

thread '[mir-opt] mir-opt/inline/inline-into-box-place.rs' panicked at 'Actual MIR output differs from expected MIR output /home/hbinadesk/git/rust/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff', src/tools/compiletest/src/runtest.rs:3165:25

---- [mir-opt] mir-opt/no-drop-for-inactive-variant.rs stdout ----
32                                               // + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }
33                                               // ty::Const
34                                               // + ty: &str
-                                                // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 })
+                                                // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 })
36                                               // mir::Constant
37                                               // + span: $SRC_DIR/libstd/macros.rs:LL:COL
-                                                // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
+                                                // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
39          }
40
41          bb3: {

thread '[mir-opt] mir-opt/no-drop-for-inactive-variant.rs' panicked at 'Actual MIR output differs from expected MIR output /home/hbinadesk/git/rust/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir', src/tools/compiletest/src/runtest.rs:3165:25

---- [mir-opt] mir-opt/no-spurious-drop-after-call.rs stdout ----
15              _4 = const "";                   // bb0[4]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
16                                               // ty::Const
17                                               // + ty: &str
-                                                // + val: Value(Slice { data: Allocation { bytes: [], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [], len: Size { raw: 0 } }, size: Size { raw: 0 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 0 })
+                                                // + val: Value(Slice { data: Allocation { bytes: [], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [], len: Size { raw: 0 } }, size: Size { raw: 0 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 0 })
19                                               // mir::Constant
20                                               // + span: $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
-                                                // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [], len: Size { raw: 0 } }, size: Size { raw: 0 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 0 }) }
+                                                // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [], len: Size { raw: 0 } }, size: Size { raw: 0 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 0 }) }
22              _3 = &(*_4);                     // bb0[5]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
23              _2 = const <str as std::string::ToString>::to_string(move _3) -> bb2; // bb0[6]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:34
24                                               // ty::Const

thread '[mir-opt] mir-opt/no-spurious-drop-after-call.rs' panicked at 'Actual MIR output differs from expected MIR output /home/hbinadesk/git/rust/src/test/mir-opt/no-spurious-drop-after-call/rustc.main.ElaborateDrops.before.mir', src/tools/compiletest/src/runtest.rs:3165:25

---- [mir-opt] mir-opt/uninhabited_enum_branching.rs stdout ----
27                _5 = const "C";                  // bb1[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
28                                                 // ty::Const
29                                                 // + ty: &str
-                                                  // + val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                                  // + val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
31                                                 // mir::Constant
32                                                 // + span: $DIR/uninhabited_enum_branching.rs:23:21: 23:24
-                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
34                _1 = &(*_5);                     // bb1[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
35                StorageDead(_5);                 // bb1[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:23: 23:24
36                goto -> bb4;                     // bb1[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6

40                _1 = const "A(Empty)";           // bb2[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:24: 21:34
41                                                 // ty::Const
42                                                 // + ty: &str
-                                                  // + val: Value(Slice { data: Allocation { bytes: [65, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 })
+                                                  // + val: Value(Slice { data: Allocation { bytes: [65, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 })
44                                                 // mir::Constant
45                                                 // + span: $DIR/uninhabited_enum_branching.rs:21:24: 21:34
-                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [65, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) }
+                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [65, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) }
47                goto -> bb4;                     // bb2[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
48            }
49        

52                _4 = const "B(Empty)";           // bb3[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34
53                                                 // ty::Const
54                                                 // + ty: &str
-                                                  // + val: Value(Slice { data: Allocation { bytes: [66, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 })
+                                                  // + val: Value(Slice { data: Allocation { bytes: [66, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 })
56                                                 // mir::Constant
57                                                 // + span: $DIR/uninhabited_enum_branching.rs:22:24: 22:34
-                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [66, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) }
+                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [66, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) }
59                _1 = &(*_4);                     // bb3[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34
60                StorageDead(_4);                 // bb3[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:33: 22:34
61                goto -> bb4;                     // bb3[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6

76                _9 = const "E";                  // bb5[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
77                                                 // ty::Const
78                                                 // + ty: &str
-                                                  // + val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                                  // + val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
80                                                 // mir::Constant
81                                                 // + span: $DIR/uninhabited_enum_branching.rs:28:21: 28:24
-                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
83                _6 = &(*_9);                     // bb5[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
84                StorageDead(_9);                 // bb5[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:23: 28:24
85                goto -> bb7;                     // bb5[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6

89                _6 = const "D";                  // bb6[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:21: 27:24
90                                                 // ty::Const
91                                                 // + ty: &str
-                                                  // + val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                                  // + val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
93                                                 // mir::Constant
94                                                 // + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24
-                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+                                                  // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
96                goto -> bb7;                     // bb6[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
97            }
98        

thread '[mir-opt] mir-opt/uninhabited_enum_branching.rs' panicked at 'Actual MIR output differs from expected MIR output /home/hbinadesk/git/rust/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff', src/tools/compiletest/src/runtest.rs:3165:25

---- [mir-opt] mir-opt/storage_live_dead_in_statics.rs stdout ----
653             _2 = Foo { tup: const "hi", data: move _3 }; // bb0[94]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:29: 23:2
654                                              // ty::Const
655                                              // + ty: &str
-                                                // + val: Value(Slice { data: Allocation { bytes: [104, 105], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 })
+                                                // + val: Value(Slice { data: Allocation { bytes: [104, 105], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 })
657                                              // mir::Constant
658                                              // + span: $DIR/storage_live_dead_in_statics.rs:6:10: 6:14
-                                                // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [104, 105], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) }
+                                                // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [104, 105], relocations: Relocations(SortedMap { data: [] }), undef_mask: UninitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) }
660             _1 = &_2;                        // bb0[95]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2
661             _0 = &(*_1);                     // bb0[96]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2
662             StorageDead(_5);                 // bb0[97]: scope 0 at $DIR/storage_live_dead_in_statics.rs:23:1: 23:2

thread '[mir-opt] mir-opt/storage_live_dead_in_statics.rs' panicked at 'Actual MIR output differs from expected MIR output /home/hbinadesk/git/rust/src/test/mir-opt/storage_live_dead_in_statics/rustc.XXX.mir_map.0.mir', src/tools/compiletest/src/runtest.rs:3165:25


failures:
    [mir-opt] mir-opt/const_prop/control-flow-simplification.rs
    [mir-opt] mir-opt/inline/inline-into-box-place.rs
    [mir-opt] mir-opt/no-drop-for-inactive-variant.rs
    [mir-opt] mir-opt/no-spurious-drop-after-call.rs
    [mir-opt] mir-opt/storage_live_dead_in_statics.rs
    [mir-opt] mir-opt/uninhabited_enum_branching.rs

test result: FAILED. 84 passed; 6 failed; 0 ignored; 0 measured; 0 filtered out

thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22


command did not execute successfully: "/home/hbinadesk/git/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/home/hbinadesk/git/rust/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/home/hbinadesk/git/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/home/hbinadesk/git/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/home/hbinadesk/git/rust/src/test/mir-opt" "--build-base" "/home/hbinadesk/git/rust/build/x86_64-unknown-linux-gnu/test/mir-opt" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "mir-opt" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/home/hbinadesk/git/rust/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/home/hbinadesk/git/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/home/hbinadesk/git/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python" "--lldb-python" "/usr/bin/python" "--gdb" "/usr/bin/gdb" "--lldb-version" "lldb version 6.0.0\n" "--lldb-python-dir" "/usr/lib/x86_64-linux-gnu/python2.7/site-packages" "--quiet" "--llvm-version" "9.0.1-rust-dev" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" ""
expected success, got: exit code: 101


failed to run: /home/hbinadesk/git/rust/build/bootstrap/debug/bootstrap test
Build completed unsuccessfully in 0:50:34

@RalfJung
Copy link
Member Author

@hbina thanks a lot for working on this!
I responded in your PR.

@RalfJung
Copy link
Member Author

Another type we will want to rename in a second batch is AllocationDefinedness. Also there are probably plenty of comments still left to be updated.

@Dylan-DPC-zz
Copy link

@hbina just a small note: before working on an issue, please check if someone else has claimed it (if it is assigned to rustbot) :)

hbina added a commit to hbina/rust that referenced this issue May 7, 2020
1. InvalidUndefBytes -> InvalidUninitBytes
2. ScalarMaybeUndef -> ScalarMaybeUninit
3. UndefMask -> InitMask

Related issue  rust-lang#71193
bors added a commit to rust-lang-ci/rust that referenced this issue May 8, 2020
Renamed "undef" -> "uninit"

1. InvalidUndefBytes -> InvalidUninitBytes
2. ScalarMaybeUndef -> ScalarMaybeUninit
3. UndefMask -> InitMask

Related issue rust-lang#71193
@RalfJung
Copy link
Member Author

RalfJung commented May 9, 2020

All right, the first round of renames landed. :) Thanks @hbina!

For the second round, here are some more names in librustc_middle/mir/interpret that should be changed:

  • ScalarMaybeUninit::not_undef -> ... hm @oli-obk how do we call this, not_uninit is a bit weird. what about init? check_init?
  • Allocation::undef -> uninit
  • check_defined_and_ptr -> check_init_and_ptr
  • is_defined+check_defined -> is_init/check_init
  • mark_definedness -> mark_init
  • AllocationDefinedness -> ... this is really the same information as InitMask but more compact for copying right? So maybe InitMaskCompact or InitMaskCompressed or so?
  • all_bytes_undef -> all_bytes_uninit
  • mark_compressed_undef_range -> mark_compressed_init_range (or "compact" if that's what we are going for above)

@oli-obk
Copy link
Contributor

oli-obk commented May 9, 2020

* `not_uninit` is a bit weird. what about `init`? `check_init`?

yea, check_init sounds good. not_undef always was a bit odd

* `is_defined`+`check_defined` -> `is_init`/`check_init`

this makes me wonder whether it should be is_initialized and check_initialized

* `all_bytes_undef` -> `all_bytes_uninit`

any_bytes_init?

@RalfJung
Copy link
Member Author

RalfJung commented May 9, 2020

this makes me wonder whether it should be is_initialized and check_initialized

initialized is very long and unint has a lot of precedence, so I think I'd prefer the short version.

any_bytes_init?

I guess it depends on the caller which naming is more apt. But I feel like an "all" statement is intuitively clearer than an "any" statement.

@pnadon
Copy link
Contributor

pnadon commented Jul 21, 2020

Hello,

I saw that this issue was still open but the last post was 2 months ago, is there a chance I could try and help out?

@Dylan-DPC-zz
Copy link

@pnadon sure.. 2 months is a short timeframe in rust's perspective :D

@pnadon
Copy link
Contributor

pnadon commented Jul 21, 2020

@Dylan-DPC Ok sounds good,

From what I understand from the comments above, the two directories I should look in are

src/librustc_middle/mir/interpret
and
src/librustc_mir/interpret

And the goal would be to rename parts of names with "undef" in them to "uninit", along with some changes with "def" to "init". Is this correct?

@RalfJung
Copy link
Member Author

RalfJung commented Jul 21, 2020

@pnadon thanks for chiming in! Yes, that sounds right. More specifically, as far as I know, the list at #71193 (comment) is still up-to-date. Post in this thread or open a topic on Rust's Zulip if you need any help; my availability is spotty until mid next week but there'll always be someone around. :)

@pnadon
Copy link
Contributor

pnadon commented Jul 22, 2020

this makes me wonder whether it should be is_initialized and check_initialized

initialized is very long and unint has a lot of precedence, so I think I'd prefer the short version.

any_bytes_init?

I guess it depends on the caller which naming is more apt. But I feel like an "all" statement is intuitively clearer than an "any" statement.

no_bytes_init? I assumed it would be synonymous with "all_bytes_uninit"

@pnadon
Copy link
Contributor

pnadon commented Jul 22, 2020

All right, the first round of renames landed. :) Thanks @hbina!

For the second round, here are some more names in librustc_middle/mir/interpret that should be changed:

* `ScalarMaybeUninit::not_undef` -> ... hm @oli-obk  how do we call this, `not_uninit` is a bit weird. what about `init`? `check_init`?

* `Allocation::undef` -> `uninit`

* `check_defined_and_ptr` -> `check_init_and_ptr`

* `is_defined`+`check_defined` -> `is_init`/`check_init`

* `mark_definedness` -> `mark_init`

I have made commits for the above changes, however I would like to wait until everyone agrees on the new names for below:

* `AllocationDefinedness` -> ... this is really the same information as `InitMask` but more compact for copying right? So maybe `InitMaskCompact` or `InitMaskCompressed` or so?

I think InitMaskCompressed would be more of a mouthful but also more accurate based on the definition here, so I agree with the latter.

* `all_bytes_undef` -> `all_bytes_uninit`

As per my previous comment, no_bytes_init?

* `mark_compressed_undef_range` -> `mark_compressed_init_range` (or "compact" if that's what we are going for above)

I agree.

@RalfJung
Copy link
Member Author

I like no_bytes_init.

@pnadon
Copy link
Contributor

pnadon commented Jul 23, 2020

I have also found:

  • inspect_with_undef_and_ptr_outside_interpreter (line 160)
  • get_bytes_with_undef_and_ptr (247)
  • allow_ptr_and_undef parameter for check_bytes (312)
  • compress_undef_range (597)
  • and the undef_end variable (781)
    for src/librustc_middle/mir/interpret, all inside of allocation.rs. Should these be changed as well?

There are also many comments which should be changed, many of them refer to "definedness", which I am not sure what to replace with.

@RalfJung
Copy link
Member Author

Yes, those all should become "uninit" I think.

For consistency maybe allow_ptr_and_undef should become allow_uninit_and_ptr.

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 26, 2020
…lfJung

Miri rename undef uninit

Renamed parts of code within the `librustc_middle/mir/interpret/` directory.

Related issue [rust-lang#71193](rust-lang#71193)
bors added a commit to rust-lang/miri that referenced this issue Jul 27, 2020
Miri rename undef uninit

The changes made here are related to [issue #71193 on Rust](rust-lang/rust#71193), and the pull request [74664 on Rust](rust-lang/rust#74664).

1. renamed `ScalarMaybeUninit::not_undef` to `check_init`
2. renamed `Immediate::to_scalar_or_undef` to `Immediate::to_scalar_or_uninit`
@pnadon
Copy link
Contributor

pnadon commented Jul 28, 2020

Yes, those all should become "uninit" I think.

For consistency maybe allow_ptr_and_undef should become allow_uninit_and_ptr.

Sounds good. Should I go ahead and implement those changes?

I will also look around for any comments etc. that we may have missed and make sure that we've got them all.

@RalfJung
Copy link
Member Author

RalfJung commented Jul 30, 2020

@pnadon yes please do. :)

@pnadon
Copy link
Contributor

pnadon commented Aug 6, 2020

I've done the initial renames, however outside of the two directories (src/librustc_middle/mir/interpret and src/librustc_mir/interpret) we had initially planned to work within, there are changes made in the following files:

  1. src/librustc_codegen_llvm/consts.rs, lines {44, 52, 77, 455, and 483}, which all contain the inspect_with_undef_and_ptr_outside_interpreter function and thus must be renamed.
  2. src/tools/clippy/clippy_lints/src/consts.rs, lines {520, 533, 547}, which also contain the inspect_with_undef_and_ptr_outside_interpreter function and thus must be renamed.

The former seems to be a fairly straightforward change, I just want to confirm that it's ok. As for the latter, since it is a submodule, I believe I will have to create a pull request for clippy with those changes.

Once these issues are resolved, I will look into making the approapriate changes within the Miri repo.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 6, 2020

clippy is not a submodule anymore. You can do these renames either here or in clippy as you prefer

@pnadon
Copy link
Contributor

pnadon commented Aug 6, 2020

clippy is not a submodule anymore. You can do these renames either here or in clippy as you prefer

Sounds good!

@pnadon
Copy link
Contributor

pnadon commented Aug 6, 2020

I have also found:

* `inspect_with_undef_and_ptr_outside_interpreter` (line 160)

* `get_bytes_with_undef_and_ptr` (247)

* `allow_ptr_and_undef` parameter for `check_bytes` (312)

* `compress_undef_range` (597)

* and the `undef_end` variable (781)
  for `src/librustc_middle/mir/interpret`, all inside of allocation.rs. Should these be changed as well?

There are also many comments which should be changed, many of them refer to "definedness", which I am not sure what to replace with.

Upon further inspection it does not seem as though there are any references to the above functions within the Miri repository.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 6, 2020

Upon further inspection it does not seem as though there are any references to the above functions within the Miri repository.

That's great, it makes the rename easier. :)
Does your list contain all uses of "undef" in src/librustc_middle/mir/interpret and src/librustc_mir/interpret?

There are also many comments which should be changed, many of them refer to "definedness", which I am not sure what to replace with.

"initializedness" is awkward, so they should probably be reworded. But from what I can see there is just one occurrence of "definedness" left in the Miri folders:

src/librustc_middle/mir/interpret/allocation.rs
636-        size: Size,
637-        repeat: u64,
638-    ) {
639:        // An optimization where we can just overwrite an entire range of definedness bits if
640-        // they are going to be uniformly `1` or `0`.
641-        if defined.ranges.len() <= 1 {
642-            self.init_mask.set_range_inbounds(

I'd make this "an entire range of initialization bits" or so.

@pnadon
Copy link
Contributor

pnadon commented Aug 6, 2020

Upon further inspection it does not seem as though there are any references to the above functions within the Miri repository.

That's great, it makes the rename easier. :)
Does your list contain all uses of "undef" in src/librustc_middle/mir/interpret and src/librustc_mir/interpret?

There are also many comments which should be changed, many of them refer to "definedness", which I am not sure what to replace with.

"initializedness" is awkward, so they should probably be reworded. But from what I can see there is just one occurrence of "definedness" left in the Miri folders:

src/librustc_middle/mir/interpret/allocation.rs
636-        size: Size,
637-        repeat: u64,
638-    ) {
639:        // An optimization where we can just overwrite an entire range of definedness bits if
640-        // they are going to be uniformly `1` or `0`.
641-        if defined.ranges.len() <= 1 {
642-            self.init_mask.set_range_inbounds(

I'd make this "an entire range of initialization bits" or so.

Thank you for catching that, I'll look into it!

@pnadon
Copy link
Contributor

pnadon commented Aug 6, 2020

Miri builds successfully, I have double-checked my search through both directories and all references to "undef" refer to "undefined behavior" which (unless I'm wrong) is unrelated.

I have also changed the last remaining "definedness" to the recommended change.

If this all looks good I will open a PR with my changes.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 6, 2020

It sounds great, please open a PR. :)

JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 11, 2020
Miri: Renamed "undef" to "uninit"

Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- `src/librustc_codegen_llvm/consts.rs`
- `src/librustc_middle/mir/interpret/`
- `src/librustc_middle/ty/print/pretty.rs`
- `src/librustc_mir/`
- `src/tools/clippy/clippy_lints/src/consts.rs`

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue rust-lang#71193
@RalfJung
Copy link
Member Author

@pnadon fixed the remaining ones in #75226, I think we are done. Thanks a lot to everyone involved. :)

flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 28, 2020
Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- src/librustc_codegen_llvm/consts.rs
- src/librustc_middle/mir/interpret/
- src/librustc_middle/ty/print/pretty.rs
- src/librustc_mir/
- src/tools/clippy/clippy_lints/src/consts.rs

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue rust-lang#71193
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 28, 2020
Miri: Renamed "undef" to "uninit"

Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- `src/librustc_codegen_llvm/consts.rs`
- `src/librustc_middle/mir/interpret/`
- `src/librustc_middle/ty/print/pretty.rs`
- `src/librustc_mir/`
- `src/tools/clippy/clippy_lints/src/consts.rs`

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue rust-lang#71193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-miri Area: The miri tool C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants