@@ -224,11 +224,6 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
224
224
StandardInstrumentations SI (Conf.DebugPassManager );
225
225
SI.registerCallbacks (PIC);
226
226
PassBuilder PB (Conf.DebugPassManager , TM, Conf.PTO , PGOOpt, &PIC);
227
- AAManager AA;
228
-
229
- // Parse a custom AA pipeline if asked to.
230
- if (auto Err = PB.parseAAPipeline (AA, " default" ))
231
- report_fatal_error (" Error parsing default AA pipeline" );
232
227
233
228
RegisterPassPlugins (Conf.PassPlugins , PB);
234
229
@@ -243,6 +238,16 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
243
238
TLII->disableAllFunctions ();
244
239
FAM.registerPass ([&] { return TargetLibraryAnalysis (*TLII); });
245
240
241
+ AAManager AA;
242
+ // Parse a custom AA pipeline if asked to.
243
+ if (!Conf.AAPipeline .empty ()) {
244
+ if (auto Err = PB.parseAAPipeline (AA, Conf.AAPipeline )) {
245
+ report_fatal_error (" unable to parse AA pipeline description '" +
246
+ Conf.AAPipeline + " ': " + toString (std::move (Err)));
247
+ }
248
+ } else {
249
+ AA = PB.buildDefaultAAPipeline ();
250
+ }
246
251
// Register the AA manager first so that our version is the one used.
247
252
FAM.registerPass ([&] { return std::move (AA); });
248
253
@@ -277,66 +282,24 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
277
282
break ;
278
283
}
279
284
280
- if (IsThinLTO)
285
+ // Parse a custom pipeline if asked to.
286
+ if (!Conf.OptPipeline .empty ()) {
287
+ if (auto Err = PB.parsePassPipeline (MPM, Conf.OptPipeline )) {
288
+ report_fatal_error (" unable to parse pass pipeline description '" +
289
+ Conf.OptPipeline + " ': " + toString (std::move (Err)));
290
+ }
291
+ } else if (IsThinLTO) {
281
292
MPM.addPass (PB.buildThinLTODefaultPipeline (OL, ImportSummary));
282
- else
293
+ } else {
283
294
MPM.addPass (PB.buildLTODefaultPipeline (OL, ExportSummary));
295
+ }
284
296
285
297
if (!Conf.DisableVerify )
286
298
MPM.addPass (VerifierPass ());
287
299
288
300
MPM.run (Mod, MAM);
289
301
}
290
302
291
- static void runNewPMCustomPasses (const Config &Conf, Module &Mod,
292
- TargetMachine *TM) {
293
- PassBuilder PB (Conf.DebugPassManager , TM);
294
- AAManager AA;
295
-
296
- // Parse a custom AA pipeline if asked to.
297
- if (!Conf.AAPipeline .empty ())
298
- if (auto Err = PB.parseAAPipeline (AA, Conf.AAPipeline ))
299
- report_fatal_error (" unable to parse AA pipeline description '" +
300
- Conf.AAPipeline + " ': " + toString (std::move (Err)));
301
-
302
- RegisterPassPlugins (Conf.PassPlugins , PB);
303
-
304
- LoopAnalysisManager LAM;
305
- FunctionAnalysisManager FAM;
306
- CGSCCAnalysisManager CGAM;
307
- ModuleAnalysisManager MAM;
308
-
309
- std::unique_ptr<TargetLibraryInfoImpl> TLII (
310
- new TargetLibraryInfoImpl (Triple (TM->getTargetTriple ())));
311
- if (Conf.Freestanding )
312
- TLII->disableAllFunctions ();
313
- FAM.registerPass ([&] { return TargetLibraryAnalysis (*TLII); });
314
-
315
- // Register the AA manager first so that our version is the one used.
316
- FAM.registerPass ([&] { return std::move (AA); });
317
-
318
- // Register all the basic analyses with the managers.
319
- PB.registerModuleAnalyses (MAM);
320
- PB.registerCGSCCAnalyses (CGAM);
321
- PB.registerFunctionAnalyses (FAM);
322
- PB.registerLoopAnalyses (LAM);
323
- PB.crossRegisterProxies (LAM, FAM, CGAM, MAM);
324
-
325
- ModulePassManager MPM;
326
-
327
- // Always verify the input.
328
- MPM.addPass (VerifierPass ());
329
-
330
- // Now, add all the passes we've been requested to.
331
- if (auto Err = PB.parsePassPipeline (MPM, Conf.OptPipeline ))
332
- report_fatal_error (" unable to parse pass pipeline description '" +
333
- Conf.OptPipeline + " ': " + toString (std::move (Err)));
334
-
335
- if (!Conf.DisableVerify )
336
- MPM.addPass (VerifierPass ());
337
- MPM.run (Mod, MAM);
338
- }
339
-
340
303
static void runOldPMPasses (const Config &Conf, Module &Mod, TargetMachine *TM,
341
304
bool IsThinLTO, ModuleSummaryIndex *ExportSummary,
342
305
const ModuleSummaryIndex *ImportSummary) {
@@ -392,13 +355,12 @@ bool lto::opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
392
355
/* Cmdline*/ CmdArgs);
393
356
}
394
357
// FIXME: Plumb the combined index into the new pass manager.
395
- if (!Conf.OptPipeline .empty ())
396
- runNewPMCustomPasses (Conf, Mod, TM);
397
- else if (Conf.UseNewPM )
358
+ if (Conf.UseNewPM ) {
398
359
runNewPMPasses (Conf, Mod, TM, Conf.OptLevel , IsThinLTO, ExportSummary,
399
360
ImportSummary);
400
- else
361
+ } else {
401
362
runOldPMPasses (Conf, Mod, TM, IsThinLTO, ExportSummary, ImportSummary);
363
+ }
402
364
return !Conf.PostOptModuleHook || Conf.PostOptModuleHook (Task, Mod);
403
365
}
404
366
0 commit comments