@@ -107,8 +107,6 @@ enum class SILStage {
107
107
// / when a Swift compilation context is lowered to SIL.
108
108
class SILModule {
109
109
friend class SILFunctionBuilder ;
110
- friend class SILGenSourceFileRequest ;
111
- friend class SILGenWholeModuleRequest ;
112
110
113
111
public:
114
112
using FunctionListType = llvm::ilist<SILFunction>;
@@ -262,10 +260,6 @@ class SILModule {
262
260
// / The indexed profile data to be used for PGO, or nullptr.
263
261
std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader;
264
262
265
- // / True if this SILModule really contains the whole module, i.e.
266
- // / optimizations can assume that they see the whole module.
267
- bool wholeModule;
268
-
269
263
// / The options passed into this SILModule.
270
264
const SILOptions &Options;
271
265
@@ -280,11 +274,8 @@ class SILModule {
280
274
// / invalidation message is sent.
281
275
llvm::SetVector<DeleteNotificationHandler*> NotificationHandlers;
282
276
283
- // Intentionally marked private so that we need to use 'constructSIL()'
284
- // to construct a SILModule.
285
- SILModule (ModuleDecl *M, Lowering::TypeConverter &TC,
286
- const SILOptions &Options, const DeclContext *associatedDC,
287
- bool wholeModule);
277
+ SILModule (llvm::PointerUnion<FileUnit *, ModuleDecl *> context,
278
+ Lowering::TypeConverter &TC, const SILOptions &Options);
288
279
289
280
SILModule (const SILModule&) = delete ;
290
281
void operator =(const SILModule&) = delete ;
@@ -355,47 +346,38 @@ class SILModule {
355
346
// / Erase a global SIL variable from the module.
356
347
void eraseGlobalVariable (SILGlobalVariable *G);
357
348
358
- // / Construct a SIL module from an AST module.
359
- // /
360
- // / The module will be constructed in the Raw stage. The provided AST module
361
- // / should contain source files.
349
+ // / Create and return an empty SIL module suitable for generating or parsing
350
+ // / SIL into.
362
351
// /
363
- // / If a source file is provided, SIL will only be emitted for decls in that
364
- // / source file.
365
- static std::unique_ptr<SILModule>
366
- constructSIL (ModuleDecl *M, Lowering::TypeConverter &TC,
367
- const SILOptions &Options, FileUnit *sf = nullptr );
368
-
369
- // / Create and return an empty SIL module that we can
370
- // / later parse SIL bodies directly into, without converting from an AST.
352
+ // / \param context The associated decl context. This should be a FileUnit in
353
+ // / single-file mode, and a ModuleDecl in whole-module mode.
371
354
static std::unique_ptr<SILModule>
372
- createEmptyModule (ModuleDecl *M, Lowering::TypeConverter &TC,
373
- const SILOptions &Options,
374
- bool WholeModule = false );
355
+ createEmptyModule (llvm::PointerUnion<FileUnit *, ModuleDecl *> context,
356
+ Lowering::TypeConverter &TC, const SILOptions &Options);
375
357
376
358
// / Get the Swift module associated with this SIL module.
377
359
ModuleDecl *getSwiftModule () const { return TheSwiftModule; }
378
360
// / Get the AST context used for type uniquing etc. by this SIL module.
379
361
ASTContext &getASTContext () const ;
380
362
SourceManager &getSourceManager () const { return getASTContext ().SourceMgr ; }
381
363
382
- // / Get the Swift DeclContext associated with this SIL module.
364
+ // / Get the Swift DeclContext associated with this SIL module. This is never
365
+ // / null.
383
366
// /
384
367
// / All AST declarations within this context are assumed to have been fully
385
368
// / processed as part of generating this module. This allows certain passes
386
369
// / to make additional assumptions about these declarations.
387
370
// /
388
371
// / If this is the same as TheSwiftModule, the entire module is being
389
- // / compiled as a single unit. If this is null, no context-based assumptions
390
- // / can be made.
372
+ // / compiled as a single unit.
391
373
const DeclContext *getAssociatedContext () const {
392
374
return AssociatedDeclContext;
393
375
}
394
376
395
377
// / Returns true if this SILModule really contains the whole module, i.e.
396
378
// / optimizations can assume that they see the whole module.
397
379
bool isWholeModule () const {
398
- return wholeModule ;
380
+ return isa<ModuleDecl>(AssociatedDeclContext) ;
399
381
}
400
382
401
383
bool isStdlibModule () const ;
0 commit comments