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

Add FileCheck annotations to dataflow-const-prop tests #119759

Merged
merged 19 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add FileCheck to struct.rs
  • Loading branch information
sfzhu93 committed Jan 9, 2024
commit 732f6a1303c4e3f9a354221e76e065571b2f1e37
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,33 @@
let _8: std::option::Option<S>;
let _9: &[f32];
scope 4 {
debug a => _7;
debug b => _8;
debug c => _9;
debug a1 => _7;
debug b1 => _8;
debug c1 => _9;
let _11: f32;
let _12: std::option::Option<S>;
let _13: &[f32];
scope 5 {
debug a => _11;
debug b => _12;
debug c => _13;
debug a2 => _11;
debug b2 => _12;
debug c2 => _13;
let _15: SmallStruct;
scope 6 {
debug ss => _15;
let _19: f32;
let _20: std::option::Option<S>;
let _21: &[f32];
scope 7 {
debug a => _19;
debug b => _20;
debug c => _21;
debug a3 => _19;
debug b3 => _20;
debug c3 => _21;
let _23: f32;
let _24: std::option::Option<S>;
let _25: &[f32];
scope 8 {
debug a => _23;
debug b => _24;
debug c => _25;
debug a4 => _23;
debug b4 => _24;
debug c4 => _25;
let _27: BigStruct;
scope 9 {
debug bs => _27;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,33 @@
let _8: std::option::Option<S>;
let _9: &[f32];
scope 4 {
debug a => _7;
debug b => _8;
debug c => _9;
debug a1 => _7;
debug b1 => _8;
debug c1 => _9;
let _11: f32;
let _12: std::option::Option<S>;
let _13: &[f32];
scope 5 {
debug a => _11;
debug b => _12;
debug c => _13;
debug a2 => _11;
debug b2 => _12;
debug c2 => _13;
let _15: SmallStruct;
scope 6 {
debug ss => _15;
let _19: f32;
let _20: std::option::Option<S>;
let _21: &[f32];
scope 7 {
debug a => _19;
debug b => _20;
debug c => _21;
debug a3 => _19;
debug b3 => _20;
debug c3 => _21;
let _23: f32;
let _24: std::option::Option<S>;
let _25: &[f32];
scope 8 {
debug a => _23;
debug b => _24;
debug c => _25;
debug a4 => _23;
debug b4 => _24;
debug c4 => _25;
let _27: BigStruct;
scope 9 {
debug bs => _27;
Expand Down
55 changes: 48 additions & 7 deletions tests/mir-opt/dataflow-const-prop/struct.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// unit-test: DataflowConstProp
// EMIT_MIR_FOR_EACH_BIT_WIDTH

Expand All @@ -12,27 +11,69 @@ struct SmallStruct(f32, Option<S>, &'static [f32]);
struct BigStruct(f32, Option<S>, &'static [f32]);

// EMIT_MIR struct.main.DataflowConstProp.diff

// CHECK-LABEL: fn main
fn main() {
// CHECK: debug s => [[s:_[0-9]+]];
// CHECK: debug a => [[a:_[0-9]+]];
// CHECK: debug b => [[b:_[0-9]+]];
// CHECK: debug a1 => [[a1:_[0-9]+]];
// CHECK: debug b1 => [[b1:_[0-9]+]];
// CHECK: debug c1 => [[c1:_[0-9]+]];
// CHECK: debug a2 => [[a2:_[0-9]+]];
// CHECK: debug b2 => [[b2:_[0-9]+]];
// CHECK: debug c2 => [[c2:_[0-9]+]];
// CHECK: debug ss => [[ss:_[0-9]+]];
// CHECK: debug a3 => [[a3:_[0-9]+]];
// CHECK: debug b3 => [[b3:_[0-9]+]];
// CHECK: debug c3 => [[c3:_[0-9]+]];
// CHECK: debug a4 => [[a4:_[0-9]+]];
// CHECK: debug b4 => [[b4:_[0-9]+]];
// CHECK: debug c4 => [[c4:_[0-9]+]];
// CHECK: debug bs => [[bs:_[0-9]+]];

// CHECK: [[s]] = const S(1_i32);
let mut s = S(1);

// CHECK: [[a]] = const 3_i32;
let a = s.0 + 2;
s.0 = 3;

// CHECK: [[b]] = const 6_i32;
let b = a + s.0;

const SMALL_VAL: SmallStruct = SmallStruct(4., Some(S(1)), &[]);
let SmallStruct(a, b, c) = SMALL_VAL;

// CHECK: [[a1]] = const 4f32;
// CHECK: [[b1]] = const Option::<S>::Some(S(1_i32));
// CHECK: [[c1]] = ({{_[0-9]+}}.2: &[f32]);
let SmallStruct(a1, b1, c1) = SMALL_VAL;

static SMALL_STAT: &SmallStruct = &SmallStruct(9., None, &[13.]);
let SmallStruct(a, b, c) = *SMALL_STAT;

let ss = SmallStruct(a, b, c);
// CHECK: [[a2]] = const 9f32;
// CHECK: [[b2]] = ((*{{_[0-9]+}}).1: std::option::Option<S>);
// CHECK: [[c2]] = ((*{{_[0-9]+}}).2: &[f32]);
let SmallStruct(a2, b2, c2) = *SMALL_STAT;

// CHECK: [[ss]] = SmallStruct(const 9f32, move {{_[0-9]+}}, move {{_[0-9]+}});
let ss = SmallStruct(a2, b2, c2);

const BIG_VAL: BigStruct = BigStruct(25., None, &[]);
let BigStruct(a, b, c) = BIG_VAL;

// CHECK: [[a3]] = const 25f32;
// CHECK: [[b3]] = ({{_[0-9]+}}.1: std::option::Option<S>);
// CHECK: [[c3]] = ({{_[0-9]+}}.2: &[f32]);
let BigStruct(a3, b3, c3) = BIG_VAL;

static BIG_STAT: &BigStruct = &BigStruct(82., Some(S(35)), &[45., 72.]);
let BigStruct(a, b, c) = *BIG_STAT;
// CHECK: [[a4]] = const 82f32;
// CHECK: [[b4]] = const Option::<S>::Some(S(35_i32));
// CHECK: [[c4]] = ((*{{_[0-9]+}}).2: &[f32]);
let BigStruct(a4, b4, c4) = *BIG_STAT;

// We arbitrarily limit the size of synthetized values to 4 pointers.
// `BigStruct` can be read, but we will keep a MIR aggregate for this.
let bs = BigStruct(a, b, c);
// CHECK: [[bs]] = BigStruct(const 82f32, const Option::<S>::Some(S(35_i32)), move {{_[0-9]+}});
let bs = BigStruct(a4, b4, c4);
}