xref: /llvm-project/llvm/include/llvm/LinkAllPasses.h (revision 3eca15cbb9888a992749ddd24f0fb666dad733bf)
1 //===- llvm/LinkAllPasses.h ------------ Reference All Passes ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This header file pulls in all transformation and analysis passes for tools
10 // like opt and bugpoint that need this functionality.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LINKALLPASSES_H
15 #define LLVM_LINKALLPASSES_H
16 
17 #include "llvm/ADT/Statistic.h"
18 #include "llvm/Analysis/AliasAnalysisEvaluator.h"
19 #include "llvm/Analysis/AliasSetTracker.h"
20 #include "llvm/Analysis/BasicAliasAnalysis.h"
21 #include "llvm/Analysis/CallPrinter.h"
22 #include "llvm/Analysis/DXILResource.h"
23 #include "llvm/Analysis/DomPrinter.h"
24 #include "llvm/Analysis/GlobalsModRef.h"
25 #include "llvm/Analysis/Passes.h"
26 #include "llvm/Analysis/PostDominators.h"
27 #include "llvm/Analysis/RegionPass.h"
28 #include "llvm/Analysis/RegionPrinter.h"
29 #include "llvm/Analysis/ScalarEvolution.h"
30 #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
31 #include "llvm/Analysis/ScopedNoAliasAA.h"
32 #include "llvm/Analysis/TargetLibraryInfo.h"
33 #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
34 #include "llvm/CodeGen/Passes.h"
35 #include "llvm/IR/Function.h"
36 #include "llvm/IR/IRPrintingPasses.h"
37 #include "llvm/Support/Valgrind.h"
38 #include "llvm/Transforms/IPO.h"
39 #include "llvm/Transforms/IPO/AlwaysInliner.h"
40 #include "llvm/Transforms/InstCombine/InstCombine.h"
41 #include "llvm/Transforms/ObjCARC.h"
42 #include "llvm/Transforms/Scalar.h"
43 #include "llvm/Transforms/Scalar/GVN.h"
44 #include "llvm/Transforms/Scalar/Scalarizer.h"
45 #include "llvm/Transforms/Utils.h"
46 #include "llvm/Transforms/Utils/SymbolRewriter.h"
47 #include "llvm/Transforms/Vectorize/LoadStoreVectorizer.h"
48 #include <cstdlib>
49 
50 namespace {
51 struct ForcePassLinking {
52   ForcePassLinking() {
53     // We must reference the passes in such a way that compilers will not
54     // delete it all as dead code, even with whole program optimization,
55     // yet is effectively a NO-OP. As the compiler isn't smart enough
56     // to know that getenv() never returns -1, this will do the job.
57     // This is so that globals in the translation units where these functions
58     // are defined are forced to be initialized, populating various
59     // registries.
60     if (std::getenv("bar") != (char *)-1)
61       return;
62 
63     (void)llvm::createAtomicExpandLegacyPass();
64     (void)llvm::createBasicAAWrapperPass();
65     (void)llvm::createSCEVAAWrapperPass();
66     (void)llvm::createTypeBasedAAWrapperPass();
67     (void)llvm::createScopedNoAliasAAWrapperPass();
68     (void)llvm::createBreakCriticalEdgesPass();
69     (void)llvm::createCallGraphDOTPrinterPass();
70     (void)llvm::createCallGraphViewerPass();
71     (void)llvm::createCFGSimplificationPass();
72     (void)llvm::createStructurizeCFGPass();
73     (void)llvm::createDXILResourceBindingWrapperPassPass();
74     (void)llvm::createDXILResourceTypeWrapperPassPass();
75     (void)llvm::createDeadArgEliminationPass();
76     (void)llvm::createDeadCodeEliminationPass();
77     (void)llvm::createDependenceAnalysisWrapperPass();
78     (void)llvm::createDomOnlyPrinterWrapperPassPass();
79     (void)llvm::createDomPrinterWrapperPassPass();
80     (void)llvm::createDomOnlyViewerWrapperPassPass();
81     (void)llvm::createDomViewerWrapperPassPass();
82     (void)llvm::createAlwaysInlinerLegacyPass();
83     (void)llvm::createGlobalMergeFuncPass();
84     (void)llvm::createGlobalsAAWrapperPass();
85     (void)llvm::createInstSimplifyLegacyPass();
86     (void)llvm::createInstructionCombiningPass();
87     (void)llvm::createJMCInstrumenterPass();
88     (void)llvm::createKCFIPass();
89     (void)llvm::createLCSSAPass();
90     (void)llvm::createLICMPass();
91     (void)llvm::createLazyValueInfoPass();
92     (void)llvm::createLoopExtractorPass();
93     (void)llvm::createLoopSimplifyPass();
94     (void)llvm::createLoopStrengthReducePass();
95     (void)llvm::createLoopTermFoldPass();
96     (void)llvm::createLoopUnrollPass();
97     (void)llvm::createLowerGlobalDtorsLegacyPass();
98     (void)llvm::createLowerInvokePass();
99     (void)llvm::createLowerSwitchPass();
100     (void)llvm::createNaryReassociatePass();
101     (void)llvm::createObjCARCContractPass();
102     (void)llvm::createPromoteMemoryToRegisterPass();
103     (void)llvm::createRegToMemWrapperPass();
104     (void)llvm::createPostDomOnlyPrinterWrapperPassPass();
105     (void)llvm::createPostDomPrinterWrapperPassPass();
106     (void)llvm::createPostDomOnlyViewerWrapperPassPass();
107     (void)llvm::createPostDomViewerWrapperPassPass();
108     (void)llvm::createReassociatePass();
109     (void)llvm::createRegionInfoPass();
110     (void)llvm::createRegionOnlyPrinterPass();
111     (void)llvm::createRegionOnlyViewerPass();
112     (void)llvm::createRegionPrinterPass();
113     (void)llvm::createRegionViewerPass();
114     (void)llvm::createSafeStackPass();
115     (void)llvm::createSROAPass();
116     (void)llvm::createSingleLoopExtractorPass();
117     (void)llvm::createTailCallEliminationPass();
118     (void)llvm::createConstantHoistingPass();
119     (void)llvm::createCodeGenPrepareLegacyPass();
120     (void)llvm::createPostInlineEntryExitInstrumenterPass();
121     (void)llvm::createEarlyCSEPass();
122     (void)llvm::createGVNPass();
123     (void)llvm::createPostDomTree();
124     (void)llvm::createMergeICmpsLegacyPass();
125     (void)llvm::createExpandLargeDivRemPass();
126     (void)llvm::createExpandMemCmpLegacyPass();
127     std::string buf;
128     llvm::raw_string_ostream os(buf);
129     (void)llvm::createPrintModulePass(os);
130     (void)llvm::createPrintFunctionPass(os);
131     (void)llvm::createSinkingPass();
132     (void)llvm::createLowerAtomicPass();
133     (void)llvm::createLoadStoreVectorizerPass();
134     (void)llvm::createPartiallyInlineLibCallsPass();
135     (void)llvm::createScalarizerPass();
136     (void)llvm::createSeparateConstOffsetFromGEPPass();
137     (void)llvm::createSpeculativeExecutionPass();
138     (void)llvm::createSpeculativeExecutionIfHasBranchDivergencePass();
139     (void)llvm::createStraightLineStrengthReducePass();
140     (void)llvm::createScalarizeMaskedMemIntrinLegacyPass();
141     (void)llvm::createHardwareLoopsLegacyPass();
142     (void)llvm::createUnifyLoopExitsPass();
143     (void)llvm::createFixIrreduciblePass();
144     (void)llvm::createSelectOptimizePass();
145 
146     (void)new llvm::ScalarEvolutionWrapperPass();
147     llvm::Function::Create(nullptr, llvm::GlobalValue::ExternalLinkage)
148         ->viewCFGOnly();
149     llvm::RGPassManager RGM;
150     llvm::TargetLibraryInfoImpl TLII;
151     llvm::TargetLibraryInfo TLI(TLII);
152     llvm::AliasAnalysis AA(TLI);
153     llvm::BatchAAResults BAA(AA);
154     llvm::AliasSetTracker X(BAA);
155     X.add(llvm::MemoryLocation()); // for -print-alias-sets
156     (void)llvm::AreStatisticsEnabled();
157     (void)llvm::sys::RunningOnValgrind();
158   }
159 } ForcePassLinking; // Force link by creating a global definition.
160 } // namespace
161 
162 #endif
163