Skip to content

Commit 5c4c12a

Browse files
committed
IRGen: Switch pass managers based on LegacyPassManager IRGenOptions flag
1 parent d24eff9 commit 5c4c12a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ void setModuleFlags(IRGenModule &IGM) {
216216
}
217217
}
218218

219-
void swift::performLLVMOptimizations(const IRGenOptions &Opts,
220-
llvm::Module *Module,
221-
llvm::TargetMachine *TargetMachine) {
219+
static void
220+
performOptimizationsUsingLegacyPassManger(const IRGenOptions &Opts,
221+
llvm::Module *Module,
222+
llvm::TargetMachine *TargetMachine) {
222223
// Set up a pipeline.
223224
PassManagerBuilderWrapper PMBuilder(Opts);
224225

@@ -389,6 +390,20 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
389390
}
390391
}
391392

393+
static void
394+
performOptimizationsUsingNewPassManger(const IRGenOptions &Opts,
395+
llvm::Module *Module,
396+
llvm::TargetMachine *TargetMachine) {}
397+
398+
void swift::performLLVMOptimizations(const IRGenOptions &Opts,
399+
llvm::Module *Module,
400+
llvm::TargetMachine *TargetMachine) {
401+
if (Opts.LegacyPassManager)
402+
performOptimizationsUsingLegacyPassManger(Opts, Module, TargetMachine);
403+
else
404+
performOptimizationsUsingNewPassManger(Opts, Module, TargetMachine);
405+
}
406+
392407
/// Computes the MD5 hash of the llvm \p Module including the compiler version
393408
/// and options which influence the compilation.
394409
static MD5::MD5Result getHashOfModule(const IRGenOptions &Opts,

0 commit comments

Comments
 (0)