PassManagerBuilder.cpp revision c8dc96be28fd1a3d6ddebbb48b8d55b61e4bd89b
1c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola//===- PassManagerBuilder.cpp - Build Standard Pass -----------------------===// 2c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// 3c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// The LLVM Compiler Infrastructure 4c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// 5c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// This file is distributed under the University of Illinois Open Source 6c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// License. See LICENSE.TXT for details. 7c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// 8c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola//===----------------------------------------------------------------------===// 9c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// 10c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// This file defines the PassManagerBuilder class, which is used to set up a 11c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// "standard" optimization sequence suitable for languages like C and C++. 12c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola// 13c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola//===----------------------------------------------------------------------===// 14c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 15c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 16c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola#include "llvm/Transforms/IPO/PassManagerBuilder.h" 1769cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola#include "llvm-c/Transforms/PassManagerBuilder.h" 18d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruth#include "llvm/ADT/SmallVector.h" 19c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola#include "llvm/Analysis/Passes.h" 20de5e5ec3045a73a06b1054417f9ac6c02929e9ceHal Finkel#include "llvm/Analysis/Verifier.h" 21d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruth#include "llvm/PassManager.h" 22de5e5ec3045a73a06b1054417f9ac6c02929e9ceHal Finkel#include "llvm/Support/CommandLine.h" 23d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruth#include "llvm/Support/ManagedStatic.h" 24c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola#include "llvm/Target/TargetLibraryInfo.h" 25d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruth#include "llvm/Transforms/IPO.h" 26c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola#include "llvm/Transforms/Scalar.h" 27de5e5ec3045a73a06b1054417f9ac6c02929e9ceHal Finkel#include "llvm/Transforms/Vectorize.h" 28c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 29c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindolausing namespace llvm; 30c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 31de5e5ec3045a73a06b1054417f9ac6c02929e9ceHal Finkelstatic cl::opt<bool> 32fe16848601bdde6e3a5e0860199169dd171222a4Nadav RotemRunLoopVectorization("vectorize-loops", cl::Hidden, 339210cc3a173224b40d9fc45b202f52cc7acf5c5aNadav Rotem cl::desc("Run the Loop vectorization passes")); 34d233b78760e481a9602266f8376eb1189c58bc9aNadav Rotem 35d233b78760e481a9602266f8376eb1189c58bc9aNadav Rotemstatic cl::opt<bool> 367b15c0afc1403c451e32d6ae4ecc43a83af496beNadav RotemLateVectorization("late-vectorize", cl::init(true), cl::Hidden, 376bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth cl::desc("Run the vectorization pasess late in the pass " 386bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth "pipeline (after the inliner)")); 396bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth 406bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruthstatic cl::opt<bool> 41fe16848601bdde6e3a5e0860199169dd171222a4Nadav RotemRunSLPVectorization("vectorize-slp", cl::Hidden, 421129a832e6ef5291b0144e9f22c76b2599cd5587Nadav Rotem cl::desc("Run the SLP vectorization passes")); 431129a832e6ef5291b0144e9f22c76b2599cd5587Nadav Rotem 441129a832e6ef5291b0144e9f22c76b2599cd5587Nadav Rotemstatic cl::opt<bool> 45fe16848601bdde6e3a5e0860199169dd171222a4Nadav RotemRunBBVectorization("vectorize-slp-aggressive", cl::Hidden, 461129a832e6ef5291b0144e9f22c76b2599cd5587Nadav Rotem cl::desc("Run the BB vectorization passes")); 47de5e5ec3045a73a06b1054417f9ac6c02929e9ceHal Finkel 48064551e94c9763c7e74121b88f9cbccc0969946aHal Finkelstatic cl::opt<bool> 49064551e94c9763c7e74121b88f9cbccc0969946aHal FinkelUseGVNAfterVectorization("use-gvn-after-vectorization", 50064551e94c9763c7e74121b88f9cbccc0969946aHal Finkel cl::init(false), cl::Hidden, 51064551e94c9763c7e74121b88f9cbccc0969946aHal Finkel cl::desc("Run GVN instead of Early CSE after vectorization passes")); 52064551e94c9763c7e74121b88f9cbccc0969946aHal Finkel 53713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruthstatic cl::opt<bool> UseNewSROA("use-new-sroa", 541fe4fae463eba5965aa1f98600161ef7de96aaf1Chandler Carruth cl::init(true), cl::Hidden, 55713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth cl::desc("Enable the new, experimental SROA pass")); 56713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth 57bebe48dbfe00078329341945bfb11f778ace6d12Hal Finkelstatic cl::opt<bool> 58bebe48dbfe00078329341945bfb11f778ace6d12Hal FinkelRunLoopRerolling("reroll-loops", cl::Hidden, 59bebe48dbfe00078329341945bfb11f778ace6d12Hal Finkel cl::desc("Run the loop rerolling pass")); 60bebe48dbfe00078329341945bfb11f778ace6d12Hal Finkel 61c684e83e4554bfaf6180426f86b9253b65dd46ecRafael EspindolaPassManagerBuilder::PassManagerBuilder() { 62c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola OptLevel = 2; 63c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola SizeLevel = 0; 64c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola LibraryInfo = 0; 65c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola Inliner = 0; 66c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola DisableUnitAtATime = false; 67c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola DisableUnrollLoops = false; 681129a832e6ef5291b0144e9f22c76b2599cd5587Nadav Rotem BBVectorize = RunBBVectorization; 698849838965941919257b923f8603ca1bacd3fa46Nadav Rotem SLPVectorize = RunSLPVectorization; 70d233b78760e481a9602266f8376eb1189c58bc9aNadav Rotem LoopVectorize = RunLoopVectorization; 716bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth LateVectorize = LateVectorization; 72c8dc96be28fd1a3d6ddebbb48b8d55b61e4bd89bHal Finkel RerollLoops = RunLoopRerolling; 73c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola} 74c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 75c684e83e4554bfaf6180426f86b9253b65dd46ecRafael EspindolaPassManagerBuilder::~PassManagerBuilder() { 76c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola delete LibraryInfo; 77c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola delete Inliner; 78c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola} 79c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 807a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall/// Set of global extensions, automatically added as part of the standard set. 817a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnallstatic ManagedStatic<SmallVector<std::pair<PassManagerBuilder::ExtensionPointTy, 827a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall PassManagerBuilder::ExtensionFn>, 8> > GlobalExtensions; 837a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall 847a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnallvoid PassManagerBuilder::addGlobalExtension( 857a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall PassManagerBuilder::ExtensionPointTy Ty, 867a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall PassManagerBuilder::ExtensionFn Fn) { 877a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall GlobalExtensions->push_back(std::make_pair(Ty, Fn)); 887a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall} 897a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall 90c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindolavoid PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) { 91c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola Extensions.push_back(std::make_pair(Ty, Fn)); 92c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola} 93c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 94c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindolavoid PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy, 95c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PassManagerBase &PM) const { 967a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i) 977a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall if ((*GlobalExtensions)[i].first == ETy) 987a817eae6cb00a2ba5ec2a4127775b839a357e4cDavid Chisnall (*GlobalExtensions)[i].second(*this, PM); 99c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola for (unsigned i = 0, e = Extensions.size(); i != e; ++i) 100c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (Extensions[i].first == ETy) 101c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola Extensions[i].second(*this, PM); 102c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola} 103c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 104c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindolavoid 105c684e83e4554bfaf6180426f86b9253b65dd46ecRafael EspindolaPassManagerBuilder::addInitialAliasAnalysisPasses(PassManagerBase &PM) const { 106c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that 107c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // BasicAliasAnalysis wins if they disagree. This is intended to help 108c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // support "obvious" type-punning idioms. 109c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createTypeBasedAliasAnalysisPass()); 110c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createBasicAliasAnalysisPass()); 111c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola} 112c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 113c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindolavoid PassManagerBuilder::populateFunctionPassManager(FunctionPassManager &FPM) { 114c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola addExtensionsToPM(EP_EarlyAsPossible, FPM); 115c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 116c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Add LibraryInfo if we have some. 117c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (LibraryInfo) FPM.add(new TargetLibraryInfo(*LibraryInfo)); 118c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 119c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (OptLevel == 0) return; 120c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 121c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola addInitialAliasAnalysisPasses(FPM); 122c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 123c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola FPM.add(createCFGSimplificationPass()); 124713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth if (UseNewSROA) 125713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth FPM.add(createSROAPass()); 126713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth else 127713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth FPM.add(createScalarReplAggregatesPass()); 128c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola FPM.add(createEarlyCSEPass()); 129c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola FPM.add(createLowerExpectIntrinsicPass()); 130c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola} 131c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 132c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindolavoid PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) { 133c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // If all optimizations are disabled, just run the always-inline pass. 134c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (OptLevel == 0) { 135c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (Inliner) { 136c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(Inliner); 137c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola Inliner = 0; 138c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola } 13963a1eb62e4eef1cbdedce5c60c3e1243a071eba1Chandler Carruth 14063a1eb62e4eef1cbdedce5c60c3e1243a071eba1Chandler Carruth // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC 14163a1eb62e4eef1cbdedce5c60c3e1243a071eba1Chandler Carruth // pass manager, but we don't want to add extensions into that pass manager. 14263a1eb62e4eef1cbdedce5c60c3e1243a071eba1Chandler Carruth // To prevent this we must insert a no-op module pass to reset the pass 14363a1eb62e4eef1cbdedce5c60c3e1243a071eba1Chandler Carruth // manager to get the same behavior as EP_OptimizerLast in non-O0 builds. 14463a1eb62e4eef1cbdedce5c60c3e1243a071eba1Chandler Carruth if (!GlobalExtensions->empty() || !Extensions.empty()) 14563a1eb62e4eef1cbdedce5c60c3e1243a071eba1Chandler Carruth MPM.add(createBarrierNoopPass()); 14663a1eb62e4eef1cbdedce5c60c3e1243a071eba1Chandler Carruth 147af65a8c54b66e9a78e2c7a9a810a33a73fb7f63aKostya Serebryany addExtensionsToPM(EP_EnabledOnOptLevel0, MPM); 148c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola return; 149c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola } 150c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 151c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Add LibraryInfo if we have some. 152c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (LibraryInfo) MPM.add(new TargetLibraryInfo(*LibraryInfo)); 153c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 154c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola addInitialAliasAnalysisPasses(MPM); 155c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 156c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (!DisableUnitAtATime) { 1577d4c87ef6eea424b7a28392ea11137ed77b44b57Dan Gohman addExtensionsToPM(EP_ModuleOptimizerEarly, MPM); 1587d4c87ef6eea424b7a28392ea11137ed77b44b57Dan Gohman 159c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createGlobalOptimizerPass()); // Optimize out global vars 160c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 161c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createIPSCCPPass()); // IP SCCP 162c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createDeadArgEliminationPass()); // Dead argument elimination 163c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 164c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE 165c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE 166c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola } 167c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 168c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Start of CallGraph SCC passes. 169c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (!DisableUnitAtATime) 170c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createPruneEHPass()); // Remove dead EH info 171c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (Inliner) { 172c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(Inliner); 173c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola Inliner = 0; 174c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola } 175c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (!DisableUnitAtATime) 176c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs 177c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (OptLevel > 2) 178c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args 179c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 180c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Start of function pass. 181c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Break up aggregate allocas, using SSAUpdater. 1821c8db50a9aca4229ebee75ed9cfbf8b222292787Chandler Carruth if (UseNewSROA) 1831c8db50a9aca4229ebee75ed9cfbf8b222292787Chandler Carruth MPM.add(createSROAPass(/*RequiresDomTree*/ false)); 1841c8db50a9aca4229ebee75ed9cfbf8b222292787Chandler Carruth else 1851c8db50a9aca4229ebee75ed9cfbf8b222292787Chandler Carruth MPM.add(createScalarReplAggregatesPass(-1, false)); 186c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createEarlyCSEPass()); // Catch trivial redundancies 187c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createJumpThreadingPass()); // Thread jumps. 188c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals 189c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createCFGSimplificationPass()); // Merge & remove BBs 190c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createInstructionCombiningPass()); // Combine silly seq's 191c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 192c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createTailCallEliminationPass()); // Eliminate tail calls 193c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createCFGSimplificationPass()); // Merge & remove BBs 194c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createReassociatePass()); // Reassociate expressions 195c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createLoopRotatePass()); // Rotate Loop 196c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createLICMPass()); // Hoist loop invariants 197c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3)); 198c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createInstructionCombiningPass()); 199c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars 200c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createLoopIdiomPass()); // Recognize idioms like memset. 201c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createLoopDeletionPass()); // Delete dead loops 202d15c0c7ac118cb23241b002e7206221283e36e2dNadav Rotem 203b6171c529670e5c240aaf9c08f5f1b6dba9d16fcArnold Schwaighofer if (!LateVectorize && LoopVectorize) 204435798e96a64738b55a01055dde1bc9a88a15191Hal Finkel MPM.add(createLoopVectorizePass(DisableUnrollLoops)); 205d15c0c7ac118cb23241b002e7206221283e36e2dNadav Rotem 206c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (!DisableUnrollLoops) 207c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createLoopUnrollPass()); // Unroll small loops 208c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola addExtensionsToPM(EP_LoopOptimizerEnd, MPM); 209c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 210c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (OptLevel > 1) 211c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createGVNPass()); // Remove redundancies 212c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset 213c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createSCCPPass()); // Constant prop with SCCP 214c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 215c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Run instcombine after redundancy elimination to exploit opportunities 216c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // opened up by them. 217c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createInstructionCombiningPass()); 218c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createJumpThreadingPass()); // Thread jumps 219c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createCorrelatedValuePropagationPass()); 220c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createDeadStoreEliminationPass()); // Delete dead stores 221c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 222c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola addExtensionsToPM(EP_ScalarOptimizerLate, MPM); 223c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 224c8dc96be28fd1a3d6ddebbb48b8d55b61e4bd89bHal Finkel if (RerollLoops) 225bebe48dbfe00078329341945bfb11f778ace6d12Hal Finkel MPM.add(createLoopRerollPass()); 226f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem if (SLPVectorize) 227f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains. 228f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem 229f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem if (BBVectorize) { 230f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createBBVectorizePass()); 231f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createInstructionCombiningPass()); 232f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem if (OptLevel > 1 && UseGVNAfterVectorization) 233f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createGVNPass()); // Remove redundancies 234f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem else 235f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createEarlyCSEPass()); // Catch trivial redundancies 236f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem 237f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem // BBVectorize may have significantly shortened a loop body; unroll again. 238f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem if (!DisableUnrollLoops) 239f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createLoopUnrollPass()); 240de5e5ec3045a73a06b1054417f9ac6c02929e9ceHal Finkel } 241de5e5ec3045a73a06b1054417f9ac6c02929e9ceHal Finkel 242c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createAggressiveDCEPass()); // Delete dead instructions 24301d7203ef8316fdd71c3cec59f8e68fb869e0dbfTom Stellard MPM.add(createCFGSimplificationPass()); // Merge & remove BBs 244c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createInstructionCombiningPass()); // Clean up after everything. 245c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 2466bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth // As an experimental mode, run any vectorization passes in a separate 2476bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth // pipeline from the CGSCC pass manager that runs iteratively with the 2486bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth // inliner. 249f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem if (LateVectorize && LoopVectorize) { 2506bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC 2516bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth // pass manager that we are specifically trying to avoid. To prevent this 2526bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth // we must insert a no-op module pass to reset the pass manager. 2536bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth MPM.add(createBarrierNoopPass()); 2546bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth 2556bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth // Add the various vectorization passes and relevant cleanup passes for 2566bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth // them since we are no longer in the middle of the main scalar pipeline. 257f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createLoopVectorizePass(DisableUnrollLoops)); 258f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createInstructionCombiningPass()); 259f1cd7983b195b2ab9c106c88b4da82983fe63f92Nadav Rotem MPM.add(createCFGSimplificationPass()); 2606bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth } 2616bf3a05235effa06b10196ee9ebeffee14d886eeChandler Carruth 262c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (!DisableUnitAtATime) { 263c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // FIXME: We shouldn't bother with this anymore. 264c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes 265c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 266f5fdc14df9914969bf56315cd3be8a3b3822a22eEvan Cheng // GlobalOpt already deletes dead functions and globals, at -O2 try a 267c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // late pass of GlobalDCE. It is capable of deleting dead cycles. 268f5fdc14df9914969bf56315cd3be8a3b3822a22eEvan Cheng if (OptLevel > 1) { 269c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createGlobalDCEPass()); // Remove dead fns and globals. 270c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola MPM.add(createConstantMergePass()); // Merge dup global constants 271f5fdc14df9914969bf56315cd3be8a3b3822a22eEvan Cheng } 272c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola } 2731db394921b9635980555cc8d7e0d05b5e885784fKostya Serebryany addExtensionsToPM(EP_OptimizerLast, MPM); 274c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola} 275c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 276c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindolavoid PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM, 277c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola bool Internalize, 2783197b4453d214aa96de3a42da8f8fe189fff2077Bill Wendling bool RunInliner, 2793197b4453d214aa96de3a42da8f8fe189fff2077Bill Wendling bool DisableGVNLoadPRE) { 280c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Provide AliasAnalysis services for optimizations. 281c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola addInitialAliasAnalysisPasses(PM); 282c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 283c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Now that composite has been compiled, scan through the module, looking 284c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // for a main function. If main is defined, mark all other functions 285c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // internal. 2866e4d93b2325b268d5394b82201c1a782cca78faeBill Wendling if (Internalize) 2877e667c56cf7e27ff521ceb86518beab32bfb630dRafael Espindola PM.add(createInternalizePass("main")); 288c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 289c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Propagate constants at call sites into the functions they call. This 290c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // opens opportunities for globalopt (and inlining) by substituting function 291c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // pointers passed as arguments to direct uses of functions. 292c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createIPSCCPPass()); 293c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 294c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Now that we internalized some globals, see if we can hack on them! 295c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createGlobalOptimizerPass()); 296c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 297c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Linking modules together can lead to duplicated global constants, only 298c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // keep one copy of each constant. 299c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createConstantMergePass()); 300c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 301c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Remove unused arguments from functions. 302c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createDeadArgEliminationPass()); 303c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 304c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Reduce the code after globalopt and ipsccp. Both can open up significant 305c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // simplification opportunities, and both can propagate functions through 306c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // function pointers. When this happens, we often have to resolve varargs 307c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // calls, etc, so let instcombine do this. 308c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createInstructionCombiningPass()); 309c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 310c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Inline small functions 311c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (RunInliner) 312c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createFunctionInliningPass()); 313c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 314c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createPruneEHPass()); // Remove dead EH info. 315c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 316c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Optimize globals again if we ran the inliner. 317c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola if (RunInliner) 318c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createGlobalOptimizerPass()); 319c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createGlobalDCEPass()); // Remove dead functions. 320c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 321c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // If we didn't decide to inline a function, check to see if we can 322c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // transform it to pass arguments by value instead of by reference. 323c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createArgumentPromotionPass()); 324c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 325c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // The IPO passes may leave cruft around. Clean up after them. 326c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createInstructionCombiningPass()); 327c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createJumpThreadingPass()); 3286e4d93b2325b268d5394b82201c1a782cca78faeBill Wendling 329c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Break up allocas 330713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth if (UseNewSROA) 331713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth PM.add(createSROAPass()); 332713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth else 333713aa9431d84805c5b7ddce57159d14ee94cd548Chandler Carruth PM.add(createScalarReplAggregatesPass()); 334c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 335c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Run a few AA driven optimizations here and now, to cleanup the code. 336c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createFunctionAttrsPass()); // Add nocapture. 337c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createGlobalsModRefPass()); // IP alias analysis. 338c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 3393197b4453d214aa96de3a42da8f8fe189fff2077Bill Wendling PM.add(createLICMPass()); // Hoist loop invariants. 3403197b4453d214aa96de3a42da8f8fe189fff2077Bill Wendling PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies. 3413197b4453d214aa96de3a42da8f8fe189fff2077Bill Wendling PM.add(createMemCpyOptPass()); // Remove dead memcpys. 3426e4d93b2325b268d5394b82201c1a782cca78faeBill Wendling 343c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Nuke dead stores. 344c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createDeadStoreEliminationPass()); 345c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 346c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Cleanup and simplify the code after the scalar optimizations. 347c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createInstructionCombiningPass()); 348c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 349c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createJumpThreadingPass()); 350c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 351c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Delete basic blocks, which optimization passes may have killed. 35201d7203ef8316fdd71c3cec59f8e68fb869e0dbfTom Stellard PM.add(createCFGSimplificationPass()); 353c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola 354c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola // Now that we have optimized the program, discard unreachable functions. 355c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola PM.add(createGlobalDCEPass()); 356c684e83e4554bfaf6180426f86b9253b65dd46ecRafael Espindola} 35769cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 3583e39731e88f2d4f597cebc74388fd6650ca4f604Eric Christopherinline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) { 3593e39731e88f2d4f597cebc74388fd6650ca4f604Eric Christopher return reinterpret_cast<PassManagerBuilder*>(P); 3603e39731e88f2d4f597cebc74388fd6650ca4f604Eric Christopher} 3613e39731e88f2d4f597cebc74388fd6650ca4f604Eric Christopher 3623e39731e88f2d4f597cebc74388fd6650ca4f604Eric Christopherinline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) { 3633e39731e88f2d4f597cebc74388fd6650ca4f604Eric Christopher return reinterpret_cast<LLVMPassManagerBuilderRef>(P); 3643e39731e88f2d4f597cebc74388fd6650ca4f604Eric Christopher} 3653e39731e88f2d4f597cebc74388fd6650ca4f604Eric Christopher 36679c07d2a36282b09b9c5d0aa65ebf4bff017621bDmitri GribenkoLLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() { 36769cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *PMB = new PassManagerBuilder(); 36869cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola return wrap(PMB); 36969cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 37069cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 37169cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) { 37269cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 37369cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola delete Builder; 37469cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 37569cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 37669cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid 37769cb216009387694122c78438a9117f31a2f9ad5Rafael EspindolaLLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, 37869cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola unsigned OptLevel) { 37969cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 38069cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola Builder->OptLevel = OptLevel; 38169cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 38269cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 38369cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid 38469cb216009387694122c78438a9117f31a2f9ad5Rafael EspindolaLLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, 38569cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola unsigned SizeLevel) { 38669cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 38769cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola Builder->SizeLevel = SizeLevel; 38869cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 38969cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 39069cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid 39169cb216009387694122c78438a9117f31a2f9ad5Rafael EspindolaLLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, 39269cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola LLVMBool Value) { 39369cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 39469cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola Builder->DisableUnitAtATime = Value; 39569cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 39669cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 39769cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid 39869cb216009387694122c78438a9117f31a2f9ad5Rafael EspindolaLLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, 39969cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola LLVMBool Value) { 40069cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 40169cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola Builder->DisableUnrollLoops = Value; 40269cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 40369cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 40469cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid 40569cb216009387694122c78438a9117f31a2f9ad5Rafael EspindolaLLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, 40669cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola LLVMBool Value) { 407be87bce32bc9af9bc5918a6e08806b61e3088165Meador Inge // NOTE: The simplify-libcalls pass has been removed. 40869cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 40969cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 41069cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid 41169cb216009387694122c78438a9117f31a2f9ad5Rafael EspindolaLLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, 41269cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola unsigned Threshold) { 41369cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 41469cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola Builder->Inliner = createFunctionInliningPass(Threshold); 41569cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 41669cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 41769cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid 41869cb216009387694122c78438a9117f31a2f9ad5Rafael EspindolaLLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, 41969cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola LLVMPassManagerRef PM) { 42069cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 42169cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola FunctionPassManager *FPM = unwrap<FunctionPassManager>(PM); 42269cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola Builder->populateFunctionPassManager(*FPM); 42369cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 42469cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 42569cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid 42669cb216009387694122c78438a9117f31a2f9ad5Rafael EspindolaLLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, 42769cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola LLVMPassManagerRef PM) { 42869cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 42969cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBase *MPM = unwrap(PM); 43069cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola Builder->populateModulePassManager(*MPM); 43169cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 43269cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola 43369cb216009387694122c78438a9117f31a2f9ad5Rafael Espindolavoid LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, 43469cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola LLVMPassManagerRef PM, 4350ebc084132cbf4ebebdb6c931ef42f97e3ff5fe1Nick Lewycky LLVMBool Internalize, 4360ebc084132cbf4ebebdb6c931ef42f97e3ff5fe1Nick Lewycky LLVMBool RunInliner) { 43769cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBuilder *Builder = unwrap(PMB); 43869cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola PassManagerBase *LPM = unwrap(PM); 4390ebc084132cbf4ebebdb6c931ef42f97e3ff5fe1Nick Lewycky Builder->populateLTOPassManager(*LPM, Internalize != 0, RunInliner != 0); 44069cb216009387694122c78438a9117f31a2f9ad5Rafael Espindola} 441