Skip to content

Commit

Permalink
FileCheck const_debuginfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 31, 2023
1 parent 3d45470 commit e65ec7d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 42 deletions.
91 changes: 53 additions & 38 deletions tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
fn main() -> () {
let mut _0: ();
let _1: u8;
let mut _5: u8;
let mut _6: u8;
let mut _7: u8;
let mut _8: u8;
let mut _14: u32;
let mut _15: u32;
scope 1 {
- debug x => _1;
+ debug x => const 1_u8;
Expand All @@ -19,34 +25,23 @@
scope 4 {
- debug sum => _4;
+ debug sum => const 6_u8;
let _5: &str;
let _9: &str;
scope 5 {
- debug s => _5;
- debug s => _9;
+ debug s => const "hello, world!";
let _8: bool;
let _9: bool;
let _10: u32;
let _10: (bool, bool, u32);
scope 6 {
- debug ((f: (bool, bool, u32)).0: bool) => _8;
- debug ((f: (bool, bool, u32)).1: bool) => _9;
- debug ((f: (bool, bool, u32)).2: u32) => _10;
+ debug ((f: (bool, bool, u32)).0: bool) => const true;
+ debug ((f: (bool, bool, u32)).1: bool) => const false;
+ debug ((f: (bool, bool, u32)).2: u32) => const 123_u32;
let _6: std::option::Option<u16>;
debug f => _10;
let _11: std::option::Option<u16>;
scope 7 {
- debug o => _6;
+ debug o => const Option::<u16>::Some(99_u16);
let _11: u32;
let _12: u32;
debug o => _11;
let _12: Point;
scope 8 {
- debug ((p: Point).0: u32) => _11;
- debug ((p: Point).1: u32) => _12;
+ debug ((p: Point).0: u32) => const 32_u32;
+ debug ((p: Point).1: u32) => const 32_u32;
let _7: u32;
- debug p => _12;
+ debug p => const Point {{ x: 32_u32, y: 32_u32 }};
let _13: u32;
scope 9 {
- debug a => _7;
- debug a => _13;
+ debug a => const 64_u32;
}
}
Expand All @@ -59,37 +54,57 @@
}

bb0: {
StorageLive(_1);
_1 = const 1_u8;
StorageLive(_2);
_2 = const 2_u8;
StorageLive(_3);
_3 = const 3_u8;
StorageLive(_4);
_4 = const 6_u8;
StorageLive(_5);
_5 = const "hello, world!";
StorageLive(_8);
StorageLive(_9);
StorageLive(_10);
_8 = const true;
_9 = const false;
_10 = const 123_u32;
StorageLive(_6);
_6 = const Option::<u16>::Some(99_u16);
_11 = const 32_u32;
_12 = const 32_u32;
_6 = const 1_u8;
StorageLive(_7);
_7 = const 64_u32;
_7 = const 2_u8;
_5 = const 3_u8;
StorageDead(_7);
StorageDead(_6);
StorageLive(_8);
_8 = const 3_u8;
_4 = const 6_u8;
StorageDead(_8);
StorageDead(_9);
StorageDead(_10);
StorageDead(_5);
StorageLive(_9);
_9 = const "hello, world!";
StorageLive(_10);
_10 = (const true, const false, const 123_u32);
StorageLive(_11);
_11 = Option::<u16>::Some(const 99_u16);
StorageLive(_12);
_12 = const Point {{ x: 32_u32, y: 32_u32 }};
StorageLive(_13);
StorageLive(_14);
_14 = const 32_u32;
StorageLive(_15);
_15 = const 32_u32;
_13 = const 64_u32;
StorageDead(_15);
StorageDead(_14);
_0 = const ();
StorageDead(_13);
StorageDead(_12);
StorageDead(_11);
StorageDead(_10);
StorageDead(_9);
StorageDead(_4);
StorageDead(_3);
StorageDead(_2);
StorageDead(_1);
return;
}
}

ALLOC0 (size: 4, align: 2) {
01 00 63 00 │ ..c.
ALLOC0 (size: 8, align: 4) {
20 00 00 00 20 00 00 00 │ ... ...
}

17 changes: 13 additions & 4 deletions tests/mir-opt/const_debuginfo.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
// skip-filecheck
// compile-flags: -C overflow-checks=no -Zunsound-mir-opts
// unit-test: ConstDebugInfo
// compile-flags: -C overflow-checks=no -Zmir-enable-passes=+ConstProp

struct Point {
x: u32,
y: u32,
}

// EMIT_MIR const_debuginfo.main.ConstDebugInfo.diff
fn main() {
// CHECK-LABEL: fn main(
// CHECK: debug x => const 1_u8;
// CHECK: debug y => const 2_u8;
// CHECK: debug z => const 3_u8;
// CHECK: debug sum => const 6_u8;
// CHECK: debug s => const "hello, world!";
// CHECK: debug f => {{_.*}};
// CHECK: debug o => {{_.*}};
// CHECK: debug p => const Point
// CHECK: debug a => const 64_u32;
let x = 1u8;
let y = 2u8;
let z = 3u8;
Expand All @@ -21,5 +32,3 @@ fn main() {
let p = Point { x: 32, y: 32 };
let a = p.x + p.y;
}

// EMIT_MIR const_debuginfo.main.ConstDebugInfo.diff

0 comments on commit e65ec7d

Please sign in to comment.