Skip to content

Commit

Permalink
Fix demote_ptr_to_int test
Browse files Browse the repository at this point in the history
  • Loading branch information
vaivaswatha committed Apr 6, 2024
1 parent 2bce7ed commit bde6bab
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions sway-ir/tests/demote_misc/demote_ptr_to_int.ir
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
script {
fn test(v1: b256) -> u64 {
entry(v1: b256):
v2 = ptr_to_int v1 to u64
ret u64 v2
}
entry fn main() -> u64 {
local b256 foo = const b256 0x2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b

entry():
v0 = get_local ptr b256, foo
v1 = load v0
v2 = ptr_to_int v1 to u64
ret u64 v2
foo_ptr = get_local ptr b256, foo
foo = load foo_ptr
v1 = call test(foo)
ret u64 v1
}
}

// regex: VAL=v\d+
// regex: ID=[[:alpha:]0-9_]+

// check: fn test($(foo_val=$ID): b256) -> u64
// check: local b256 $(tmp_loc=$ID)
// check: local b256 foo = const b256 0x2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b

// check: $(foo_ptr=$VAL) = get_local ptr b256, foo
// check: $(foo_val=$VAL) = load $foo_ptr
// check: $(tmp_ptr=$VAL) = get_local ptr b256, $tmp_loc
// check: store $foo_val to $tmp_ptr
// check: $(tmp_ptr_int=$VAL) = ptr_to_int $tmp_ptr to u64
// check: ret u64 $tmp_ptr_int

// check: entry fn main() -> u64
// check: local b256 foo = const b256 0x2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b
// check: $(foo_ptr=$VAL) = get_local ptr b256, foo
// check: $(foo_val=$VAL) = load $foo_ptr

0 comments on commit bde6bab

Please sign in to comment.