-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
199 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
all: test.linked-mir.json | ||
|
||
test.linked-mir.json: test.rs | ||
saw-rustc $< | ||
$(MAKE) remove-unused-build-artifacts | ||
|
||
.PHONY: remove-unused-build-artifacts | ||
remove-unused-build-artifacts: | ||
rm -f test libtest.mir libtest.rlib | ||
|
||
.PHONY: clean | ||
clean: remove-unused-build-artifacts | ||
rm -f test.linked-mir.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"fns":[{"abi":{"kind":"Rust"},"args":[{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::u32"}],"body":{"blocks":[{"block":{"data":[{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::u32"}},"pos":"test.rs:6:8: 6:13","rhs":{"kind":"Use","usevar":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::u32"}},"kind":"Copy"}}},{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_2","ty":"ty::bool"}},"pos":"test.rs:6:8: 6:24","rhs":{"L":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::u32"}},"kind":"Move"},"R":{"data":{"rendered":{"kind":"uint","size":4,"val":"4294967295"},"ty":"ty::u32"},"kind":"Constant"},"kind":"BinaryOp","op":{"kind":"Lt"}}}],"terminator":{"discr":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_2","ty":"ty::bool"}},"kind":"Move"},"discr_span":"test.rs:6:8: 6:24 !test.rs:6:8: 6:24","kind":"SwitchInt","pos":"test.rs:6:8: 6:24 !test.rs:6:8: 6:24","switch_ty":"ty::bool","targets":["bb3","bb1"],"values":["0"]}},"blockid":"bb0"},{"block":{"data":[{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_5","ty":"ty::u32"}},"pos":"test.rs:7:12: 7:17","rhs":{"kind":"Use","usevar":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::u32"}},"kind":"Copy"}}},{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_6","ty":"ty::Tuple::7063e33f0dbc8a58"}},"pos":"test.rs:7:12: 7:19","rhs":{"L":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_5","ty":"ty::u32"}},"kind":"Copy"},"R":{"data":{"rendered":{"kind":"uint","size":4,"val":"1"},"ty":"ty::u32"},"kind":"Constant"},"kind":"CheckedBinaryOp","op":{"kind":"Add"}}}],"terminator":{"cleanup":null,"cond":{"data":{"data":[{"field":1,"kind":"Field","ty":"ty::bool"}],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_6","ty":"ty::Tuple::7063e33f0dbc8a58"}},"kind":"Move"},"expected":false,"kind":"Assert","msg":"attempt to compute `move _5 + const 1_u32`, which would overflow","pos":"test.rs:7:12: 7:19","target":"bb2"}},"blockid":"bb1"},{"block":{"data":[{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_4","ty":"ty::u32"}},"pos":"test.rs:7:12: 7:19","rhs":{"kind":"Use","usevar":{"data":{"data":[{"field":0,"kind":"Field","ty":"ty::u32"}],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_6","ty":"ty::Tuple::7063e33f0dbc8a58"}},"kind":"Move"}}},{"kind":"Deinit","pos":"test.rs:7:9: 7:20"},{"kind":"Assign","lhs":{"data":[{"kind":"Downcast","variant":0},{"field":0,"kind":"Field","ty":"ty::u32"}],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Adt::0d08cc03e8faa6eb"}},"pos":"test.rs:7:9: 7:20","rhs":{"kind":"Use","usevar":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_4","ty":"ty::u32"}},"kind":"Move"}}},{"kind":"SetDiscriminant","lvalue":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Adt::0d08cc03e8faa6eb"}},"pos":"test.rs:7:9: 7:20","variant_index":0}],"terminator":{"kind":"Goto","pos":"test.rs:6:5: 10:6","target":"bb4"}},"blockid":"bb2"},{"block":{"data":[{"kind":"Deinit","pos":"test.rs:9:9: 9:29"},{"kind":"SetDiscriminant","lvalue":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Adt::0d08cc03e8faa6eb"}},"pos":"test.rs:9:9: 9:29","variant_index":1}],"terminator":{"kind":"Goto","pos":"test.rs:6:5: 10:6","target":"bb4"}},"blockid":"bb3"},{"block":{"data":[],"terminator":{"kind":"Return","pos":"test.rs:11:2: 11:2"}},"blockid":"bb4"}],"vars":[{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Adt::0d08cc03e8faa6eb"},{"is_zst":false,"mut":{"kind":"Mut"},"name":"_2","ty":"ty::bool"},{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::u32"},{"is_zst":false,"mut":{"kind":"Mut"},"name":"_4","ty":"ty::u32"},{"is_zst":false,"mut":{"kind":"Mut"},"name":"_5","ty":"ty::u32"},{"is_zst":false,"mut":{"kind":"Mut"},"name":"_6","ty":"ty::Tuple::7063e33f0dbc8a58"}]},"name":"test/059ac093::increment","return_ty":"ty::Adt::0d08cc03e8faa6eb","spread_arg":null},{"abi":{"kind":"Rust"},"args":[],"body":{"blocks":[{"block":{"data":[],"terminator":{"args":[{"data":{"rendered":{"kind":"uint","size":4,"val":"0"},"ty":"ty::u32"},"kind":"Constant"}],"cleanup":null,"destination":[{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Adt::0d08cc03e8faa6eb"}},"bb1"],"from_hir_call":true,"func":{"data":{"rendered":{"kind":"zst"},"ty":"ty::FnDef::1a1eab9d9d698a9d"},"kind":"Constant"},"kind":"Call","pos":"test.rs:14:5: 14:17"}},"blockid":"bb0"},{"block":{"data":[],"terminator":{"kind":"Return","pos":"test.rs:15:2: 15:2"}},"blockid":"bb1"}],"vars":[{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Adt::0d08cc03e8faa6eb"}]},"name":"test/059ac093::f","return_ty":"ty::Adt::0d08cc03e8faa6eb","spread_arg":null},{"abi":{"kind":"Rust"},"args":[],"body":{"blocks":[{"block":{"data":[],"terminator":{"args":[{"data":{"rendered":{"kind":"uint","size":4,"val":"4294967295"},"ty":"ty::u32"},"kind":"Constant"}],"cleanup":null,"destination":[{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Adt::0d08cc03e8faa6eb"}},"bb1"],"from_hir_call":true,"func":{"data":{"rendered":{"kind":"zst"},"ty":"ty::FnDef::1a1eab9d9d698a9d"},"kind":"Constant"},"kind":"Call","pos":"test.rs:18:5: 18:24"}},"blockid":"bb0"},{"block":{"data":[],"terminator":{"kind":"Return","pos":"test.rs:19:2: 19:2"}},"blockid":"bb1"}],"vars":[{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Adt::0d08cc03e8faa6eb"}]},"name":"test/059ac093::g","return_ty":"ty::Adt::0d08cc03e8faa6eb","spread_arg":null}],"adts":[{"kind":{"discr_ty":"ty::isize","kind":"Enum"},"name":"test/059ac093::Error::_adtb7803c2264daf0ec[0]","orig_def_id":"test/059ac093::Error","orig_substs":[],"repr_transparent":false,"size":0,"variants":[{"ctor_kind":{"kind":"Const"},"discr":{"index":0,"kind":"Relative"},"discr_value":"0","fields":[],"inhabited":true,"name":"test/059ac093::Error::Overflow"}]},{"kind":{"discr_ty":"ty::isize","kind":"Enum"},"name":"core/73237d41::result::Result::_adt8c4e4dad4cfdd737[0]","orig_def_id":"core/73237d41::result::Result","orig_substs":["ty::u32","ty::Adt::c843e4c253dfdd59"],"repr_transparent":false,"size":8,"variants":[{"ctor_kind":{"kind":"Fn"},"discr":{"index":0,"kind":"Relative"},"discr_value":"0","fields":[{"name":"core/73237d41::result::Result::Ok::0","ty":"ty::u32"}],"inhabited":true,"name":"core/73237d41::result::Result::Ok"},{"ctor_kind":{"kind":"Fn"},"discr":{"index":1,"kind":"Relative"},"discr_value":"1","fields":[{"name":"core/73237d41::result::Result::Err::0","ty":"ty::Adt::c843e4c253dfdd59"}],"inhabited":true,"name":"core/73237d41::result::Result::Err"}]}],"statics":[],"vtables":[],"traits":[],"intrinsics":[{"inst":{"def_id":"test/059ac093::increment","kind":"Item","substs":[]},"name":"test/059ac093::increment"},{"inst":{"def_id":"test/059ac093::f","kind":"Item","substs":[]},"name":"test/059ac093::f"},{"inst":{"def_id":"test/059ac093::g","kind":"Item","substs":[]},"name":"test/059ac093::g"}],"tys":[{"name":"ty::u32","ty":{"kind":"Uint","uintkind":{"kind":"U32"}}},{"name":"ty::Adt::c843e4c253dfdd59","ty":{"kind":"Adt","name":"test/059ac093::Error::_adtb7803c2264daf0ec[0]","orig_def_id":"test/059ac093::Error","substs":[]}},{"name":"ty::Adt::0d08cc03e8faa6eb","ty":{"kind":"Adt","name":"core/73237d41::result::Result::_adt8c4e4dad4cfdd737[0]","orig_def_id":"core/73237d41::result::Result","substs":["ty::u32","ty::Adt::c843e4c253dfdd59"]}},{"name":"ty::bool","ty":{"kind":"Bool"}},{"name":"ty::Tuple::7063e33f0dbc8a58","ty":{"kind":"Tuple","tys":["ty::u32","ty::bool"]}},{"name":"ty::FnDef::1a1eab9d9d698a9d","ty":{"defid":"test/059ac093::increment","kind":"FnDef"}},{"name":"ty::isize","ty":{"intkind":{"kind":"Isize"},"kind":"Int"}}],"roots":["test/059ac093::increment","test/059ac093::f","test/059ac093::g"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pub enum Error { | ||
Overflow, | ||
} | ||
|
||
pub fn increment(count: u32) -> Result<u32, Error> { | ||
if count < u32::MAX { | ||
Ok(count+1) | ||
} else { | ||
Err(Error::Overflow) | ||
} | ||
} | ||
|
||
pub fn f() -> Result<u32, Error> { | ||
increment(0) | ||
} | ||
|
||
pub fn g() -> Result<u32, Error> { | ||
increment(u32::MAX) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
enable_experimental; | ||
|
||
m <- mir_load_module "test.linked-mir.json"; | ||
|
||
let error_adt = mir_find_adt m "test::Error" []; | ||
let result_adt = mir_find_adt m "core::result::Result" [mir_u32, mir_adt error_adt]; | ||
|
||
let increment_spec = do { | ||
count <- mir_fresh_var "count" mir_u32; | ||
|
||
mir_execute_func [mir_term count]; | ||
|
||
let ok = mir_enum_value result_adt "Ok" [mir_term {{ count + 1 }}]; | ||
let err = mir_enum_value result_adt "Err" [mir_enum_value error_adt "Overflow" []]; | ||
let res = mir_mux_values {{ count < (2^^32 - 1) }} ok err; | ||
mir_return res; | ||
}; | ||
|
||
increment_ov <- mir_verify m "test::increment" [] false increment_spec z3; | ||
|
||
let f_spec = do { | ||
mir_execute_func []; | ||
|
||
mir_return (mir_enum_value result_adt "Ok" [mir_term {{ 1 : [32] }}]); | ||
}; | ||
|
||
let g_spec = do { | ||
mir_execute_func []; | ||
|
||
mir_return (mir_enum_value result_adt "Err" [mir_enum_value error_adt "Overflow" []]); | ||
}; | ||
|
||
mir_verify m "test::f" [increment_ov] false f_spec z3; | ||
mir_verify m "test::g" [increment_ov] false g_spec z3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set -e | ||
|
||
$SAW test.saw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.