1 //===- llvm/LinkAllPasses.h ------------ Reference All Passes ---*- C++ -*-===//
2 //
3 //                      The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This header file pulls in all transformation and analysis passes for tools
11 // like opt and bugpoint that need this functionality.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LINKALLPASSES_H
16 #define LLVM_LINKALLPASSES_H
17 
18 #include "llvm/ADT/Statistic.h"
19 #include "llvm/Analysis/AliasAnalysisEvaluator.h"
20 #include "llvm/Analysis/AliasSetTracker.h"
21 #include "llvm/Analysis/BasicAliasAnalysis.h"
22 #include "llvm/Analysis/CFLAndersAliasAnalysis.h"
23 #include "llvm/Analysis/CFLSteensAliasAnalysis.h"
24 #include "llvm/Analysis/CallPrinter.h"
25 #include "llvm/Analysis/DomPrinter.h"
26 #include "llvm/Analysis/GlobalsModRef.h"
27 #include "llvm/Analysis/IntervalPartition.h"
28 #include "llvm/Analysis/Lint.h"
29 #include "llvm/Analysis/Passes.h"
30 #include "llvm/Analysis/PostDominators.h"
31 #include "llvm/Analysis/RegionPass.h"
32 #include "llvm/Analysis/RegionPrinter.h"
33 #include "llvm/Analysis/ScalarEvolution.h"
34 #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
35 #include "llvm/Analysis/ScopedNoAliasAA.h"
36 #include "llvm/Analysis/TargetLibraryInfo.h"
37 #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
38 #include "llvm/CodeGen/Passes.h"
39 #include "llvm/IR/Function.h"
40 #include "llvm/IR/IRPrintingPasses.h"
41 #include "llvm/Support/Valgrind.h"
42 #include "llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h"
43 #include "llvm/Transforms/IPO.h"
44 #include "llvm/Transforms/IPO/AlwaysInliner.h"
45 #include "llvm/Transforms/IPO/FunctionAttrs.h"
46 #include "llvm/Transforms/InstCombine/InstCombine.h"
47 #include "llvm/Transforms/Instrumentation.h"
48 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
49 #include "llvm/Transforms/ObjCARC.h"
50 #include "llvm/Transforms/Scalar.h"
51 #include "llvm/Transforms/Scalar/GVN.h"
52 #include "llvm/Transforms/Scalar/InstSimplifyPass.h"
53 #include "llvm/Transforms/Scalar/Scalarizer.h"
54 #include "llvm/Transforms/Utils.h"
55 #include "llvm/Transforms/Utils/SymbolRewriter.h"
56 #include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
57 #include "llvm/Transforms/Vectorize.h"
58 #include <cstdlib>
59 
60 namespace {
61   struct ForcePassLinking {
ForcePassLinkingForcePassLinking62     ForcePassLinking() {
63       // We must reference the passes in such a way that compilers will not
64       // delete it all as dead code, even with whole program optimization,
65       // yet is effectively a NO-OP. As the compiler isn't smart enough
66       // to know that getenv() never returns -1, this will do the job.
67       if (std::getenv("bar") != (char*) -1)
68         return;
69 
70       (void) llvm::createAAEvalPass();
71       (void) llvm::createAggressiveDCEPass();
72       (void) llvm::createAggressiveInstCombinerPass();
73       (void) llvm::createBitTrackingDCEPass();
74       (void) llvm::createArgumentPromotionPass();
75       (void) llvm::createAlignmentFromAssumptionsPass();
76       (void) llvm::createBasicAAWrapperPass();
77       (void) llvm::createSCEVAAWrapperPass();
78       (void) llvm::createTypeBasedAAWrapperPass();
79       (void) llvm::createScopedNoAliasAAWrapperPass();
80       (void) llvm::createBoundsCheckingLegacyPass();
81       (void) llvm::createBreakCriticalEdgesPass();
82       (void) llvm::createCallGraphDOTPrinterPass();
83       (void) llvm::createCallGraphViewerPass();
84       (void) llvm::createCFGSimplificationPass();
85       (void) llvm::createCFLAndersAAWrapperPass();
86       (void) llvm::createCFLSteensAAWrapperPass();
87       (void) llvm::createStructurizeCFGPass();
88       (void) llvm::createLibCallsShrinkWrapPass();
89       (void) llvm::createCalledValuePropagationPass();
90       (void) llvm::createConstantMergePass();
91       (void) llvm::createConstantPropagationPass();
92       (void) llvm::createControlHeightReductionLegacyPass();
93       (void) llvm::createCostModelAnalysisPass();
94       (void) llvm::createDeadArgEliminationPass();
95       (void) llvm::createDeadCodeEliminationPass();
96       (void) llvm::createDeadInstEliminationPass();
97       (void) llvm::createDeadStoreEliminationPass();
98       (void) llvm::createDependenceAnalysisWrapperPass();
99       (void) llvm::createDomOnlyPrinterPass();
100       (void) llvm::createDomPrinterPass();
101       (void) llvm::createDomOnlyViewerPass();
102       (void) llvm::createDomViewerPass();
103       (void) llvm::createGCOVProfilerPass();
104       (void) llvm::createPGOInstrumentationGenLegacyPass();
105       (void) llvm::createPGOInstrumentationUseLegacyPass();
106       (void) llvm::createPGOIndirectCallPromotionLegacyPass();
107       (void) llvm::createPGOMemOPSizeOptLegacyPass();
108       (void) llvm::createInstrProfilingLegacyPass();
109       (void) llvm::createFunctionImportPass();
110       (void) llvm::createFunctionInliningPass();
111       (void) llvm::createAlwaysInlinerLegacyPass();
112       (void) llvm::createGlobalDCEPass();
113       (void) llvm::createGlobalOptimizerPass();
114       (void) llvm::createGlobalsAAWrapperPass();
115       (void) llvm::createGuardWideningPass();
116       (void) llvm::createLoopGuardWideningPass();
117       (void) llvm::createIPConstantPropagationPass();
118       (void) llvm::createIPSCCPPass();
119       (void) llvm::createInductiveRangeCheckEliminationPass();
120       (void) llvm::createIndVarSimplifyPass();
121       (void) llvm::createInstSimplifyLegacyPass();
122       (void) llvm::createInstructionCombiningPass();
123       (void) llvm::createInternalizePass();
124       (void) llvm::createLCSSAPass();
125       (void) llvm::createLegacyDivergenceAnalysisPass();
126       (void) llvm::createLICMPass();
127       (void) llvm::createLoopSinkPass();
128       (void) llvm::createLazyValueInfoPass();
129       (void) llvm::createLoopExtractorPass();
130       (void) llvm::createLoopInterchangePass();
131       (void) llvm::createLoopPredicationPass();
132       (void) llvm::createLoopSimplifyPass();
133       (void) llvm::createLoopSimplifyCFGPass();
134       (void) llvm::createLoopStrengthReducePass();
135       (void) llvm::createLoopRerollPass();
136       (void) llvm::createLoopUnrollPass();
137       (void) llvm::createLoopUnrollAndJamPass();
138       (void) llvm::createLoopUnswitchPass();
139       (void) llvm::createLoopVersioningLICMPass();
140       (void) llvm::createLoopIdiomPass();
141       (void) llvm::createLoopRotatePass();
142       (void) llvm::createLowerExpectIntrinsicPass();
143       (void) llvm::createLowerInvokePass();
144       (void) llvm::createLowerSwitchPass();
145       (void) llvm::createNaryReassociatePass();
146       (void) llvm::createObjCARCAAWrapperPass();
147       (void) llvm::createObjCARCAPElimPass();
148       (void) llvm::createObjCARCExpandPass();
149       (void) llvm::createObjCARCContractPass();
150       (void) llvm::createObjCARCOptPass();
151       (void) llvm::createPAEvalPass();
152       (void) llvm::createPromoteMemoryToRegisterPass();
153       (void) llvm::createDemoteRegisterToMemoryPass();
154       (void) llvm::createPruneEHPass();
155       (void) llvm::createPostDomOnlyPrinterPass();
156       (void) llvm::createPostDomPrinterPass();
157       (void) llvm::createPostDomOnlyViewerPass();
158       (void) llvm::createPostDomViewerPass();
159       (void) llvm::createReassociatePass();
160       (void) llvm::createRegionInfoPass();
161       (void) llvm::createRegionOnlyPrinterPass();
162       (void) llvm::createRegionOnlyViewerPass();
163       (void) llvm::createRegionPrinterPass();
164       (void) llvm::createRegionViewerPass();
165       (void) llvm::createSCCPPass();
166       (void) llvm::createSafeStackPass();
167       (void) llvm::createSROAPass();
168       (void) llvm::createSingleLoopExtractorPass();
169       (void) llvm::createStripSymbolsPass();
170       (void) llvm::createStripNonDebugSymbolsPass();
171       (void) llvm::createStripDeadDebugInfoPass();
172       (void) llvm::createStripDeadPrototypesPass();
173       (void) llvm::createTailCallEliminationPass();
174       (void) llvm::createJumpThreadingPass();
175       (void) llvm::createUnifyFunctionExitNodesPass();
176       (void) llvm::createInstCountPass();
177       (void) llvm::createConstantHoistingPass();
178       (void) llvm::createCodeGenPreparePass();
179       (void) llvm::createEntryExitInstrumenterPass();
180       (void) llvm::createPostInlineEntryExitInstrumenterPass();
181       (void) llvm::createEarlyCSEPass();
182       (void) llvm::createGVNHoistPass();
183       (void) llvm::createMergedLoadStoreMotionPass();
184       (void) llvm::createGVNPass();
185       (void) llvm::createNewGVNPass();
186       (void) llvm::createMemCpyOptPass();
187       (void) llvm::createLoopDeletionPass();
188       (void) llvm::createPostDomTree();
189       (void) llvm::createInstructionNamerPass();
190       (void) llvm::createMetaRenamerPass();
191       (void) llvm::createPostOrderFunctionAttrsLegacyPass();
192       (void) llvm::createReversePostOrderFunctionAttrsPass();
193       (void) llvm::createMergeFunctionsPass();
194       (void) llvm::createMergeICmpsPass();
195       (void) llvm::createExpandMemCmpPass();
196       std::string buf;
197       llvm::raw_string_ostream os(buf);
198       (void) llvm::createPrintModulePass(os);
199       (void) llvm::createPrintFunctionPass(os);
200       (void) llvm::createPrintBasicBlockPass(os);
201       (void) llvm::createModuleDebugInfoPrinterPass();
202       (void) llvm::createPartialInliningPass();
203       (void) llvm::createLintPass();
204       (void) llvm::createSinkingPass();
205       (void) llvm::createLowerAtomicPass();
206       (void) llvm::createCorrelatedValuePropagationPass();
207       (void) llvm::createMemDepPrinter();
208       (void) llvm::createLoopVectorizePass();
209       (void) llvm::createSLPVectorizerPass();
210       (void) llvm::createLoadStoreVectorizerPass();
211       (void) llvm::createPartiallyInlineLibCallsPass();
212       (void) llvm::createScalarizerPass();
213       (void) llvm::createSeparateConstOffsetFromGEPPass();
214       (void) llvm::createSpeculativeExecutionPass();
215       (void) llvm::createSpeculativeExecutionIfHasBranchDivergencePass();
216       (void) llvm::createRewriteSymbolsPass();
217       (void) llvm::createStraightLineStrengthReducePass();
218       (void) llvm::createMemDerefPrinter();
219       (void) llvm::createMustExecutePrinter();
220       (void) llvm::createFloat2IntPass();
221       (void) llvm::createEliminateAvailableExternallyPass();
222       (void) llvm::createScalarizeMaskedMemIntrinPass();
223       (void) llvm::createWarnMissedTransformationsPass();
224 
225       (void)new llvm::IntervalPartition();
226       (void)new llvm::ScalarEvolutionWrapperPass();
227       llvm::Function::Create(nullptr, llvm::GlobalValue::ExternalLinkage)->viewCFGOnly();
228       llvm::RGPassManager RGM;
229       llvm::TargetLibraryInfoImpl TLII;
230       llvm::TargetLibraryInfo TLI(TLII);
231       llvm::AliasAnalysis AA(TLI);
232       llvm::AliasSetTracker X(AA);
233       X.add(nullptr, llvm::LocationSize::unknown(),
234             llvm::AAMDNodes()); // for -print-alias-sets
235       (void) llvm::AreStatisticsEnabled();
236       (void) llvm::sys::RunningOnValgrind();
237     }
238   } ForcePassLinking; // Force link by creating a global definition.
239 }
240 
241 #endif
242