llvm.org GIT mirror llvm / 72cdd19
Revert "Define the ThinLTO Pipeline" This reverts commit r260604. I didn't intend to push this now. From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260606 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
2 changed file(s) with 1 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
132132 bool VerifyOutput;
133133 bool MergeFunctions;
134134 bool PrepareForLTO;
135 bool PrepareForThinLTO;
136 bool PerformThinLTO;
137135
138136 /// Profile data file name that the instrumentation will be written to.
139137 std::string PGOInstrGen;
171169 /// populateModulePassManager - This sets up the primary pass manager.
172170 void populateModulePassManager(legacy::PassManagerBase &MPM);
173171 void populateLTOPassManager(legacy::PassManagerBase &PM);
174 void populateThinLTOPassManager(legacy::PassManagerBase &PM);
175172 };
176173
177174 /// Registers a function for adding a standard set of passes. This should be
139139 PrepareForLTO = false;
140140 PGOInstrGen = RunPGOInstrGen;
141141 PGOInstrUse = RunPGOInstrUse;
142 PrepareForThinLTO = false;
143 PerformThinLTO = false;
144142 }
145143
146144 PassManagerBuilder::~PassManagerBuilder() {
234232 MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
235233 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
236234 MPM.add(createReassociatePass()); // Reassociate expressions
237 if (PrepareForThinLTO) {
238 MPM.add(createAggressiveDCEPass()); // Delete dead instructions
239 MPM.add(createInstructionCombiningPass()); // Combine silly seq's
240 return;
241 }
242235 // Rotate Loop - disable header duplication at -Oz
243236 MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
244237 MPM.add(createLICMPass()); // Hoist loop invariants
352345
353346 MPM.add(createIPSCCPPass()); // IP SCCP
354347 MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
355
356 if (PerformThinLTO)
357 // Linking modules together can lead to duplicated global constants, only
358 // keep one copy of each constant.
359 MPM.add(createConstantMergePass());
360
361348 // Promote any localized global vars
362349 MPM.add(createPromoteMemoryToRegisterPass());
363350
389376 MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
390377
391378 addFunctionSimplificationPasses(MPM);
392
393 // If we are planning to perform ThinLTO later, let's not bloat the code with
394 // unrolling/vectorization/... now. We'll first run the inliner + CGSCC passes
395 // during ThinLTO and performs the rest of the optimizations afterward.
396 if (PrepareForThinLTO)
397 return;
398379
399380 // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
400381 // pass manager that we are specifically trying to avoid. To prevent this
414395 if (!DisableUnitAtATime)
415396 MPM.add(createReversePostOrderFunctionAttrsPass());
416397
417 if (!DisableUnitAtATime && OptLevel > 1 && !PrepareForLTO)
398 if (!DisableUnitAtATime && OptLevel > 1 && !PrepareForLTO) {
418399 // Remove avail extern fns and globals definitions if we aren't
419400 // compiling an object file for later LTO. For LTO we want to preserve
420401 // these so they are eligible for inlining at link-time. Note if they
425406 // globals referenced by available external functions dead
426407 // and saves running remaining passes on the eliminated functions.
427408 MPM.add(createEliminateAvailableExternallyPass());
428
429 if (PerformThinLTO) {
430 // Remove dead fns and globals. Removing unreferenced functions could lead
431 // to more opportunities for globalopt
432 MPM.add(createGlobalDCEPass());
433 MPM.add(createGlobalOptimizerPass());
434 // Remove dead fns and globals after globalopt
435 MPM.add(createGlobalDCEPass());
436 addFunctionSimplificationPasses(MPM);
437409 }
438410
439411 if (EnableNonLTOGlobalsModRef)
709681 PM.add(createMergeFunctionsPass());
710682 }
711683
712 void PassManagerBuilder::populateThinLTOPassManager(
713 legacy::PassManagerBase &PM) {
714 PerformThinLTO = true;
715
716 if (VerifyInput)
717 PM.add(createVerifierPass());
718
719 populateModulePassManager(PM);
720
721 if (VerifyOutput)
722 PM.add(createVerifierPass());
723 PerformThinLTO = false;
724 }
725
726684 void PassManagerBuilder::populateLTOPassManager(legacy::PassManagerBase &PM) {
727685 if (LibraryInfo)
728686 PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));