diff options
author | Alon Zakai <azakai@google.com> | 2020-11-17 15:57:45 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 15:57:45 -0800 |
commit | 8cb7d3b341f4c907da9dfecc1054e5136f22c606 (patch) | |
tree | b65f97a4a9f04e0f938084f11a91d5e6f3e2a6d2 /src/passes/LoopInvariantCodeMotion.cpp | |
parent | 5d1642bd600b591145ae96d1916f85888c0f4dbf (diff) | |
download | binaryen-8cb7d3b341f4c907da9dfecc1054e5136f22c606.tar.gz binaryen-8cb7d3b341f4c907da9dfecc1054e5136f22c606.tar.bz2 binaryen-8cb7d3b341f4c907da9dfecc1054e5136f22c606.zip |
[effects.h] Refactor hasGlobalSideEffects and throw handling. (#3370)
The new writesGlobalState has a name that more clearly indicates what it
actually does: affect global state (that is, memory, globals, the table, etc.).
This removes throw from there, and handles it directly in the single caller
of the method, the licm pass. For simplicity, disallow exceptions in that
pass, leaving it for future work.
Diffstat (limited to 'src/passes/LoopInvariantCodeMotion.cpp')
-rw-r--r-- | src/passes/LoopInvariantCodeMotion.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/passes/LoopInvariantCodeMotion.cpp b/src/passes/LoopInvariantCodeMotion.cpp index 26e2a0844..a80e3a55d 100644 --- a/src/passes/LoopInvariantCodeMotion.cpp +++ b/src/passes/LoopInvariantCodeMotion.cpp @@ -114,17 +114,20 @@ struct LoopInvariantCodeMotion } if (interestingToMove(curr)) { // Let's see if we can move this out. - // Global side effects would prevent this - we might end up + // Global state changes would prevent this - we might end up // executing them just once. // And we must also move across anything not moved out already, // so check for issues there too. // The rest of the loop's effects matter too, we must also // take into account global state like interacting loads and // stores. - bool unsafeToMove = effects.hasGlobalSideEffects() || - effectsSoFar.invalidates(effects) || - (effects.noticesGlobalSideEffects() && - loopEffects.hasGlobalSideEffects()); + bool unsafeToMove = + effects.writesGlobalState() || effectsSoFar.invalidates(effects) || + (effects.readsGlobalState() && loopEffects.writesGlobalState()); + // TODO: look into optimizing this with exceptions. for now, disallow + if (effects.throws || loopEffects.throws) { + unsafeToMove = true; + } if (!unsafeToMove) { // So far so good. Check if our local dependencies are all // outside of the loop, in which case everything is good - |