llvm.org GIT mirror llvm / 3fa81fc
Revert "Refactor the PassManagerBuilder: extract a "addFunctionSimplificationPasses()"" This reverts commit r260603. I didn't intend to push it :( From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260607 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
2 changed file(s) with 74 addition(s) and 78 deletion(s). Raw diff Collapse all Expand all
159159 void addEarlyLTOOptimizationPasses(legacy::PassManagerBase &PM);
160160 void addLateLTOOptimizationPasses(legacy::PassManagerBase &PM);
161161 void addPGOInstrPasses(legacy::PassManagerBase &MPM);
162 void addFunctionSimplificationPasses(legacy::PassManagerBase &MPM);
162
163163 public:
164164 /// populateFunctionPassManager - This fills in the function pass manager,
165165 /// which is expected to be run on each function immediately as it is
214214 if (!PGOInstrUse.empty())
215215 MPM.add(createPGOInstrumentationUsePass(PGOInstrUse));
216216 }
217 void PassManagerBuilder::addFunctionSimplificationPasses(
218 legacy::PassManagerBase &MPM) {
217
218 void PassManagerBuilder::populateModulePassManager(
219 legacy::PassManagerBase &MPM) {
220 // Allow forcing function attributes as a debugging and tuning aid.
221 MPM.add(createForceFunctionAttrsLegacyPass());
222
223 // If all optimizations are disabled, just run the always-inline pass and,
224 // if enabled, the function merging pass.
225 if (OptLevel == 0) {
226 addPGOInstrPasses(MPM);
227 if (Inliner) {
228 MPM.add(Inliner);
229 Inliner = nullptr;
230 }
231
232 // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
233 // creates a CGSCC pass manager, but we don't want to add extensions into
234 // that pass manager. To prevent this we insert a no-op module pass to reset
235 // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
236 // builds. The function merging pass is
237 if (MergeFunctions)
238 MPM.add(createMergeFunctionsPass());
239 else if (!GlobalExtensions->empty() || !Extensions.empty())
240 MPM.add(createBarrierNoopPass());
241
242 addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
243 return;
244 }
245
246 // Add LibraryInfo if we have some.
247 if (LibraryInfo)
248 MPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
249
250 addInitialAliasAnalysisPasses(MPM);
251
252 if (!DisableUnitAtATime) {
253 // Infer attributes about declarations if possible.
254 MPM.add(createInferFunctionAttrsLegacyPass());
255
256 addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
257
258 MPM.add(createIPSCCPPass()); // IP SCCP
259 MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
260 // Promote any localized global vars
261 MPM.add(createPromoteMemoryToRegisterPass());
262
263 MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
264
265 MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
266 addExtensionsToPM(EP_Peephole, MPM);
267 MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
268 }
269
270 addPGOInstrPasses(MPM);
271
272 if (EnableNonLTOGlobalsModRef)
273 // We add a module alias analysis pass here. In part due to bugs in the
274 // analysis infrastructure this "works" in that the analysis stays alive
275 // for the entire SCC pass run below.
276 MPM.add(createGlobalsAAWrapperPass());
277
278 // Start of CallGraph SCC passes.
279 if (!DisableUnitAtATime)
280 MPM.add(createPruneEHPass()); // Remove dead EH info
281 if (Inliner) {
282 MPM.add(Inliner);
283 Inliner = nullptr;
284 }
285 if (!DisableUnitAtATime)
286 MPM.add(createPostOrderFunctionAttrsPass());
287 if (OptLevel > 2)
288 MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
289
219290 // Start of function pass.
220291 // Break up aggregate allocas, using SSAUpdater.
221292 if (UseNewSROA)
301372 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
302373 MPM.add(createInstructionCombiningPass()); // Clean up after everything.
303374 addExtensionsToPM(EP_Peephole, MPM);
304 }
305
306 void PassManagerBuilder::populateModulePassManager(
307 legacy::PassManagerBase &MPM) {
308 // Allow forcing function attributes as a debugging and tuning aid.
309 MPM.add(createForceFunctionAttrsLegacyPass());
310
311 // If all optimizations are disabled, just run the always-inline pass and,
312 // if enabled, the function merging pass.
313 if (OptLevel == 0) {
314 addPGOInstrPasses(MPM);
315 if (Inliner) {
316 MPM.add(Inliner);
317 Inliner = nullptr;
318 }
319
320 // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
321 // creates a CGSCC pass manager, but we don't want to add extensions into
322 // that pass manager. To prevent this we insert a no-op module pass to reset
323 // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
324 // builds. The function merging pass is
325 if (MergeFunctions)
326 MPM.add(createMergeFunctionsPass());
327 else if (!GlobalExtensions->empty() || !Extensions.empty())
328 MPM.add(createBarrierNoopPass());
329
330 addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
331 return;
332 }
333
334 // Add LibraryInfo if we have some.
335 if (LibraryInfo)
336 MPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
337
338 addInitialAliasAnalysisPasses(MPM);
339
340 if (!DisableUnitAtATime) {
341 // Infer attributes about declarations if possible.
342 MPM.add(createInferFunctionAttrsLegacyPass());
343
344 addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
345
346 MPM.add(createIPSCCPPass()); // IP SCCP
347 MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
348 // Promote any localized global vars
349 MPM.add(createPromoteMemoryToRegisterPass());
350
351 MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
352
353 MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
354 addExtensionsToPM(EP_Peephole, MPM);
355 MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
356 }
357
358 addPGOInstrPasses(MPM);
359
360 if (EnableNonLTOGlobalsModRef)
361 // We add a module alias analysis pass here. In part due to bugs in the
362 // analysis infrastructure this "works" in that the analysis stays alive
363 // for the entire SCC pass run below.
364 MPM.add(createGlobalsAAWrapperPass());
365
366 // Start of CallGraph SCC passes.
367 if (!DisableUnitAtATime)
368 MPM.add(createPruneEHPass()); // Remove dead EH info
369 if (Inliner) {
370 MPM.add(Inliner);
371 Inliner = nullptr;
372 }
373 if (!DisableUnitAtATime)
374 MPM.add(createPostOrderFunctionAttrsPass());
375 if (OptLevel > 2)
376 MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
377
378 addFunctionSimplificationPasses(MPM);
379375
380376 // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
381377 // pass manager that we are specifically trying to avoid. To prevent this