GaloisInc / mir-json

Plugin for rustc to dump MIR in JSON format
Apache License 2.0
9 stars 2 forks source link

Don't print `slice op_ty` output by default #69

Closed RyanGlScott closed 4 months ago

RyanGlScott commented 4 months ago

If you use mir-json to compile a program with a constant slice value, such as this one:

const X: &[u32] = &[0; 4];
const Y: &[u32] = &[0; 4];

pub fn f(_x: &[u32], _y: &[u32]) {}

pub fn g() {
    f(X, Y);
}

Then the mir-json output is surprisingly noisy:

$ saw-rustc test.rs 
test build - extract output path - ["rustc", "test.rs", "--test", "--target", "x86_64-unknown-linux-gnu", "--cfg", "crux"]
test build - ["rustc", "test.rs", "--target", "x86_64-unknown-linux-gnu", "--cfg", "crux", "--cfg", "crux_top_level", "--crate-type", "rlib"]
note: Emitting MIR for test/48b0e836::f

note: Emitting MIR for test/48b0e836::g

slice op_ty: OpTy { op: Indirect(MemPlace { ptr: alloc11, meta: None }), layout: TyAndLayout { ty: &[u32], layout: Layout { size: Size(16 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: ScalarPair(Initialized { value: Pointer, valid_range: 1..=18446744073709551615 }, Initialized { value: Int(I64, false), valid_range: 0..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes)], memory_index: [0, 1] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer, valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } } }, align: Some(Align(8 bytes)) }
slice op_ty: OpTy { op: Indirect(MemPlace { ptr: alloc12, meta: None }), layout: TyAndLayout { ty: &[u32], layout: Layout { size: Size(16 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: ScalarPair(Initialized { value: Pointer, valid_range: 1..=18446744073709551615 }, Initialized { value: Int(I64, false), valid_range: 0..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes)], memory_index: [0, 1] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer, valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } } }, align: Some(Align(8 bytes)) }
linking 1 mir files into test.linked-mir.json
  inputs: libtest.mir
generated test script test

In particular, the slice op_ty part of the output feels like debugging output that shouldn't surface during a normal execution. I propose that we either relegate this output to a higher verbosity level or remove it outright.

spernsteiner commented 4 months ago

Yep, that looks like debug output from the recent overhaul of const eval handling. It's probably safe to remove it entirely.