summaryrefslogtreecommitdiff
path: root/src/mir/optimise.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir/optimise.cpp')
-rw-r--r--src/mir/optimise.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mir/optimise.cpp b/src/mir/optimise.cpp
index dc3967b4..6601c03b 100644
--- a/src/mir/optimise.cpp
+++ b/src/mir/optimise.cpp
@@ -574,11 +574,16 @@ void MIR_Optimise(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path
// >> Unify duplicate temporaries
// If two temporaries don't overlap in lifetime (blocks in which they're valid), unify the two
- // TODO: Only run this when nothing else happened. (It's VERY expensive)
- change_happened |= MIR_Optimise_UnifyTemporaries(state, fcn);
- #if CHECK_AFTER_ALL
- MIR_Validate(resolve, path, fcn, args, ret_type);
- #endif
+ // Only run this when nothing else happened. (It's VERY expensive)
+#if 1
+ if( !change_happened )
+ {
+ change_happened |= MIR_Optimise_UnifyTemporaries(state, fcn);
+# if CHECK_AFTER_ALL
+ MIR_Validate(resolve, path, fcn, args, ret_type);
+# endif
+ }
+#endif
// >> Combine Duplicate Blocks
change_happened |= MIR_Optimise_UnifyBlocks(state, fcn);
@@ -1254,7 +1259,8 @@ bool MIR_Optimise_UnifyTemporaries(::MIR::TypeResolve& state, ::MIR::Function& f
return false;
}
- auto lifetimes = MIR_Helper_GetLifetimes(state, fcn, /*dump_debug=*/true);
+ // TODO: Only calculate lifetimes for replacable locals
+ auto lifetimes = MIR_Helper_GetLifetimes(state, fcn, /*dump_debug=*/true, /*mask=*/&replacable);
::std::vector<::MIR::ValueLifetime> slot_lifetimes = mv$(lifetimes.m_slots);
// 2. Unify variables of the same type with distinct non-overlapping lifetimes