diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-28 16:24:20 +1100 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-28 16:24:20 +1100 |
commit | 5c64edfd50b334022f0a0ca5414287a9dd8aa3c2 (patch) | |
tree | 711b9841ce04b3b76559c54b598c299818384f0e | |
parent | f057e423c91a7ab821b68e7ec04f3280c24a1ffc (diff) | |
download | mrust-5c64edfd50b334022f0a0ca5414287a9dd8aa3c2.tar.gz |
MIR Gen - Handle diverging calls fully
-rw-r--r-- | src/main.cpp | 6 | ||||
-rw-r--r-- | src/mir/check.cpp | 2 | ||||
-rw-r--r-- | src/mir/from_hir.cpp | 6 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index 87bb3f3e..5acb8545 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -392,9 +392,9 @@ int main(int argc, char *argv[]) }); // Validate the MIR - //CompilePhaseV("MIR Validate", [&]() { - // MIR_CheckCrate(*hir_crate); - // }); + CompilePhaseV("MIR Validate", [&]() { + MIR_CheckCrate(*hir_crate); + }); // Second shot of constant evaluation (with full type information) CompilePhaseV("Constant Evaluate Full", [&]() { diff --git a/src/mir/check.cpp b/src/mir/check.cpp index ffcc4523..0c428c64 100644 --- a/src/mir/check.cpp +++ b/src/mir/check.cpp @@ -380,6 +380,8 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path val_state.ensure_valid( state, arg ); // Push blocks (with return valid only in one) add_to_visit(e.panic_block, val_state); + + // TODO: If the function returns !, don't follow the ret_block val_state.mark_validity( state, e.ret_val, true ); add_to_visit(e.ret_block, mv$(val_state)); ) diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index 3e41feeb..b5e42d31 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -1503,6 +1503,12 @@ namespace { unconditional_diverge = true; } } + else + { + // TODO: Know if the call unconditionally diverges. + if( node.m_cache.m_arg_types.back().m_data.is_Diverge() ) + unconditional_diverge = true; + } // If the call wasn't to an intrinsic, emit it as a path if( m_builder.block_active() ) |