2323#include " ir/intrinsics.h"
2424#include " pass.h"
2525#include " support/name.h"
26- #include " support/utilities.h"
2726#include " wasm-traversal.h"
2827#include " wasm-type.h"
2928#include " wasm.h"
@@ -44,7 +43,7 @@ class EffectAnalyzer {
4443 readsMutableArray(false ), writesArray(false ),
4544 readsSharedMutableArray(false ), writesSharedArray(false ), trap(false ),
4645 implicitTrap(false ), throws_(false ), danglingPop(false ),
47- mayNotReturn(false ), hasReturnCallThrow(false ), suspends_ (false ),
46+ mayNotReturn(false ), hasReturnCallThrow(false ), suspends (false ),
4847 module(module ), features(module .features) {}
4948
5049 EffectAnalyzer (const PassOptions& passOptions,
@@ -138,7 +137,7 @@ class EffectAnalyzer {
138137 // more here.)
139138 bool hasReturnCallThrow : 1 ;
140139
141- bool suspends_ : 1 ;
140+ bool suspends : 1 ;
142141
143142 const Module& module ;
144143 FeatureSet features;
@@ -230,7 +229,7 @@ class EffectAnalyzer {
230229 return calls || readsSharedMutableArray || writesSharedArray;
231230 }
232231 bool throws () const { return throws_ || !delegateTargets.empty (); }
233- bool suspends () const { return suspends_; }
232+
234233 // Check whether this may transfer control flow to somewhere outside of this
235234 // expression (aside from just flowing out normally). That includes a break,
236235 // a throw (if the throw is not known to be caught inside this expression;
@@ -240,25 +239,7 @@ class EffectAnalyzer {
240239 // transferred inside the function, but this expression does not know that),
241240 // or a suspension.
242241 bool transfersControlFlow () const {
243- return branchesOut || throws () || hasExternalBreakTargets () || suspends ();
244- }
245-
246- // Explicitly marks all global mutable state as clobbered (read and written).
247- void clobbersGlobalState () {
248- readsMemory = true ;
249- writesMemory = true ;
250- readsSharedMemory = true ;
251- writesSharedMemory = true ;
252- readsTable = true ;
253- writesTable = true ;
254- readsMutableStruct = true ;
255- writesStruct = true ;
256- readsSharedMutableStruct = true ;
257- writesSharedStruct = true ;
258- readsMutableArray = true ;
259- writesArray = true ;
260- readsSharedMutableArray = true ;
261- writesSharedArray = true ;
242+ return branchesOut || suspends || throws () || hasExternalBreakTargets ();
262243 }
263244
264245 // Changes something in globally-stored state.
@@ -286,7 +267,7 @@ class EffectAnalyzer {
286267 bool hasNonTrapSideEffects () const {
287268 return localsWritten.size () > 0 || danglingPop || writesGlobalState () ||
288269 throws () || transfersControlFlow () || hasSynchronization () ||
289- mayNotReturn || suspends () ;
270+ mayNotReturn;
290271 }
291272
292273 bool hasSideEffects () const { return trap || hasNonTrapSideEffects (); }
@@ -502,7 +483,7 @@ class EffectAnalyzer {
502483 danglingPop = danglingPop || other.danglingPop ;
503484 mayNotReturn = mayNotReturn || other.mayNotReturn ;
504485 hasReturnCallThrow = hasReturnCallThrow || other.hasReturnCallThrow ;
505- suspends_ = suspends_ || other.suspends_ ;
486+ suspends = suspends || other.suspends ;
506487 readOrder = std::max (readOrder, other.readOrder );
507488 writeOrder = std::max (writeOrder, other.writeOrder );
508489
@@ -1296,8 +1277,8 @@ class EffectAnalyzer {
12961277 void visitSuspend (Suspend* curr) {
12971278 // Suspending transfers control to an enclosing handler and executes
12981279 // arbitrary other code before we may resume here.
1299- parent.suspends_ = true ;
1300- parent.clobbersGlobalState () ;
1280+ parent.suspends = true ;
1281+ parent.calls = true ;
13011282 if (parent.features .hasExceptionHandling () && parent.tryDepth == 0 ) {
13021283 parent.throws_ = true ;
13031284 }
@@ -1397,7 +1378,7 @@ class EffectAnalyzer {
13971378 // If stack switching is enabled and we don't have global effects
13981379 // information, assume that the call target may suspend.
13991380 if (parent.features .hasStackSwitching ()) {
1400- parent.suspends_ = true ;
1381+ parent.suspends = true ;
14011382 }
14021383 }
14031384 };
@@ -1489,7 +1470,7 @@ class EffectAnalyzer {
14891470 if (danglingPop) {
14901471 effects |= SideEffects::DanglingPop;
14911472 }
1492- if (suspends_ ) {
1473+ if (suspends ) {
14931474 effects |= SideEffects::Suspends;
14941475 }
14951476 return effects;
@@ -1507,7 +1488,7 @@ class EffectAnalyzer {
15071488 breakTargets.clear ();
15081489 throws_ = false ;
15091490 delegateTargets.clear ();
1510- suspends_ = false ;
1491+ suspends = false ;
15111492 assert (!transfersControlFlow ());
15121493 }
15131494
0 commit comments