55
55
56
56
#define DEBUG_TYPE " access-enforcement-wmo"
57
57
58
+ #include " swift/Basic/SmallPtrSetVector.h"
58
59
#include " swift/SIL/DebugUtils.h"
59
60
#include " swift/SIL/MemAccessUtils.h"
60
61
#include " swift/SIL/SILFunction.h"
@@ -143,6 +144,7 @@ namespace {
143
144
// checks).
144
145
class GlobalAccessRemoval {
145
146
SILModule &module ;
147
+ SmallPtrSetVector<SILFunction *, 8 > changedFunctions;
146
148
147
149
using BeginAccessSet = SmallDenseSet<BeginAccessInst *, 8 >;
148
150
@@ -162,6 +164,8 @@ class GlobalAccessRemoval {
162
164
GlobalAccessRemoval (SILModule &module ) : module (module ) {}
163
165
164
166
void perform ();
167
+
168
+ void invalidateAnalysis (SILModuleTransform *pass);
165
169
166
170
protected:
167
171
bool visitInstruction (SILInstruction *I);
@@ -189,6 +193,13 @@ void GlobalAccessRemoval::perform() {
189
193
removeNonreentrantAccess ();
190
194
}
191
195
196
+ void GlobalAccessRemoval::invalidateAnalysis (SILModuleTransform *pass) {
197
+ for (SILFunction *changedFunction : changedFunctions) {
198
+ pass->invalidateAnalysis (changedFunction,
199
+ SILAnalysis::InvalidationKind::Instructions);
200
+ }
201
+ }
202
+
192
203
bool GlobalAccessRemoval::visitInstruction (SILInstruction *I) {
193
204
if (auto *BAI = dyn_cast<BeginAccessInst>(I)) {
194
205
auto storageAndBase = AccessStorageWithBase::compute (BAI->getSource ());
@@ -292,6 +303,7 @@ void GlobalAccessRemoval::removeNonreentrantAccess() {
292
303
for (BeginAccessInst *beginAccess : info.beginAccessSet ) {
293
304
LLVM_DEBUG (llvm::dbgs () << " Disabling access marker " << *beginAccess);
294
305
beginAccess->setEnforcement (SILAccessEnforcement::Static);
306
+ changedFunctions.insert (beginAccess->getFunction ());
295
307
}
296
308
}
297
309
}
@@ -301,6 +313,7 @@ struct AccessEnforcementWMO : public SILModuleTransform {
301
313
void run () override {
302
314
GlobalAccessRemoval eliminationPass (*getModule ());
303
315
eliminationPass.perform ();
316
+ eliminationPass.invalidateAnalysis (this );
304
317
}
305
318
};
306
319
}
0 commit comments