llvm.org GIT mirror llvm / 844731a
Clean up the use of static and anonymous namespaces. This turned up several things that were neither in an anonymous namespace nor static but not intended to be global. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51017 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 11 years ago
124 changed file(s) with 846 addition(s) and 768 deletion(s). Raw diff Collapse all Expand all
3333 using namespace llvm;
3434
3535 // Register the AliasAnalysis interface, providing a nice name to refer to.
36 namespace {
37 RegisterAnalysisGroup Z("Alias Analysis");
38 }
36 static RegisterAnalysisGroup Z("Alias Analysis");
3937 char AliasAnalysis::ID = 0;
4038
4139 //===----------------------------------------------------------------------===//
2020 #include "llvm/Support/Streams.h"
2121 using namespace llvm;
2222
23 static cl::opt
24 PrintAll("count-aa-print-all-queries", cl::ReallyHidden);
25 static cl::opt
26 PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden);
27
2328 namespace {
24 static cl::opt
25 PrintAll("count-aa-print-all-queries", cl::ReallyHidden);
26 static cl::opt
27 PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden);
28
2929 class VISIBILITY_HIDDEN AliasAnalysisCounter
3030 : public ModulePass, public AliasAnalysis {
3131 unsigned No, May, Must;
112112 return AliasAnalysis::getModRefInfo(CS1,CS2);
113113 }
114114 };
115 }
115116
116 char AliasAnalysisCounter::ID = 0;
117 RegisterPass
118 X("count-aa", "Count Alias Analysis Query Responses", false, true);
119 RegisterAnalysisGroup Y(X);
120 }
117 char AliasAnalysisCounter::ID = 0;
118 static RegisterPass
119 X("count-aa", "Count Alias Analysis Query Responses", false, true);
120 static RegisterAnalysisGroup Y(X);
121121
122122 ModulePass *llvm::createAliasAnalysisCounterPass() {
123123 return new AliasAnalysisCounter();
3333 #include
3434 using namespace llvm;
3535
36 static cl::opt PrintAll("print-all-alias-modref-info", cl::ReallyHidden);
37
38 static cl::opt PrintNoAlias("print-no-aliases", cl::ReallyHidden);
39 static cl::opt PrintMayAlias("print-may-aliases", cl::ReallyHidden);
40 static cl::opt PrintMustAlias("print-must-aliases", cl::ReallyHidden);
41
42 static cl::opt PrintNoModRef("print-no-modref", cl::ReallyHidden);
43 static cl::opt PrintMod("print-mod", cl::ReallyHidden);
44 static cl::opt PrintRef("print-ref", cl::ReallyHidden);
45 static cl::opt PrintModRef("print-modref", cl::ReallyHidden);
46
3647 namespace {
37 static cl::opt
38 PrintAll("print-all-alias-modref-info", cl::ReallyHidden);
39
40 static cl::opt PrintNoAlias("print-no-aliases", cl::ReallyHidden);
41 static cl::opt PrintMayAlias("print-may-aliases", cl::ReallyHidden);
42 static cl::opt PrintMustAlias("print-must-aliases", cl::ReallyHidden);
43
44 static cl::opt PrintNoModRef("print-no-modref", cl::ReallyHidden);
45 static cl::opt PrintMod("print-mod", cl::ReallyHidden);
46 static cl::opt PrintRef("print-ref", cl::ReallyHidden);
47 static cl::opt PrintModRef("print-modref", cl::ReallyHidden);
48
4948 class VISIBILITY_HIDDEN AAEval : public FunctionPass {
5049 unsigned NoAlias, MayAlias, MustAlias;
5150 unsigned NoModRef, Mod, Ref, ModRef;
7372 bool runOnFunction(Function &F);
7473 bool doFinalization(Module &M);
7574 };
76
77 char AAEval::ID = 0;
78 static RegisterPass
79 X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true);
80 }
75 }
76
77 char AAEval::ID = 0;
78 static RegisterPass
79 X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true);
8180
8281 FunctionPass *llvm::createAAEvalPass() { return new AAEval(); }
8382
120120 }
121121
122122 };
123 }
123124
124 char AliasDebugger::ID = 0;
125 RegisterPass X("debug-aa", "AA use debugger", false, true);
126 RegisterAnalysisGroup Y(X);
127 }
125 char AliasDebugger::ID = 0;
126 static RegisterPass
127 X("debug-aa", "AA use debugger", false, true);
128 static RegisterAnalysisGroup Y(X);
128129
129130 Pass *llvm::createAliasDebugger() { return new AliasDebugger(); }
130131
584584 return false;
585585 }
586586 };
587 char AliasSetPrinter::ID = 0;
588 RegisterPass X("print-alias-sets", "Alias Set Printer", false, true);
589 }
587 }
588
589 char AliasSetPrinter::ID = 0;
590 static RegisterPass
591 X("print-alias-sets", "Alias Set Printer", false, true);
7878 virtual void deleteValue(Value *V) {}
7979 virtual void copyValue(Value *From, Value *To) {}
8080 };
81
82 // Register this pass...
83 char NoAA::ID = 0;
84 RegisterPass
85 U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true);
86
87 // Declare that we implement the AliasAnalysis interface
88 RegisterAnalysisGroup V(U);
8981 } // End of anonymous namespace
82
83 // Register this pass...
84 char NoAA::ID = 0;
85 static RegisterPass
86 U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true);
87
88 // Declare that we implement the AliasAnalysis interface
89 static RegisterAnalysisGroup V(U);
9090
9191 ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
9292
123123 const Type *BasePtr2Ty,
124124 Value **GEP2Ops, unsigned NumGEP2Ops, unsigned G2Size);
125125 };
126
127 // Register this pass...
128 char BasicAliasAnalysis::ID = 0;
129 RegisterPass
130 X("basicaa", "Basic Alias Analysis (default AA impl)", false, true);
131
132 // Declare that we implement the AliasAnalysis interface
133 RegisterAnalysisGroup Y(X);
134126 } // End of anonymous namespace
127
128 // Register this pass...
129 char BasicAliasAnalysis::ID = 0;
130 static RegisterPass
131 X("basicaa", "Basic Alias Analysis (default AA impl)", false, true);
132
133 // Declare that we implement the AliasAnalysis interface
134 static RegisterAnalysisGroup Y(X);
135135
136136 ImmutablePass *llvm::createBasicAliasAnalysisPass() {
137137 return new BasicAliasAnalysis();
104104 AU.setPreservesAll();
105105 }
106106 };
107
108 char CFGViewer::ID = 0;
109 RegisterPass V0("view-cfg",
110 "View CFG of function", false, true);
111
107 }
108
109 char CFGViewer::ID = 0;
110 static RegisterPass
111 V0("view-cfg", "View CFG of function", false, true);
112
113 namespace {
112114 struct VISIBILITY_HIDDEN CFGOnlyViewer : public FunctionPass {
113115 static char ID; // Pass identifcation, replacement for typeid
114116 CFGOnlyViewer() : FunctionPass((intptr_t)&ID) {}
126128 AU.setPreservesAll();
127129 }
128130 };
129
130 char CFGOnlyViewer::ID = 0;
131 RegisterPass V1("view-cfg-only",
132 "View CFG of function (with no function bodies)", false, true);
133
131 }
132
133 char CFGOnlyViewer::ID = 0;
134 static RegisterPass
135 V1("view-cfg-only",
136 "View CFG of function (with no function bodies)", false, true);
137
138 namespace {
134139 struct VISIBILITY_HIDDEN CFGPrinter : public FunctionPass {
135140 static char ID; // Pass identification, replacement for typeid
136141 CFGPrinter() : FunctionPass((intptr_t)&ID) {}
155160 AU.setPreservesAll();
156161 }
157162 };
158
159 char CFGPrinter::ID = 0;
160 RegisterPass P1("print-cfg",
161 "Print CFG of function to 'dot' file", false, true);
162
163 }
164
165 char CFGPrinter::ID = 0;
166 static RegisterPass
167 P1("print-cfg", "Print CFG of function to 'dot' file", false, true);
168
169 namespace {
163170 struct VISIBILITY_HIDDEN CFGOnlyPrinter : public CFGPrinter {
164171 static char ID; // Pass identification, replacement for typeid
165172 CFGOnlyPrinter() : CFGPrinter((intptr_t)&ID) {}
176183 AU.setPreservesAll();
177184 }
178185 };
179
180 char CFGOnlyPrinter::ID = 0;
181 RegisterPass
182 P2("print-cfg-only",
183 "Print CFG of function to 'dot' file (with no function bodies)", false, true);
184 }
186 }
187
188 char CFGOnlyPrinter::ID = 0;
189 static RegisterPass
190 P2("print-cfg-only",
191 "Print CFG of function to 'dot' file (with no function bodies)", false, true);
185192
186193 /// viewCFG - This function is meant for use from the debugger. You can just
187194 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
8888 STATISTIC(NumUnified , "Number of variables unified");
8989 STATISTIC(NumErased , "Number of redundant constraints erased");
9090
91 static const unsigned SelfRep = (unsigned)-1;
92 static const unsigned Unvisited = (unsigned)-1;
93 // Position of the function return node relative to the function node.
94 static const unsigned CallReturnPos = 1;
95 // Position of the function call node relative to the function node.
96 static const unsigned CallFirstArgPos = 2;
97
9198 namespace {
92 const unsigned SelfRep = (unsigned)-1;
93 const unsigned Unvisited = (unsigned)-1;
94 // Position of the function return node relative to the function node.
95 const unsigned CallReturnPos = 1;
96 // Position of the function call node relative to the function node.
97 const unsigned CallFirstArgPos = 2;
98
9999 struct BitmapKeyInfo {
100100 static inline SparseBitVector<> *getEmptyKey() {
101101 return reinterpret_cast *>(-1);
607607 PrintPointsToGraph();
608608 }
609609 };
610
611 char Andersens::ID = 0;
612 RegisterPass X("anders-aa",
613 "Andersen's Interprocedural Alias Analysis", false,
614 true);
615 RegisterAnalysisGroup Y(X);
616
617 // Initialize Timestamp Counter (static).
618 unsigned Andersens::Node::Counter = 0;
619 }
610 }
611
612 char Andersens::ID = 0;
613 static RegisterPass
614 X("anders-aa", "Andersen's Interprocedural Alias Analysis", false, true);
615 static RegisterAnalysisGroup Y(X);
616
617 // Initialize Timestamp Counter (static).
618 unsigned Andersens::Node::Counter = 0;
620619
621620 ModulePass *llvm::createAndersensPass() { return new Andersens(); }
622621
189189 }
190190 };
191191
192 RegisterAnalysisGroup X("Call Graph");
193 RegisterPass Y("basiccg", "Basic CallGraph Construction", false, true);
194 RegisterAnalysisGroup Z(Y);
195
196192 } //End anonymous namespace
193
194 static RegisterAnalysisGroup X("Call Graph");
195 static RegisterPass
196 Y("basiccg", "Basic CallGraph Construction", false, true);
197 static RegisterAnalysisGroup Z(Y);
197198
198199 char CallGraph::ID = 0;
199200 char BasicCallGraph::ID = 0;
2525 // CGPassManager
2626 //
2727 /// CGPassManager manages FPPassManagers and CalLGraphSCCPasses.
28
29 namespace {
2830
2931 class CGPassManager : public ModulePass, public PMDataManager {
3032
7173 return PMT_CallGraphPassManager;
7274 }
7375 };
76
77 }
7478
7579 char CGPassManager::ID = 0;
7680 /// run - Execute all of the passes scheduled for execution. Keep track of
145145 GlobalValue *OkayStoreDest = 0);
146146 bool AnalyzeIndirectGlobalMemory(GlobalValue *GV);
147147 };
148
149 char GlobalsModRef::ID = 0;
150 RegisterPass X("globalsmodref-aa",
151 "Simple mod/ref analysis for globals", false,
152 true);
153 RegisterAnalysisGroup Y(X);
154 }
148 }
149
150 char GlobalsModRef::ID = 0;
151 static RegisterPass
152 X("globalsmodref-aa", "Simple mod/ref analysis for globals", false, true);
153 static RegisterAnalysisGroup Y(X);
155154
156155 Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); }
157156
6161 virtual void print(std::ostream &O, const Module *M) const {}
6262
6363 };
64 }
6465
65 char InstCount::ID = 0;
66 RegisterPass X("instcount",
67 "Counts the various types of Instructions", false, true);
68 }
66 char InstCount::ID = 0;
67 static RegisterPass
68 X("instcount", "Counts the various types of Instructions", false, true);
6969
7070 FunctionPass *llvm::createInstCountPass() { return new InstCount(); }
7171
8181 void getCallEqualNumberNodes(CallInst *CI,
8282 std::vector &RetVals) const;
8383 };
84
85 char LoadVN::ID = 0;
86 // Register this pass...
87 RegisterPass X("load-vn", "Load Value Numbering", false, true);
88
89 // Declare that we implement the ValueNumbering interface
90 RegisterAnalysisGroup Y(X);
9184 }
85
86 char LoadVN::ID = 0;
87 // Register this pass...
88 static RegisterPass
89 X("load-vn", "Load Value Numbering", false, true);
90
91 // Declare that we implement the ValueNumbering interface
92 static RegisterAnalysisGroup Y(X);
9293
9394 FunctionPass *llvm::createLoadValueNumberingPass() { return new LoadVN(); }
9495
2727
2828 using namespace llvm;
2929
30 namespace {
31 // Control the calculation of non-local dependencies by only examining the
32 // predecessors if the basic block has less than X amount (50 by default).
33 static cl::opt
34 PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50),
35 cl::desc("Control the calculation of non-local"
36 "dependencies (default = 50)"));
37 }
30 // Control the calculation of non-local dependencies by only examining the
31 // predecessors if the basic block has less than X amount (50 by default).
32 static cl::opt
33 PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50),
34 cl::desc("Control the calculation of non-local"
35 "dependencies (default = 50)"));
3836
3937 STATISTIC(NumCacheNonlocal, "Number of cached non-local responses");
4038 STATISTIC(NumUncacheNonlocal, "Number of uncached non-local responses");
2020 using namespace llvm;
2121
2222 // Register the ProfileInfo interface, providing a nice name to refer to.
23 namespace {
24 RegisterAnalysisGroup Z("Profile Information");
25 }
23 static RegisterAnalysisGroup Z("Profile Information");
2624 char ProfileInfo::ID = 0;
2725
2826 ProfileInfo::~ProfileInfo() {}
8886 static char ID; // Class identification, replacement for typeinfo
8987 NoProfileInfo() : ImmutablePass((intptr_t)&ID) {}
9088 };
91
92 char NoProfileInfo::ID = 0;
93 // Register this pass...
94 RegisterPass
95 X("no-profile", "No Profile Information", false, true);
96
97 // Declare that we implement the ProfileInfo interface
98 RegisterAnalysisGroup Y(X);
9989 } // End of anonymous namespace
10090
91 char NoProfileInfo::ID = 0;
92 // Register this pass...
93 static RegisterPass
94 X("no-profile", "No Profile Information", false, true);
95
96 // Declare that we implement the ProfileInfo interface
97 static RegisterAnalysisGroup Y(X);
98
10199 ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); }
2222 #include "llvm/Support/Streams.h"
2323 using namespace llvm;
2424
25 static cl::opt
26 ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"),
27 cl::value_desc("filename"),
28 cl::desc("Profile file loaded by -profile-loader"));
29
2530 namespace {
26 static cl::opt
27 ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"),
28 cl::value_desc("filename"),
29 cl::desc("Profile file loaded by -profile-loader"));
30
3131 class VISIBILITY_HIDDEN LoaderPass : public ModulePass, public ProfileInfo {
3232 std::string Filename;
3333 public:
4848 /// run - Load the profile information from the specified file.
4949 virtual bool runOnModule(Module &M);
5050 };
51 } // End of anonymous namespace
5152
52 char LoaderPass::ID = 0;
53 RegisterPass
54 X("profile-loader", "Load profile information from llvmprof.out", false, true);
53 char LoaderPass::ID = 0;
54 static RegisterPass
55 X("profile-loader", "Load profile information from llvmprof.out", false, true);
5556
56 RegisterAnalysisGroup Y(X);
57 } // End of anonymous namespace
57 static RegisterAnalysisGroup Y(X);
5858
5959 ModulePass *llvm::createProfileLoaderPass() { return new LoaderPass(); }
6060
9494 STATISTIC(NumBruteForceTripCountsComputed,
9595 "Number of loops with trip counts computed by force");
9696
97 cl::opt
97 static cl::opt
9898 MaxBruteForceIterations("scalar-evolution-max-iterations", cl::ReallyHidden,
9999 cl::desc("Maximum number of iterations SCEV will "
100100 "symbolically execute a constant derived loop"),
101101 cl::init(100));
102102
103 namespace {
104 RegisterPass
105 R("scalar-evolution", "Scalar Evolution Analysis", false, true);
106 }
103 static RegisterPass
104 R("scalar-evolution", "Scalar Evolution Analysis", false, true);
107105 char ScalarEvolution::ID = 0;
108106
109107 //===----------------------------------------------------------------------===//
2323
2424 char ValueNumbering::ID = 0;
2525 // Register the ValueNumbering interface, providing a nice name to refer to.
26 static RegisterAnalysisGroup X("Value Numbering");
26 static RegisterAnalysisGroup V("Value Numbering");
2727
2828 /// ValueNumbering destructor: DO NOT move this to the header file for
2929 /// ValueNumbering or else clients of the ValueNumbering class may not depend on
6363 virtual void getEqualNumberNodes(Value *V1,
6464 std::vector &RetVals) const;
6565 };
66
67 char BasicVN::ID = 0;
68 // Register this pass...
69 RegisterPass
70 X("basicvn", "Basic Value Numbering (default GVN impl)", false, true);
71
72 // Declare that we implement the ValueNumbering interface
73 RegisterAnalysisGroup Y(X);
74
66 }
67
68 char BasicVN::ID = 0;
69 // Register this pass...
70 static RegisterPass
71 X("basicvn", "Basic Value Numbering (default GVN impl)", false, true);
72
73 // Declare that we implement the ValueNumbering interface
74 static RegisterAnalysisGroup Y(X);
75
76 namespace {
7577 /// BVNImpl - Implement BasicVN in terms of a visitor class that
7678 /// handles the different types of instructions as appropriate.
7779 ///
1818 using namespace llvm;
1919
2020 /// Read a variable-bit-rate encoded unsigned integer
21 inline unsigned readInteger(const char*&At, const char*End){
21 static inline unsigned readInteger(const char*&At, const char*End) {
2222 unsigned Shift = 0;
2323 unsigned Result = 0;
2424
2424
2525 // Write an integer using variable bit rate encoding. This saves a few bytes
2626 // per entry in the symbol table.
27 inline void writeInteger(unsigned num, std::ofstream& ARFile) {
27 static inline void writeInteger(unsigned num, std::ofstream& ARFile) {
2828 while (1) {
2929 if (num < 0x80) { // done?
3030 ARFile << (unsigned char)num;
4040
4141 // Compute how many bytes are taken by a given VBR encoded value. This is needed
4242 // to pre-compute the size of the symbol table.
43 inline unsigned numVbrBytes(unsigned num) {
43 static inline unsigned numVbrBytes(unsigned num) {
4444
4545 // Note that the following nested ifs are somewhat equivalent to a binary
4646 // search. We split it in half by comparing against 2^14 first. This allows
113113 }
114114
115115 // Optimize constant ordering.
116 struct CstSortPredicate {
117 ValueEnumerator &VE;
118 CstSortPredicate(ValueEnumerator &ve) : VE(ve) {}
119 bool operator()(const std::pair &LHS,
120 const std::pair &RHS) {
121 // Sort by plane.
122 if (LHS.first->getType() != RHS.first->getType())
123 return VE.getTypeID(LHS.first->getType()) <
124 VE.getTypeID(RHS.first->getType());
125 // Then by frequency.
126 return LHS.second > RHS.second;
127 }
128 };
116 namespace {
117 struct CstSortPredicate {
118 ValueEnumerator &VE;
119 explicit CstSortPredicate(ValueEnumerator &ve) : VE(ve) {}
120 bool operator()(const std::pair &LHS,
121 const std::pair &RHS) {
122 // Sort by plane.
123 if (LHS.first->getType() != RHS.first->getType())
124 return VE.getTypeID(LHS.first->getType()) <
125 VE.getTypeID(RHS.first->getType());
126 // Then by frequency.
127 return LHS.second > RHS.second;
128 }
129 };
130 }
129131
130132 /// OptimizeConstants - Reorder constant pool for denser encoding.
131133 void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) {
3737 STATISTIC(NumTailMerge , "Number of block tails merged");
3838 static cl::opt FlagEnableTailMerge("enable-tail-merge",
3939 cl::init(cl::BOU_UNSET), cl::Hidden);
40 // Throttle for huge numbers of predecessors (compile speed problems)
41 static cl::opt
42 TailMergeThreshold("tail-merge-threshold",
43 cl::desc("Max number of predecessors to consider tail merging"),
44 cl::init(100), cl::Hidden);
45
4046 namespace {
41 // Throttle for huge numbers of predecessors (compile speed problems)
42 static cl::opt
43 TailMergeThreshold("tail-merge-threshold",
44 cl::desc("Max number of predecessors to consider tail merging"),
45 cl::init(100), cl::Hidden);
46
4747 struct VISIBILITY_HIDDEN BranchFolder : public MachineFunctionPass {
4848 static char ID;
4949 explicit BranchFolder(bool defaultEnableTailMerge) :
5050 bool doFinalization(Module &M);
5151 };
5252
53 RegisterPass
54 X("collector-metadata", "Create Garbage Collector Module Metadata");
55
56 }
53 }
54
55 static RegisterPass
56 X("collector-metadata", "Create Garbage Collector Module Metadata");
5757
5858 // -----------------------------------------------------------------------------
5959
3535 #include
3636 using namespace llvm;
3737
38 namespace {
39 // Hidden options for help debugging.
40 static cl::opt DisableReMat("disable-rematerialization",
41 cl::init(false), cl::Hidden);
42
43 static cl::opt SplitAtBB("split-intervals-at-bb",
44 cl::init(true), cl::Hidden);
45 static cl::opt SplitLimit("split-limit",
46 cl::init(-1), cl::Hidden);
47 }
38 // Hidden options for help debugging.
39 static cl::opt DisableReMat("disable-rematerialization",
40 cl::init(false), cl::Hidden);
41
42 static cl::opt SplitAtBB("split-intervals-at-bb",
43 cl::init(true), cl::Hidden);
44 static cl::opt SplitLimit("split-limit",
45 cl::init(-1), cl::Hidden);
4846
4947 STATISTIC(numIntervals, "Number of original intervals");
5048 STATISTIC(numIntervalsAfter, "Number of intervals after coalescing");
5250 STATISTIC(numSplits , "Number of intervals split");
5351
5452 char LiveIntervals::ID = 0;
55 namespace {
56 RegisterPass X("liveintervals", "Live Interval Analysis");
57 }
53 static RegisterPass X("liveintervals", "Live Interval Analysis");
5854
5955 void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const {
6056 AU.addPreserved();
10771073
10781074 /// RewriteInfo - Keep track of machine instrs that will be rewritten
10791075 /// during spilling.
1080 struct RewriteInfo {
1081 unsigned Index;
1082 MachineInstr *MI;
1083 bool HasUse;
1084 bool HasDef;
1085 RewriteInfo(unsigned i, MachineInstr *mi, bool u, bool d)
1086 : Index(i), MI(mi), HasUse(u), HasDef(d) {}
1087 };
1088
1089 struct RewriteInfoCompare {
1090 bool operator()(const RewriteInfo &LHS, const RewriteInfo &RHS) const {
1091 return LHS.Index < RHS.Index;
1092 }
1093 };
1076 namespace {
1077 struct RewriteInfo {
1078 unsigned Index;
1079 MachineInstr *MI;
1080 bool HasUse;
1081 bool HasDef;
1082 RewriteInfo(unsigned i, MachineInstr *mi, bool u, bool d)
1083 : Index(i), MI(mi), HasUse(u), HasDef(d) {}
1084 };
1085
1086 struct RewriteInfoCompare {
1087 bool operator()(const RewriteInfo &LHS, const RewriteInfo &RHS) const {
1088 return LHS.Index < RHS.Index;
1089 }
1090 };
1091 }
10941092
10951093 void LiveIntervals::
10961094 rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit,
2121
2222 char MachineDominatorTree::ID = 0;
2323
24 namespace {
25 RegisterPass
26 E("machinedomtree", "MachineDominator Tree Construction", true);
27 }
24 static RegisterPass
25 E("machinedomtree", "MachineDominator Tree Construction", true);
2826
2927 const PassInfo *llvm::MachineDominatorsID = E.getPassInfo();
149149 ///
150150 void Hoist(MachineInstr &MI);
151151 };
152
153 char MachineLICM::ID = 0;
154 RegisterPass X("machine-licm",
155 "Machine Loop Invariant Code Motion");
156152 } // end anonymous namespace
153
154 char MachineLICM::ID = 0;
155 static RegisterPass
156 X("machine-licm", "Machine Loop Invariant Code Motion");
157157
158158 FunctionPass *llvm::createMachineLICMPass() { return new MachineLICM(); }
159159
2222 TEMPLATE_INSTANTIATION(class LoopInfoBase);
2323
2424 char MachineLoopInfo::ID = 0;
25 namespace {
26 RegisterPass
27 X("machine-loops", "Machine Natural Loop Construction", true);
28 }
25 static RegisterPass
26 X("machine-loops", "Machine Natural Loop Construction", true);
2927
3028 const PassInfo *llvm::MachineLoopInfoID = X.getPassInfo();
3129
2626 using namespace llvm::dwarf;
2727
2828 // Handle the Pass registration stuff necessary to use TargetData's.
29 namespace {
30 RegisterPass X("machinemoduleinfo", "Module Information");
31 }
29 static RegisterPass
30 X("machinemoduleinfo", "Module Information");
3231 char MachineModuleInfo::ID = 0;
3332
3433 //===----------------------------------------------------------------------===//
159158 DD->ApplyToFields(this);
160159 }
161160
161 namespace {
162
162163 //===----------------------------------------------------------------------===//
163164 /// DICountVisitor - This DIVisitor counts all the fields in the supplied debug
164165 /// the supplied DebugInfoDesc.
478479 }
479480 };
480481
482 }
481483
482484 //===----------------------------------------------------------------------===//
483485
4949 bool SinkInstruction(MachineInstr *MI, bool &SawStore);
5050 bool AllUsesDominatedByBlock(unsigned Reg, MachineBasicBlock *MBB) const;
5151 };
52
53 char MachineSinking::ID = 0;
54 RegisterPass X("machine-sink", "Machine code sinking");
5552 } // end anonymous namespace
53
54 char MachineSinking::ID = 0;
55 static RegisterPass
56 X("machine-sink", "Machine code sinking");
5657
5758 FunctionPass *llvm::createMachineSinkingPass() { return new MachineSinking(); }
5859
3434 const TargetAsmInfo &TAI);
3535 };
3636
37 CollectorRegistry::Add
38 X("ocaml", "ocaml 3.10-compatible collector");
39
4037 }
38
39 static CollectorRegistry::Add
40 X("ocaml", "ocaml 3.10-compatible collector");
4141
4242 // -----------------------------------------------------------------------------
4343
7272 // Defs of PHI sources which are implicit_def.
7373 SmallPtrSet ImpDefs;
7474 };
75
76 char PNE::ID = 0;
77 RegisterPass X("phi-node-elimination",
78 "Eliminate PHI nodes for register allocation");
79 }
75 }
76
77 char PNE::ID = 0;
78 static RegisterPass
79 X("phi-node-elimination", "Eliminate PHI nodes for register allocation");
8080
8181 const PassInfo *llvm::PHIEliminationID = X.getPassInfo();
8282
2929 /// RegAlloc command line options.
3030 ///
3131 //===---------------------------------------------------------------------===//
32 namespace {
33 static
34 cl::opt
35 RegisterPassParser >
36 RegAlloc("regalloc",
37 cl::init(&createLinearScanRegisterAllocator),
38 cl::desc("Register allocator to use: (default = linearscan)"));
39 }
32 static cl::opt
33 RegisterPassParser >
34 RegAlloc("regalloc",
35 cl::init(&createLinearScanRegisterAllocator),
36 cl::desc("Register allocator to use: (default = linearscan)"));
4037
4138
4239 //===---------------------------------------------------------------------===//
5151 STATISTIC(NumLoads , "Number of loads added");
5252 STATISTIC(NumFolded, "Number of loads/stores folded into instructions");
5353
54 static RegisterRegAlloc
55 bigBlockRegAlloc("bigblock", " Big-block register allocator",
56 createBigBlockRegisterAllocator);
57
5458 namespace {
55 static RegisterRegAlloc
56 bigBlockRegAlloc("bigblock", " Big-block register allocator",
57 createBigBlockRegisterAllocator);
58
5959 /// VRegKeyInfo - Defines magic values required to use VirtRegs as DenseMap
6060 /// keys.
6161 struct VRegKeyInfo {
3636 STATISTIC(NumStores, "Number of stores added");
3737 STATISTIC(NumLoads , "Number of loads added");
3838
39 static RegisterRegAlloc
40 localRegAlloc("local", " local register allocator",
41 createLocalRegisterAllocator);
42
3943 namespace {
40 static RegisterRegAlloc
41 localRegAlloc("local", " local register allocator",
42 createLocalRegisterAllocator);
43
44
4544 class VISIBILITY_HIDDEN RALocal : public MachineFunctionPass {
4645 public:
4746 static char ID;
2121 using namespace llvm;
2222
2323 // Register the RegisterCoalescer interface, providing a nice name to refer to.
24 namespace {
25 RegisterAnalysisGroup Z("Register Coalescer");
26 }
24 static RegisterAnalysisGroup Z("Register Coalescer");
2725 char RegisterCoalescer::ID = 0;
2826
2927 // RegisterCoalescer destructor: DO NOT move this to the header file
317317
318318 /// AddNodeIDValueTypes - Value type lists are intern'd so we can represent them
319319 /// solely with their pointer.
320 void AddNodeIDValueTypes(FoldingSetNodeID &ID, SDVTList VTList) {
320 static void AddNodeIDValueTypes(FoldingSetNodeID &ID, SDVTList VTList) {
321321 ID.AddPointer(VTList.VTs);
322322 }
323323
7373 /// ISHeuristic command line option for instruction schedulers.
7474 ///
7575 //===---------------------------------------------------------------------===//
76 namespace {
77 static cl::opt
78 RegisterPassParser >
79 ISHeuristic("pre-RA-sched",
80 cl::init(&createDefaultScheduler),
81 cl::desc("Instruction schedulers available (before register"
82 " allocation):"));
83
84 static RegisterScheduler
85 defaultListDAGScheduler("default", " Best scheduler for the target",
86 createDefaultScheduler);
87 } // namespace
76 static cl::opt
77 RegisterPassParser >
78 ISHeuristic("pre-RA-sched",
79 cl::init(&createDefaultScheduler),
80 cl::desc("Instruction schedulers available (before register"
81 " allocation):"));
82
83 static RegisterScheduler
84 defaultListDAGScheduler("default", " Best scheduler for the target",
85 createDefaultScheduler);
8886
8987 namespace { struct SDISelAsmOperandInfo; }
9088
6565 static GetElementPtrInst *CreateGEP(IRBuilder &B, Value *BasePtr,
6666 int Idx1, int Idx2, const char *Name);
6767 };
68
69 CollectorRegistry::Add
70 Y("shadow-stack",
71 "Very portable collector for uncooperative code generators");
72
68
69 }
70
71 static CollectorRegistry::Add
72 Y("shadow-stack",
73 "Very portable collector for uncooperative code generators");
74
75 namespace {
7376 /// EscapeEnumerator - This is a little algorithm to find all escape points
7477 /// from a function so that "finally"-style code can be inserted. In addition
7578 /// to finding the existing return and unwind instructions, it also (if
4141 STATISTIC(numAborts , "Number of times interval joining aborted");
4242
4343 char SimpleRegisterCoalescing::ID = 0;
44 namespace {
45 static cl::opt
46 EnableJoining("join-liveintervals",
47 cl::desc("Coalesce copies (default=true)"),
48 cl::init(true));
49
50 static cl::opt
51 NewHeuristic("new-coalescer-heuristic",
52 cl::desc("Use new coalescer heuristic"),
53 cl::init(false));
54
55 RegisterPass
56 X("simple-register-coalescing", "Simple Register Coalescing");
57
58 // Declare that we implement the RegisterCoalescer interface
59 RegisterAnalysisGroup V(X);
60 }
44 static cl::opt
45 EnableJoining("join-liveintervals",
46 cl::desc("Coalesce copies (default=true)"),
47 cl::init(true));
48
49 static cl::opt
50 NewHeuristic("new-coalescer-heuristic",
51 cl::desc("Use new coalescer heuristic"),
52 cl::init(false));
53
54 static RegisterPass
55 X("simple-register-coalescing", "Simple Register Coalescing");
56
57 // Declare that we implement the RegisterCoalescer interface
58 static RegisterAnalysisGroup V(X);
6159
6260 const PassInfo *llvm::SimpleRegisterCoalescingID = X.getPassInfo();
6361
139139 SmallPtrSet& v);
140140 void mergeLiveIntervals(unsigned primary, unsigned secondary, unsigned VN);
141141 };
142
143 char StrongPHIElimination::ID = 0;
144 RegisterPass X("strong-phi-node-elimination",
145 "Eliminate PHI nodes for register allocation, intelligently");
146 }
142 }
143
144 char StrongPHIElimination::ID = 0;
145 static RegisterPass
146 X("strong-phi-node-elimination",
147 "Eliminate PHI nodes for register allocation, intelligently");
147148
148149 const PassInfo *llvm::StrongPHIEliminationID = X.getPassInfo();
149150
191192 }
192193 }
193194
195 namespace {
196
194197 /// PreorderSorter - a helper class that is used to sort registers
195198 /// according to the preorder number of their defining blocks
196199 class PreorderSorter {
217220 return false;
218221 }
219222 };
223
224 }
220225
221226 /// computeDomForest - compute the subforest of the DomTree corresponding
222227 /// to the defining blocks of the registers in question
7474 /// runOnMachineFunction - Pass entry point.
7575 bool runOnMachineFunction(MachineFunction&);
7676 };
77
78 char TwoAddressInstructionPass::ID = 0;
79 RegisterPass
80 X("twoaddressinstruction", "Two-Address instruction pass");
8177 }
78
79 char TwoAddressInstructionPass::ID = 0;
80 static RegisterPass
81 X("twoaddressinstruction", "Two-Address instruction pass");
8282
8383 const PassInfo *llvm::TwoAddressInstructionPassID = X.getPassInfo();
8484
3737 static char ID; // Pass identification, replacement for typeid
3838 UnreachableBlockElim() : FunctionPass((intptr_t)&ID) {}
3939 };
40 char UnreachableBlockElim::ID = 0;
41 RegisterPass
42 X("unreachableblockelim", "Remove unreachable blocks from the CFG");
4340 }
41 char UnreachableBlockElim::ID = 0;
42 static RegisterPass
43 X("unreachableblockelim", "Remove unreachable blocks from the CFG");
4444
4545 FunctionPass *llvm::createUnreachableBlockEliminationPass() {
4646 return new UnreachableBlockElim();
4747
4848 namespace {
4949 enum SpillerName { simple, local };
50
51 static cl::opt
52 SpillerOpt("spiller",
53 cl::desc("Spiller to use: (default: local)"),
54 cl::Prefix,
55 cl::values(clEnumVal(simple, " simple spiller"),
56 clEnumVal(local, " local spiller"),
57 clEnumValEnd),
58 cl::init(local));
59 }
50 }
51
52 static cl::opt
53 SpillerOpt("spiller",
54 cl::desc("Spiller to use: (default: local)"),
55 cl::Prefix,
56 cl::values(clEnumVal(simple, " simple spiller"),
57 clEnumVal(local, " local spiller"),
58 clEnumValEnd),
59 cl::init(local));
6060
6161 //===----------------------------------------------------------------------===//
6262 // VirtRegMap implementation
2020 #include
2121 using namespace llvm;
2222
23 namespace {
24
2325 static struct RegisterInterp {
2426 RegisterInterp() { Interpreter::Register(); }
2527 } InterpRegistrator;
28
29 }
2630
2731 namespace llvm {
2832 void LinkInInterpreter() {
5151 extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
5252 #endif
5353
54 namespace {
55
5456 static struct RegisterJIT {
5557 RegisterJIT() { JIT::Register(); }
5658 } JITRegistrator;
59
60 }
5761
5862 namespace llvm {
5963 void LinkInJIT() {
171171 return LSize < RSize;
172172 }
173173
174 namespace {
175
174176 struct KeyInfo {
175177 static inline unsigned getEmptyKey() { return -1U; }
176178 static inline unsigned getTombstoneKey() { return -2U; }
203205 unsigned PadLabel; // zero indicates that there is no landing pad.
204206 unsigned Action;
205207 };
208
209 }
206210
207211 unsigned char* JITDwarfEmitter::EmitExceptionTable(MachineFunction* MF,
208212 unsigned char* StartFunction,
6969 Initialized = true;
7070 }
7171
72 namespace {
73
7274 struct NameCompare {
7375 bool operator()(const Statistic *LHS, const Statistic *RHS) const {
7476 int Cmp = std::strcmp(LHS->getName(), RHS->getName());
7880 return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0;
7981 }
8082 };
83
84 }
8185
8286 // Print information when destroyed, iff command line option is specified.
8387 StatisticInfo::~StatisticInfo() {
6969 /// string and the Unix error number given by \p errnum. If errnum is -1, the
7070 /// default then the value of errno is used.
7171 /// @brief Make an error message
72 inline bool MakeErrMsg(
72 static inline bool MakeErrMsg(
7373 std::string* ErrMsg, const std::string& prefix, int errnum = -1) {
7474 if (!ErrMsg)
7575 return true;
2626 static cl::opt DisableIfConversion("disable-arm-if-conversion",cl::Hidden,
2727 cl::desc("Disable if-conversion pass"));
2828
29 namespace {
30 // Register the target.
31 RegisterTarget X("arm", " ARM");
32 RegisterTarget Y("thumb", " Thumb");
33 }
29 // Register the target.
30 static RegisterTarget X("arm", " ARM");
31 static RegisterTarget Y("thumb", " Thumb");
3432
3533 /// ThumbTargetMachine - Create an Thumb architecture model.
3634 ///
1919
2020 using namespace llvm;
2121
22 namespace {
23 // Register the targets
24 RegisterTarget X("alpha", " Alpha (incomplete)");
25 }
22 // Register the targets
23 static RegisterTarget X("alpha", " Alpha (incomplete)");
2624
2725 const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
2826 return new AlphaTargetAsmInfo(*this);
4646 #include
4747 using namespace llvm;
4848
49 // Register the target.
50 static RegisterTarget X("c", " C backend");
51
4952 namespace {
50 // Register the target.
51 RegisterTarget X("c", " C backend");
52
5353 /// CBackendNameAllUsedStructsAndMergeFunctions - This pass inserts names for
5454 /// any unnamed structure types that are used by the program, and merges
5555 /// external functions with the same name.
213213 }
214214 }
215215
216 namespace {
217
216218 //===--------------------------------------------------------------------===//
217219 /// SPUDAGToDAGISel - Cell SPU-specific code to select SPU machine
218220 /// instructions for SelectionDAG operations.
335337 #include "SPUGenDAGISel.inc"
336338 };
337339
340 }
341
338342 /// InstructionSelectBasicBlock - This callback is invoked by
339343 /// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
340344 void
6969 cl::desc("Specify the name of the thing to generate"),
7070 cl::init("!bad!"));
7171
72 // Register the target.
73 static RegisterTarget X("cpp", " C++ backend");
74
7275 namespace {
73 // Register the target.
74 RegisterTarget X("cpp", " C++ backend");
75
7676 typedef std::vector TypeList;
7777 typedef std::map TypeMap;
7878 typedef std::map ValueMap;
2525 extern "C" int IA64TargetMachineModule;
2626 int IA64TargetMachineModule = 0;
2727
28 namespace {
29 RegisterTarget X("ia64", " IA-64 (Itanium)");
30 }
28 static RegisterTarget X("ia64", " IA-64 (Itanium)");
3129
3230 const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
3331 return new IA64TargetAsmInfo(*this);
4545 }
4646
4747
48 RegisterTarget X("msil", " MSIL backend");
48 static RegisterTarget X("msil", " MSIL backend");
4949
5050 bool MSILModule::runOnModule(Module &M) {
5151 ModulePtr = &M;
1818 #include "llvm/Target/TargetMachineRegistry.h"
1919 using namespace llvm;
2020
21 namespace {
22 // Register the target.
23 RegisterTarget X("mips", " Mips");
24 }
21 // Register the target.
22 static RegisterTarget X("mips", " Mips");
2523
2624 const TargetAsmInfo *MipsTargetMachine::
2725 createTargetAsmInfo() const
19191919 DAG.getTargetLoweringInfo().getPointerTy()).Val;
19201920 }
19211921
1922 namespace {
1923
19221924 struct TailCallArgumentInfo {
19231925 SDOperand Arg;
19241926 SDOperand FrameIdxOp;
19261928
19271929 TailCallArgumentInfo() : FrameIdx(0) {}
19281930 };
1931
1932 }
19291933
19301934 /// StoreTailCallArgumentsToStackSlot - Stores arguments to their stack slot.
19311935 static void
1818 #include "llvm/Target/TargetMachineRegistry.h"
1919 using namespace llvm;
2020
21 namespace {
22 // Register the targets
23 RegisterTarget
24 X("ppc32", " PowerPC 32");
25 RegisterTarget
26 Y("ppc64", " PowerPC 64");
27 }
21 // Register the targets
22 static RegisterTarget
23 X("ppc32", " PowerPC 32");
24 static RegisterTarget
25 Y("ppc64", " PowerPC 64");
2826
2927 const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const {
3028 if (Subtarget.isDarwin())
1717 #include "llvm/Target/TargetMachineRegistry.h"
1818 using namespace llvm;
1919
20 namespace {
21 // Register the target.
22 RegisterTarget X("sparc", " SPARC");
23 }
20 // Register the target.
21 static RegisterTarget X("sparc", " SPARC");
2422
2523 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
2624 return new SparcTargetAsmInfo(*this);
2929 using namespace llvm;
3030
3131 // Handle the Pass registration stuff necessary to use TargetData's.
32 namespace {
33 // Register the default SparcV9 implementation...
34 RegisterPass X("targetdata", "Target Data Layout", false,
35 true);
36 }
32
33 // Register the default SparcV9 implementation...
34 static RegisterPass X("targetdata", "Target Data Layout", false,
35 true);
3736 char TargetData::ID = 0;
3837
3938 //===----------------------------------------------------------------------===//
317316 : Alignments[BestMatchIdx].PrefAlign;
318317 }
319318
319 namespace {
320
320321 /// LayoutInfo - The lazy cache of structure layout information maintained by
321322 /// TargetData. Note that the struct types must have been free'd before
322323 /// llvm_shutdown is called (and thus this is deallocated) because all the
341342 };
342343
343344 typedef DenseMap LayoutInfoTy;
345
346 }
347
344348 static ManagedStatic LayoutInfo;
345
346349
347350 TargetData::~TargetData() {
348351 if (LayoutInfo.isConstructed()) {
3838 bool RealignStack;
3939 unsigned StackAlignment;
4040 }
41 namespace {
42 static cl::opt PrintCode("print-machineinstrs",
43 cl::desc("Print generated machine code"),
44 cl::location(PrintMachineCode), cl::init(false));
4541
46 static cl::opt
47 DisableFPElim("disable-fp-elim",
48 cl::desc("Disable frame pointer elimination optimization"),
49 cl::location(NoFramePointerElim),
50 cl::init(false));
51 static cl::opt
52 DisableExcessPrecision("disable-excess-fp-precision",
53 cl::desc("Disable optimizations that may increase FP precision"),
54 cl::location(NoExcessFPPrecision),
55 cl::init(false));
56 static cl::opt
57 EnableUnsafeFPMath("enable-unsafe-fp-math",
58 cl::desc("Enable optimizations that may decrease FP precision"),
59 cl::location(UnsafeFPMath),
60 cl::init(false));
61 static cl::opt
62 EnableFiniteOnlyFPMath("enable-finite-only-fp-math",
63 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
64 cl::location(FiniteOnlyFPMathOption),
65 cl::init(false));
66 static cl::opt
67 EnableHonorSignDependentRoundingFPMath(cl::Hidden,
68 "enable-sign-dependent-rounding-fp-math",
69 cl::desc("Force codegen to assume rounding mode can change dynamically"),
70 cl::location(HonorSignDependentRoundingFPMathOption),
71 cl::init(false));
42 static cl::opt PrintCode("print-machineinstrs",
43 cl::desc("Print generated machine code"),
44 cl::location(PrintMachineCode), cl::init(false));
7245
73 static cl::opt
74 GenerateSoftFloatCalls("soft-float",
75 cl::desc("Generate software floating point library calls"),
76 cl::location(UseSoftFloat),
77 cl::init(false));
78 static cl::opt
79 DontPlaceZerosInBSS("nozero-initialized-in-bss",
80 cl::desc("Don't place zero-initialized symbols into bss section"),
81 cl::location(NoZerosInBSS),
82 cl::init(false));
83 static cl::opt
84 EnableExceptionHandling("enable-eh",
85 cl::desc("Emit DWARF exception handling (default if target supports)"),
86 cl::location(ExceptionHandling),
87 cl::init(false));
88 static cl::opt
89 EnableUnwindTables("unwind-tables",
90 cl::desc("Generate unwinding tables for all functions"),
91 cl::location(UnwindTablesMandatory),
92 cl::init(false));
46 static cl::opt
47 DisableFPElim("disable-fp-elim",
48 cl::desc("Disable frame pointer elimination optimization"),
49 cl::location(NoFramePointerElim),
50 cl::init(false));
51 static cl::opt
52 DisableExcessPrecision("disable-excess-fp-precision",
53 cl::desc("Disable optimizations that may increase FP precision"),
54 cl::location(NoExcessFPPrecision),
55 cl::init(false));
56 static cl::opt
57 EnableUnsafeFPMath("enable-unsafe-fp-math",
58 cl::desc("Enable optimizations that may decrease FP precision"),
59 cl::location(UnsafeFPMath),
60 cl::init(false));
61 static cl::opt
62 EnableFiniteOnlyFPMath("enable-finite-only-fp-math",
63 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
64 cl::location(FiniteOnlyFPMathOption),
65 cl::init(false));
66 static cl::opt
67 EnableHonorSignDependentRoundingFPMath(cl::Hidden,
68 "enable-sign-dependent-rounding-fp-math",
69 cl::desc("Force codegen to assume rounding mode can change dynamically"),
70 cl::location(HonorSignDependentRoundingFPMathOption),
71 cl::init(false));
9372
94 static cl::opt
95 DefRelocationModel(
96 "relocation-model",
97 cl::desc("Choose relocation model"),
98 cl::location(RelocationModel),
99 cl::init(Reloc::Default),
100 cl::values(
101 clEnumValN(Reloc::Default, "default",
102 " Target default relocation model"),
103 clEnumValN(Reloc::Static, "static",
104 " Non-relocatable code"),
105 clEnumValN(Reloc::PIC_, "pic",
106 " Fully relocatable, position independent code"),
107 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
108 " Relocatable external references, non-relocatable code"),
109 clEnumValEnd));
110 static cl::opt
111 DefCodeModel(
112 "code-model",
113 cl::desc("Choose code model"),
114 cl::location(CMModel),
115 cl::init(CodeModel::Default),
116 cl::values(
117 clEnumValN(CodeModel::Default, "default",
118 " Target default code model"),
119 clEnumValN(CodeModel::Small, "small",
120 " Small code model"),
121 clEnumValN(CodeModel::Kernel, "kernel",
122 " Kernel code model"),
123 clEnumValN(CodeModel::Medium, "medium",
124 " Medium code model"),
125 clEnumValN(CodeModel::Large, "large",
126 " Large code model"),
127 clEnumValEnd));
73 static cl::opt
74 GenerateSoftFloatCalls("soft-float",
75 cl::desc("Generate software floating point library calls"),
76 cl::location(UseSoftFloat),
77 cl::init(false));
78 static cl::opt
79 DontPlaceZerosInBSS("nozero-initialized-in-bss",
80 cl::desc("Don't place zero-initialized symbols into bss section"),
81 cl::location(NoZerosInBSS),
82 cl::init(false));
83 static cl::opt
84 EnableExceptionHandling("enable-eh",
85 cl::desc("Emit DWARF exception handling (default if target supports)"),
86 cl::location(ExceptionHandling),
87 cl::init(false));
88 static cl::opt
89 EnableUnwindTables("unwind-tables",
90 cl::desc("Generate unwinding tables for all functions"),
91 cl::location(UnwindTablesMandatory),
92 cl::init(false));
12893
129 static cl::opt
130 EnablePerformTailCallOpt("tailcallopt",
131 cl::desc("Turn on tail call optimization."),
132 cl::location(PerformTailCallOpt),
133 cl::init(false));
134 static cl::opt
135 EnableOptimizeForSize("optimize-size",
136 cl::desc("Optimize for size."),
137 cl::location(OptimizeForSize),
138 cl::init(false));
94 static cl::opt
95 DefRelocationModel(
96 "relocation-model",
97 cl::desc("Choose relocation model"),
98 cl::location(RelocationModel),
99 cl::init(Reloc::Default),
100 cl::values(
101 clEnumValN(Reloc::Default, "default",
102 " Target default relocation model"),
103 clEnumValN(Reloc::Static, "static",
104 " Non-relocatable code"),
105 clEnumValN(Reloc::PIC_, "pic",
106 " Fully relocatable, position independent code"),
107 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
108 " Relocatable external references, non-relocatable code"),
109 clEnumValEnd));
110 static cl::opt
111 DefCodeModel(
112 "code-model",
113 cl::desc("Choose code model"),
114 cl::location(CMModel),
115 cl::init(CodeModel::Default),
116 cl::values(
117 clEnumValN(CodeModel::Default, "default",
118 " Target default code model"),
119 clEnumValN(CodeModel::Small, "small",
120 " Small code model"),
121 clEnumValN(CodeModel::Kernel, "kernel",
122 " Kernel code model"),
123 clEnumValN(CodeModel::Medium, "medium",
124 " Medium code model"),
125 clEnumValN(CodeModel::Large, "large",
126 " Large code model"),
127 clEnumValEnd));
139128
140 static cl::opt
141 EnableRealignStack("realign-stack",
142 cl::desc("Realign stack if needed"),
143 cl::location(RealignStack),
144 cl::init(true));
129 static cl::opt
130 EnablePerformTailCallOpt("tailcallopt",
131 cl::desc("Turn on tail call optimization."),
132 cl::location(PerformTailCallOpt),
133 cl::init(false));
134 static cl::opt
135 EnableOptimizeForSize("optimize-size",
136 cl::desc("Optimize for size."),
137 cl::location(OptimizeForSize),
138 cl::init(false));
145139
146 static cl::opt
147 OverrideStackAlignment("stack-alignment",
148 cl::desc("Override default stack alignment"),
149 cl::location(StackAlignment),
150 cl::init(0));
151 }
140 static cl::opt
141 EnableRealignStack("realign-stack",
142 cl::desc("Realign stack if needed"),
143 cl::location(RealignStack),
144 cl::init(true));
145
146 static cl::opt
147 OverrideStackAlignment("stack-alignment",
148 cl::desc("Override default stack alignment"),
149 cl::location(StackAlignment),
150 cl::init(0));
152151
153152 //---------------------------------------------------------------------------
154153 // TargetMachine Class
1818 #include "llvm/Target/TargetOptions.h"
1919 using namespace llvm;
2020
21 cl::opt
21 static cl::opt
2222 AsmWriterFlavor("x86-asm-syntax", cl::init(X86Subtarget::Unset),
2323 cl::desc("Choose style of code to emit from X86 backend:"),
2424 cl::values(
2929 extern "C" int X86TargetMachineModule;
3030 int X86TargetMachineModule = 0;
3131
32 namespace {
33 // Register the target.
34 RegisterTarget
35 X("x86", " 32-bit X86: Pentium-Pro and above");
36 RegisterTarget
37 Y("x86-64", " 64-bit X86: EM64T and AMD64");
38 }
32 // Register the target.
33 static RegisterTarget
34 X("x86", " 32-bit X86: Pentium-Pro and above");
35 static RegisterTarget
36 Y("x86-64", " 64-bit X86: EM64T and AMD64");
3937
4038 const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const {
4139 return new X86TargetAsmInfo(*this);
3535 return false;
3636 }
3737 };
38 }
3839
39 char Hello::ID = 0;
40 RegisterPass X("hello", "Hello World Pass");
40 char Hello::ID = 0;
41 static RegisterPass X("hello", "Hello World Pass");
4142
43 namespace {
4244 // Hello2 - The second implementation with getAnalysisUsage implemented.
4345 struct Hello2 : public FunctionPass {
4446 static char ID; // Pass identification, replacement for typeid
5759 AU.setPreservesAll();
5860 };
5961 };
60 char Hello2::ID = 0;
61 RegisterPass Y("hello2",
62 "Hello World Pass (with getAnalysisUsage implemented)");
6362 }
63
64 char Hello2::ID = 0;
65 static RegisterPass
66 Y("hello2", "Hello World Pass (with getAnalysisUsage implemented)");
7676 /// The maximum number of elements to expand, or 0 for unlimited.
7777 unsigned maxElements;
7878 };
79
80 char ArgPromotion::ID = 0;
81 RegisterPass X("argpromotion",
82 "Promote 'by reference' arguments to scalars");
83 }
79 }
80
81 char ArgPromotion::ID = 0;
82 static RegisterPass
83 X("argpromotion", "Promote 'by reference' arguments to scalars");
8484
8585 Pass *llvm::createArgumentPromotionPass(unsigned maxElements) {
8686 return new ArgPromotion(maxElements);
3737 //
3838 bool runOnModule(Module &M);
3939 };
40 }
4041
41 char ConstantMerge::ID = 0;
42 RegisterPassX("constmerge","Merge Duplicate Global Constants");
43 }
42 char ConstantMerge::ID = 0;
43 static RegisterPass
44 X("constmerge", "Merge Duplicate Global Constants");
4445
4546 ModulePass *llvm::createConstantMergePass() { return new ConstantMerge(); }
4647
9696
9797 void RemoveDeadArgumentsFromFunction(Function *F);
9898 };
99 char DAE::ID = 0;
100 RegisterPass X("deadargelim", "Dead Argument Elimination");
101
99 }
100
101 char DAE::ID = 0;
102 static RegisterPass
103 X("deadargelim", "Dead Argument Elimination");
104
105 namespace {
102106 /// DAH - DeadArgumentHacking pass - Same as dead argument elimination, but
103107 /// deletes arguments to functions which are external. This is only for use
104108 /// by bugpoint.
106110 static char ID;
107111 virtual bool ShouldHackArguments() const { return true; }
108112 };
109 char DAH::ID = 0;
110 RegisterPass Y("deadarghaX0r",
111 "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)");
112 }
113 }
114
115 char DAH::ID = 0;
116 static RegisterPass
117 Y("deadarghaX0r", "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)");
113118
114119 /// createDeadArgEliminationPass - This pass removes arguments from functions
115120 /// which are not used by the body of the function.
4242 AU.addRequired();
4343 }
4444 };
45 char DTE::ID = 0;
46 RegisterPass X("deadtypeelim", "Dead Type Elimination");
4745 }
46
47 char DTE::ID = 0;
48 static RegisterPass X("deadtypeelim", "Dead Type Elimination");
4849
4950 ModulePass *llvm::createDeadTypeEliminationPass() {
5051 return new DTE();
4848 bool SafeToDestroyConstant(Constant* C);
4949 bool RemoveUnusedGlobalValue(GlobalValue &GV);
5050 };
51 char GlobalDCE::ID = 0;
52 RegisterPass X("globaldce", "Dead Global Elimination");
53 }
51 }
52
53 char GlobalDCE::ID = 0;
54 static RegisterPass X("globaldce", "Dead Global Elimination");
5455
5556 ModulePass *llvm::createGlobalDCEPass() { return new GlobalDCE(); }
5657
6767 bool OptimizeGlobalCtorsList(GlobalVariable *&GCL);
6868 bool ProcessInternalGlobal(GlobalVariable *GV,Module::global_iterator &GVI);
6969 };
70
71 char GlobalOpt::ID = 0;
72 RegisterPass X("globalopt", "Global Variable Optimizer");
73 }
70 }
71
72 char GlobalOpt::ID = 0;
73 static RegisterPass X("globalopt", "Global Variable Optimizer");
7474
7575 ModulePass *llvm::createGlobalOptimizerPass() { return new GlobalOpt(); }
76
77 namespace {
7678
7779 /// GlobalStatus - As we analyze each global, keep track of some information
7880 /// about it. If we find out that the address of the global is taken, none of
128130 HasNonInstructionUser(false), HasPHIUser(false) {}
129131 };
130132
131
133 }
132134
133135 /// ConstantIsDead - Return true if the specified constant is (transitively)
134136 /// dead. The constant may be used by other constants (e.g. constant arrays and
4141 bool PropagateConstantsIntoArguments(Function &F);
4242 bool PropagateConstantReturn(Function &F);
4343 };
44 char IPCP::ID = 0;
45 RegisterPass X("ipconstprop", "Interprocedural constant propagation");
46 }
44 }
45
46 char IPCP::ID = 0;
47 static RegisterPass
48 X("ipconstprop", "Interprocedural constant propagation");
4749
4850 ModulePass *llvm::createIPConstantPropagationPass() { return new IPCP(); }
4951
3636
3737 virtual bool runOnModule(Module &M);
3838 };
39 char IndMemRemPass::ID = 0;
40 RegisterPass X("indmemrem","Indirect Malloc and Free Removal");
4139 } // end anonymous namespace
4240
41 char IndMemRemPass::ID = 0;
42 static RegisterPass
43 X("indmemrem","Indirect Malloc and Free Removal");
4344
4445 bool IndMemRemPass::runOnModule(Module &M) {
4546 //in Theory, all direct calls of malloc and free should be promoted
4444 }
4545 virtual bool doInitialization(CallGraph &CG);
4646 };
47 char SimpleInliner::ID = 0;
48 RegisterPass X("inline", "Function Integration/Inlining");
4947 }
48
49 char SimpleInliner::ID = 0;
50 static RegisterPass
51 X("inline", "Function Integration/Inlining");
5052
5153 Pass *llvm::createFunctionInliningPass() { return new SimpleInliner(); }
5254
2929 STATISTIC(NumInlined, "Number of functions inlined");
3030 STATISTIC(NumDeleted, "Number of functions deleted because all callers found");
3131
32 namespace {
33 static cl::opt
34 InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
32 static cl::opt
33 InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
3534 cl::desc("Control the amount of inlining to perform (default = 200)"));
36 }
3735
3836 Inliner::Inliner(const void *ID)
3937 : CallGraphSCCPass((intptr_t)ID), InlineThreshold(InlineLimit) {}
2727 STATISTIC(NumFunctions, "Number of functions internalized");
2828 STATISTIC(NumGlobals , "Number of global vars internalized");
2929
30 // APIFile - A file which contains a list of symbols that should not be marked
31 // external.
32 static cl::opt
33 APIFile("internalize-public-api-file", cl::value_desc("filename"),
34 cl::desc("A file containing list of symbol names to preserve"));
35
36 // APIList - A list of symbols that should not be marked internal.
37 static cl::list
38 APIList("internalize-public-api-list", cl::value_desc("list"),
39 cl::desc("A list of symbol names to preserve"),
40 cl::CommaSeparated);
41
3042 namespace {
31
32 // APIFile - A file which contains a list of symbols that should not be marked
33 // external.
34 static cl::opt
35 APIFile("internalize-public-api-file", cl::value_desc("filename"),
36 cl::desc("A file containing list of symbol names to preserve"));
37
38 // APIList - A list of symbols that should not be marked internal.
39 static cl::list
40 APIList("internalize-public-api-list", cl::value_desc("list"),
41 cl::desc("A list of symbol names to preserve"),
42 cl::CommaSeparated);
43
4443 class VISIBILITY_HIDDEN InternalizePass : public ModulePass {
4544 std::set ExternalNames;
4645 bool DontInternalize;
5150 void LoadFile(const char *Filename);
5251 virtual bool runOnModule(Module &M);
5352 };
54 char InternalizePass::ID = 0;
55 RegisterPass X("internalize", "Internalize Global Symbols");
5653 } // end anonymous namespace
54
55 char InternalizePass::ID = 0;
56 static RegisterPass
57 X("internalize", "Internalize Global Symbols");
5758
5859 InternalizePass::InternalizePass(bool InternalizeEverything)
5960 : ModulePass((intptr_t)&ID), DontInternalize(false){
5151 AU.addRequired();
5252 }
5353 };
54
55 char LoopExtractor::ID = 0;
56 RegisterPass
57 X("loop-extract", "Extract loops into new functions");
58
54 }
55
56 char LoopExtractor::ID = 0;
57 static RegisterPass
58 X("loop-extract", "Extract loops into new functions");
59
60 namespace {
5961 /// SingleLoopExtractor - For bugpoint.
6062 struct SingleLoopExtractor : public LoopExtractor {
6163 static char ID; // Pass identification, replacement for typeid
6264 SingleLoopExtractor() : LoopExtractor(1) {}
6365 };
64
65 char SingleLoopExtractor::ID = 0;
66 RegisterPass
67 Y("loop-extract-single", "Extract at most one loop into a new function");
6866 } // End anonymous namespace
67
68 char SingleLoopExtractor::ID = 0;
69 static RegisterPass
70 Y("loop-extract-single", "Extract at most one loop into a new function");
6971
7072 // createLoopExtractorPass - This pass extracts all natural loops from the
7173 // program into a function if it can.
145147 }
146148
147149
150 // BlockFile - A file which contains a list of blocks that should not be
151 // extracted.
152 static cl::opt
153 BlockFile("extract-blocks-file", cl::value_desc("filename"),
154 cl::desc("A file containing list of basic blocks to not extract"),
155 cl::Hidden);
156
148157 namespace {
149 // BlockFile - A file which contains a list of blocks that should not be
150 // extracted.
151 static cl::opt
152 BlockFile("extract-blocks-file", cl::value_desc("filename"),
153 cl::desc("A file containing list of basic blocks to not extract"),
154 cl::Hidden);
155
156158 /// BlockExtractorPass - This pass is used by bugpoint to extract all blocks
157159 /// from the module into their own functions except for those specified by the
158160 /// BlocksToNotExtract list.
172174
173175 bool runOnModule(Module &M);
174176 };
175
176 char BlockExtractorPass::ID = 0;
177 RegisterPass
178 XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)");
179 }
177 }
178
179 char BlockExtractorPass::ID = 0;
180 static RegisterPass
181 XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)");
180182
181183 // createBlockExtractorPass - This pass extracts all blocks (except those
182184 // specified in the argument list) from the functions in the module.
121121 bool runOnModule(Module& M);
122122 bool doInitialization(Module& M);
123123 };
124
125 char LowerSetJmp::ID = 0;
126 RegisterPass X("lowersetjmp", "Lower Set Jump");
127124 } // end anonymous namespace
125
126 char LowerSetJmp::ID = 0;
127 static RegisterPass X("lowersetjmp", "Lower Set Jump");
128128
129129 // run - Run the transformation on the program. We grab the function
130130 // prototypes for longjmp and setjmp. If they are used in the program,
4242 bool SimplifyFunction(Function *F);
4343 void DeleteBasicBlock(BasicBlock *BB);
4444 };
45
46 char PruneEH::ID = 0;
47 RegisterPass X("prune-eh", "Remove unused exception handling info");
48 }
45 }
46
47 char PruneEH::ID = 0;
48 static RegisterPass
49 X("prune-eh", "Remove unused exception handling info");
4950
5051 Pass *llvm::createPruneEHPass() { return new PruneEH(); }
5152
4747 //
4848 bool runOnModule(Module &M);
4949 };
50
51 char RaiseAllocations::ID = 0;
52 RegisterPass
53 X("raiseallocs", "Raise allocations from calls to instructions");
5450 } // end anonymous namespace
5551
52 char RaiseAllocations::ID = 0;
53 static RegisterPass
54 X("raiseallocs", "Raise allocations from calls to instructions");
5655
5756 // createRaiseAllocationsPass - The interface to this file...
5857 ModulePass *llvm::createRaiseAllocationsPass() {
3333 virtual bool runOnModule(Module &M);
3434 };
3535
36 } // end anonymous namespace
37
3638 char StripDeadPrototypesPass::ID = 0;
37 RegisterPass X("strip-dead-prototypes",
38 "Strip Unused Function Prototypes");
39
40 } // end anonymous namespace
39 static RegisterPass
40 X("strip-dead-prototypes", "Strip Unused Function Prototypes");
4141
4242 bool StripDeadPrototypesPass::runOnModule(Module &M) {
4343 bool MadeChange = false;
4545 AU.setPreservesAll();
4646 }
4747 };
48
49 char StripSymbols::ID = 0;
50 RegisterPass X("strip", "Strip all symbols from a module");
51 }
48 }
49
50 char StripSymbols::ID = 0;
51 static RegisterPass
52 X("strip", "Strip all symbols from a module");
5253
5354 ModulePass *llvm::createStripSymbolsPass(bool OnlyDebugInfo) {
5455 return new StripSymbols(OnlyDebugInfo);
5757 void updateCallSites(Function *F, Function *NF);
5858 bool nestedStructType(const StructType *STy);
5959 };
60
61 char SRETPromotion::ID = 0;
62 RegisterPass X("sretpromotion",
63 "Promote sret arguments to multiple ret values");
64 }
60 }
61
62 char SRETPromotion::ID = 0;
63 static RegisterPass
64 X("sretpromotion", "Promote sret arguments to multiple ret values");
6565
6666 Pass *llvm::createStructRetPromotionPass() {
6767 return new SRETPromotion();
3535 static char ID;
3636 bool runOnModule(Module &M);
3737 };
38 }
3839
39 char FunctionProfiler::ID = 0;
40 char FunctionProfiler::ID = 0;
4041
41 RegisterPass X("insert-function-profiling",
42 "Insert instrumentation for function profiling");
43 RegisterAnalysisGroup XG(X);
44
45 }
42 static RegisterPass
43 X("insert-function-profiling",
44 "Insert instrumentation for function profiling");
45 static RegisterAnalysisGroup XG(X);
4646
4747 ModulePass *llvm::createFunctionProfilerPass() {
4848 return new FunctionProfiler();
8585 public:
8686 static char ID;
8787 };
88 }
8889
89 char BlockProfiler::ID = 0;
90 RegisterPass Y("insert-block-profiling",
91 "Insert instrumentation for block profiling");
92 RegisterAnalysisGroup YG(Y);
93 }
90 char BlockProfiler::ID = 0;
91 static RegisterPass
92 Y("insert-block-profiling", "Insert instrumentation for block profiling");
93 static RegisterAnalysisGroup YG(Y);
9494
9595 ModulePass *llvm::createBlockProfilerPass() { return new BlockProfiler(); }
9696
3535 static char ID; // Pass identification, replacement for typeid
3636 EdgeProfiler() : ModulePass((intptr_t)&ID) {}
3737 };
38 }
3839
39 char EdgeProfiler::ID = 0;
40 RegisterPass X("insert-edge-profiling",
41 "Insert instrumentation for edge profiling");
42 }
40 char EdgeProfiler::ID = 0;
41 static RegisterPass
42 X("insert-edge-profiling", "Insert instrumentation for edge profiling");
4343
4444 ModulePass *llvm::createEdgeProfilerPass() { return new EdgeProfiler(); }
4545
5454 enum RandomMeth {
5555 GBV, GBVO, HOSTCC
5656 };
57
58 static cl::opt RandomMethod("profile-randomness",
59 cl::desc("How to randomly choose to profile:"),
60 cl::values(
61 clEnumValN(GBV, "global", "global counter"),
62 clEnumValN(GBVO, "ra_global",
63 "register allocated global counter"),
64 clEnumValN(HOSTCC, "rdcc", "cycle counter"),
65 clEnumValEnd));
66
57 }
58
59 static cl::opt RandomMethod("profile-randomness",
60 cl::desc("How to randomly choose to profile:"),
61 cl::values(
62 clEnumValN(GBV, "global", "global counter"),
63 clEnumValN(GBVO, "ra_global",
64 "register allocated global counter"),
65 clEnumValN(HOSTCC, "rdcc", "cycle counter"),
66 clEnumValEnd));
67
68 namespace {
6769 /// NullProfilerRS - The basic profiler that does nothing. It is the default
6870 /// profiler and thus terminates RSProfiler chains. It is useful for
6971 /// measuring framework overhead
8082 AU.setPreservesAll();
8183 }
8284 };
83
84 static RegisterAnalysisGroup A("Profiling passes");
85 static RegisterPass NP("insert-null-profiling-rs",
86 "Measure profiling framework overhead");
87 static RegisterAnalysisGroup NPT(NP);
88
85 }
86
87 static RegisterAnalysisGroup A("Profiling passes");
88 static RegisterPass NP("insert-null-profiling-rs",
89 "Measure profiling framework overhead");
90 static RegisterAnalysisGroup NPT(NP);
91
92 namespace {
8993 /// Chooser - Something that chooses when to make a sample of the profiled code
9094 class VISIBILITY_HIDDEN Chooser {
9195 public:
157161 bool doInitialization(Module &M);
158162 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
159163 };
160
161 RegisterPass X("insert-rs-profiling-framework",
162 "Insert random sampling instrumentation framework");
163 }
164 }
165
166 static RegisterPass
167 X("insert-rs-profiling-framework",
168 "Insert random sampling instrumentation framework");
164169
165170 char RSProfilers::ID = 0;
166171 char NullProfilerRS::ID = 0;
105105 markInstructionLive(const_cast(BB->getTerminator()));
106106 }
107107 };
108
109 char ADCE::ID = 0;
110 RegisterPass X("adce", "Aggressive Dead Code Elimination");
111108 } // End of anonymous namespace
109
110 char ADCE::ID = 0;
111 static RegisterPass X("adce", "Aggressive Dead Code Elimination");
112112
113113 FunctionPass *llvm::createAggressiveDCEPass() { return new ADCE(); }
114114
7171 /// successors.
7272 void PlaceBlocks(BasicBlock *BB);
7373 };
74 }
7475
75 char BlockPlacement::ID = 0;
76 RegisterPass X("block-placement",
77 "Profile Guided Basic Block Placement");
78 }
76 char BlockPlacement::ID = 0;
77 static RegisterPass
78 X("block-placement", "Profile Guided Basic Block Placement");
7979
8080 FunctionPass *llvm::createBlockPlacementPass() { return new BlockPlacement(); }
8181
482482 }
483483 }
484484
485 namespace {
485486
486487 /// ExtAddrMode - This is an extended version of TargetLowering::AddrMode which
487488 /// holds actual Value*'s for register values.
514515
515516 void ExtAddrMode::dump() const {
516517 cerr << *this << "\n";
518 }
519
517520 }
518521
519522 static bool TryMatchingScaledValue(Value *ScaleReg, int64_t Scale,
4747 void SimplifyPredecessors(SwitchInst *SI);
4848 void RevectorBlockTo(BasicBlock *FromBB, BasicBlock *ToBB);
4949 };
50 }
5051
51 char CondProp::ID = 0;
52 RegisterPass X("condprop", "Conditional Propagation");
53 }
52 char CondProp::ID = 0;
53 static RegisterPass X("condprop", "Conditional Propagation");
5454
5555 FunctionPass *llvm::createCondPropagationPass() {
5656 return new CondProp();
4242 AU.setPreservesCFG();
4343 }
4444 };
45 }
4546
46 char ConstantPropagation::ID = 0;
47 RegisterPass X("constprop",
48 "Simple constant propagation");
49 }
47 char ConstantPropagation::ID = 0;
48 static RegisterPass
49 X("constprop", "Simple constant propagation");
5050
5151 FunctionPass *llvm::createConstantPropagationPass() {
5252 return new ConstantPropagation();
5151 AU.setPreservesCFG();
5252 }
5353 };
54 }
5455
55 char DeadInstElimination::ID = 0;
56 RegisterPass X("die", "Dead Instruction Elimination");
57 }
56 char DeadInstElimination::ID = 0;
57 static RegisterPass
58 X("die", "Dead Instruction Elimination");
5859
5960 Pass *llvm::createDeadInstEliminationPass() {
6061 return new DeadInstElimination();
7576 AU.setPreservesCFG();
7677 }
7778 };
79 }
7880
79 char DCE::ID = 0;
80 RegisterPass Y("dce", "Dead Code Elimination");
81 }
81 char DCE::ID = 0;
82 static RegisterPass Y("dce", "Dead Code Elimination");
8283
8384 bool DCE::runOnFunction(Function &F) {
8485 // Start out with all of the instructions in the worklist...
9191 AU.addPreserved();
9292 }
9393 };
94 char DSE::ID = 0;
95 RegisterPass X("dse", "Dead Store Elimination");
9694 }
95
96 char DSE::ID = 0;
97 static RegisterPass X("dse", "Dead Store Elimination");
9798
9899 FunctionPass *llvm::createDeadStoreEliminationPass() { return new DSE(); }
99100
5151 AU.addRequired();
5252 }
5353 };
54
55 char GCSE::ID = 0;
56 RegisterPass X("gcse", "Global Common Subexpression Elimination");
5754 }
55
56 char GCSE::ID = 0;
57 static RegisterPass
58 X("gcse", "Global Common Subexpression Elimination");
5859
5960 // createGCSEPass - The public interface to this file...
6061 FunctionPass *llvm::createGCSEPass() { return new GCSE(); }
4444 // ValueTable Class
4545 //===----------------------------------------------------------------------===//
4646
47 namespace {
48
4749 /// This class holds the mapping between values and value numbers. It is used
4850 /// as an efficient mechanism to determine the expression-wise equivalence of
4951 /// two values.
122124 }
123125 };
124126
127 }
125128
126129 namespace {
127130 class VISIBILITY_HIDDEN ValueTable {
595598 return nextValueNumber;
596599 }
597600
601 namespace {
602
598603 //===----------------------------------------------------------------------===//
599604 // ValueNumberedSet Class
600605 //===----------------------------------------------------------------------===//
650655 numbers.clear();
651656 }
652657 };
658
659 }
653660
654661 //===----------------------------------------------------------------------===//
655662 // GVNPRE Pass
9393
9494 void DeleteTriviallyDeadInstructions(std::set &Insts);
9595 };
96
97 char IndVarSimplify::ID = 0;
98 RegisterPass X("indvars", "Canonicalize Induction Variables");
99 }
96 }
97
98 char IndVarSimplify::ID = 0;
99 static RegisterPass
100 X("indvars", "Canonicalize Induction Variables");
100101
101102 LoopPass *llvm::createIndVarSimplifyPass() {
102103 return new IndVarSimplify();
77 //===----------------------------------------------------------------------===//
88 //
99 // InstructionCombining - Combine instructions to form fewer, simple
10 // instructions. This pass does not modify the CFG This pass is where algebraic
11 // simplification happens.
10 // instructions. This pass does not modify the CFG. This pass is where
11 // algebraic simplification happens.
1212 //
1313 // This pass combines things like:
1414 // %Y = add i32 %X, 1
383383 unsigned GetOrEnforceKnownAlignment(Value *V,
384384 unsigned PrefAlign = 0);
385385 };
386
387 char InstCombiner::ID = 0;
388 RegisterPass X("instcombine", "Combine redundant instructions");
389 }
386 }
387
388 char InstCombiner::ID = 0;
389 static RegisterPass
390 X("instcombine", "Combine redundant instructions");
390391
391392 // getComplexity: Assign a complexity or rank value to LLVM Values...
392393 // 0 -> undef, 1 -> Const, 2 -> Other, 3 -> Arg, 3 -> Unary, 4 -> OtherInst
21502151 return 0;
21512152 }
21522153
2154 namespace {
21532155
21542156 // AddRHS - Implements: X + X --> X << 1
21552157 struct AddRHS {
21762178 return BinaryOperator::createOr(Add.getOperand(0), Add.getOperand(1));
21772179 }
21782180 };
2181
2182 }
21792183
21802184 static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
21812185 InstCombiner *IC) {
46344638 return Changed ? &I : 0;
46354639 }
46364640
4641 namespace {
4642
46374643 // XorSelf - Implements: X ^ X --> 0
46384644 struct XorSelf {
46394645 Value *RHS;
46444650 }
46454651 };
46464652
4653 }
46474654
46484655 Instruction *InstCombiner::visitXor(BinaryOperator &I) {
46494656 bool Changed = SimplifyCommutative(I);
6262 bool ProcessBranchOnLogical(Value *V, BasicBlock *BB, bool isAnd);
6363 bool ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB);
6464 };
65 char JumpThreading::ID = 0;
66 RegisterPass X("jump-threading", "Jump Threading");
67 }
65 }
66
67 char JumpThreading::ID = 0;
68 static RegisterPass
69 X("jump-threading", "Jump Threading");
6870
6971 // Public interface to the Jump Threading pass
7072 FunctionPass *llvm::createJumpThreadingPass() { return new JumpThreading(); }
5757 STATISTIC(NumMovedCalls, "Number of call insts hoisted or sunk");
5858 STATISTIC(NumPromoted , "Number of memory locations promoted to registers");
5959
60 static cl::opt
61 DisablePromotion("disable-licm-promotion", cl::Hidden,
62 cl::desc("Disable memory promotion in LICM pass"));
63
6064 namespace {
61 static cl::opt
62 DisablePromotion("disable-licm-promotion", cl::Hidden,
63 cl::desc("Disable memory promotion in LICM pass"));
64
6565 struct VISIBILITY_HIDDEN LICM : public LoopPass {
6666 static char ID; // Pass identification, replacement for typeid
6767 LICM() : LoopPass((intptr_t)&ID) {}
215215 std::vector > &PromotedValues,
216216 std::map &Val2AlMap);
217217 };
218
219 char LICM::ID = 0;
220 RegisterPass X("licm", "Loop Invariant Code Motion");
221 }
218 }
219
220 char LICM::ID = 0;
221 static RegisterPass X("licm", "Loop Invariant Code Motion");
222222
223223 LoopPass *llvm::createLICMPass() { return new LICM(); }
224224
5151 AU.addPreservedID(LCSSAID);
5252 }
5353 };
54
55 char LoopDeletion::ID = 0;
56 RegisterPass X ("loop-deletion", "Delete dead loops");
57 }
54 }
55
56 char LoopDeletion::ID = 0;
57 static RegisterPass X("loop-deletion", "Delete dead loops");
5858
5959 LoopPass* llvm::createLoopDeletionPass() {
6060 return new LoopDeletion();
194194 // Induction variable's final loop exit value operand number in exit condition..
195195 unsigned ExitValueNum;
196196 };
197
198 char LoopIndexSplit::ID = 0;
199 RegisterPass X ("loop-index-split", "Index Split Loops");
200 }
197 }
198
199 char LoopIndexSplit::ID = 0;
200 static RegisterPass
201 X("loop-index-split", "Index Split Loops");
201202
202203 LoopPass *llvm::createLoopIndexSplitPass() {
203204 return new LoopIndexSplit();
101101 LPPassManager *LPM_Ptr;
102102 SmallVector LoopHeaderInfo;
103103 };
104 }
104105
105 char LoopRotate::ID = 0;
106 RegisterPass X ("loop-rotate", "Rotate Loops");
107 }
106 char LoopRotate::ID = 0;
107 static RegisterPass X("loop-rotate", "Rotate Loops");
108108
109109 LoopPass *llvm::createLoopRotatePass() { return new LoopRotate(); }
110110
193193 Loop *L, bool isOnlyStride);
194194 void DeleteTriviallyDeadInstructions(SmallPtrSet &Insts);
195195 };
196 char LoopStrengthReduce::ID = 0;
197 RegisterPass X("loop-reduce", "Loop Strength Reduction");
198 }
196 }
197
198 char LoopStrengthReduce::ID = 0;
199 static RegisterPass
200 X("loop-reduce", "Loop Strength Reduction");
199201
200202 LoopPass *llvm::createLoopStrengthReducePass(const TargetLowering *TLI) {
201203 return new LoopStrengthReduce(TLI);
4343 STATISTIC(NumCompletelyUnrolled, "Number of loops completely unrolled");
4444 STATISTIC(NumUnrolled, "Number of loops unrolled (completely or otherwise)");
4545
46 static cl::opt
47 UnrollThreshold("unroll-threshold", cl::init(100), cl::Hidden,
48 cl::desc("The cut-off point for automatic loop unrolling"));
49
50 static cl::opt
51 UnrollCount("unroll-count", cl::init(0), cl::Hidden,
52 cl::desc("Use this unroll count for all loops, for testing purposes"));
53
4654 namespace {
47 static cl::opt
48 UnrollThreshold
49 ("unroll-threshold", cl::init(100), cl::Hidden,
50 cl::desc("The cut-off point for automatic loop unrolling"));
51
52 static cl::opt
53 UnrollCount
54 ("unroll-count", cl::init(0), cl::Hidden,
55 cl::desc("Use this unroll count for all loops, for testing purposes"));
56
5755 class VISIBILITY_HIDDEN LoopUnroll : public LoopPass {
5856 LoopInfo *LI; // The current loop information
5957 public:
8078 AU.addPreserved();
8179 }
8280 };
83 char LoopUnroll::ID = 0;
84 RegisterPass X("loop-unroll", "Unroll loops");
8581 }
82
83 char LoopUnroll::ID = 0;
84 static RegisterPass X("loop-unroll", "Unroll loops");
8685
8786 LoopPass *llvm::createLoopUnrollPass() { return new LoopUnroll(); }
8887
5353 STATISTIC(NumTrivial , "Number of unswitches that are trivial");
5454 STATISTIC(NumSimplify, "Number of simplifications of unswitched code");
5555
56 static cl::opt
57 Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"),
58 cl::init(10), cl::Hidden);
59
5660 namespace {
57 static cl::opt
58 Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"),
59 cl::init(10), cl::Hidden);
60
6161 class VISIBILITY_HIDDEN LoopUnswitch : public LoopPass {
6262 LoopInfo *LI; // Loop information
6363 LPPassManager *LPM;
143143 std::vector &Worklist, Loop *l);
144144 void RemoveLoopFromHierarchy(Loop *L);
145145 };
146 char LoopUnswitch::ID = 0;
147 RegisterPass X("loop-unswitch", "Unswitch loops");
148 }
146 }
147 char LoopUnswitch::ID = 0;
148 static RegisterPass X("loop-unswitch", "Unswitch loops");
149149
150150 LoopPass *llvm::createLoopUnswitchPass(bool Os) {
151151 return new LoopUnswitch(Os);
458458 // OrigPreheader is loop pre-header before this pass started
459459 // updating CFG. NewPrehader is loops new pre-header. However, after CFG
460460 // manipulation, loop L may not exist. So rely on input parameter NewPreheader.
461 void CloneDomInfo(BasicBlock *NewBB, BasicBlock *Orig,
462 BasicBlock *NewPreheader, BasicBlock *OrigPreheader,
463 BasicBlock *OrigHeader,
464 DominatorTree *DT, DominanceFrontier *DF,
465 DenseMap &VM) {
461 static void CloneDomInfo(BasicBlock *NewBB, BasicBlock *Orig,
462 BasicBlock *NewPreheader, BasicBlock *OrigPreheader,
463 BasicBlock *OrigHeader,
464 DominatorTree *DT, DominanceFrontier *DF,
465 DenseMap &VM) {
466466
467467 // If NewBB alreay has found its place in domiantor tree then no need to do
468468 // anything.
26452645 }
26462646 }
26472647 }
2648
2649 char PredicateSimplifier::ID = 0;
2650 RegisterPass X("predsimplify",
2651 "Predicate Simplifier");
26522648 }
2649
2650 char PredicateSimplifier::ID = 0;
2651 static RegisterPass
2652 X("predsimplify", "Predicate Simplifier");
26532653
26542654 FunctionPass *llvm::createPredicateSimplifierPass() {
26552655 return new PredicateSimplifier();
6363 << "," << Ops[i].Rank;
6464 }
6565
66 namespace {
66 namespace {
6767 class VISIBILITY_HIDDEN Reassociate : public FunctionPass {
6868 std::map RankMap;
6969 std::map ValueRankMap;
9191
9292 void RemoveDeadBinaryOp(Value *V);
9393 };
94
95 char Reassociate::ID = 0;
96 RegisterPass X("reassociate", "Reassociate expressions");
97 }
94 }
95
96 char Reassociate::ID = 0;
97 static RegisterPass X("reassociate", "Reassociate expressions");
9898
9999 // Public interface to the Reassociate pass
100100 FunctionPass *llvm::createReassociatePass() { return new Reassociate(); }
110110 return false;
111111 }
112112 };
113 }
113114
114 char RegToMem::ID = 0;
115 RegisterPass X("reg2mem", "Demote all values to stack slots");
116 }
115 char RegToMem::ID = 0;
116 static RegisterPass
117 X("reg2mem", "Demote all values to stack slots");
117118
118119 // createDemoteRegisterToMemory - Provide an entry point to create this pass.
119120 //
14341434 AU.setPreservesCFG();
14351435 }
14361436 };
1437
1438 char SCCP::ID = 0;
1439 RegisterPass X("sccp", "Sparse Conditional Constant Propagation");
14401437 } // end anonymous namespace
14411438
1439 char SCCP::ID = 0;
1440 static RegisterPass
1441 X("sccp", "Sparse Conditional Constant Propagation");
14421442
14431443 // createSCCPPass - This is the public interface to this file...
14441444 FunctionPass *llvm::createSCCPPass() {
15421542 IPSCCP() : ModulePass((intptr_t)&ID) {}
15431543 bool runOnModule(Module &M);
15441544 };
1545
1546 char IPSCCP::ID = 0;
1547 RegisterPass
1548 Y("ipsccp", "Interprocedural Sparse Conditional Constant Propagation");
15491545 } // end anonymous namespace
1546
1547 char IPSCCP::ID = 0;
1548 static RegisterPass
1549 Y("ipsccp", "Interprocedural Sparse Conditional Constant Propagation");
15501550
15511551 // createIPSCCPPass - This is the public interface to this file...
15521552 ModulePass *llvm::createIPSCCPPass() {
123123 unsigned Offset);
124124 static Instruction *isOnlyCopiedFromConstantGlobal(AllocationInst *AI);
125125 };
126
127 char SROA::ID = 0;
128 RegisterPass X("scalarrepl", "Scalar Replacement of Aggregates");
129 }
126 }
127
128 char SROA::ID = 0;
129 static RegisterPass X("scalarrepl", "Scalar Replacement of Aggregates");
130130
131131 // Public interface to the ScalarReplAggregates pass
132132 FunctionPass *llvm::createScalarReplAggregatesPass(signed int Threshold) {
4444
4545 virtual bool runOnFunction(Function &F);
4646 };
47 char CFGSimplifyPass::ID = 0;
48 RegisterPass X("simplifycfg", "Simplify the CFG");
49 }
47 }
48
49 char CFGSimplifyPass::ID = 0;
50 static RegisterPass X("simplifycfg", "Simplify the CFG");
5051
5152 // Public interface to the CFGSimplification pass
5253 FunctionPass *llvm::createCFGSimplificationPass() {
3636
3737 STATISTIC(NumEliminated, "Number of unconditional branches eliminated");
3838
39 static cl::opt
40 Threshold("taildup-threshold", cl::desc("Max block size to tail duplicate"),
41 cl::init(6), cl::Hidden);
42
3943 namespace {
40 cl::opt
41 Threshold("taildup-threshold", cl::desc("Max block size to tail duplicate"),
42 cl::init(6), cl::Hidden);
4344 class VISIBILITY_HIDDEN TailDup : public FunctionPass {
4445 bool runOnFunction(Function &F);
4546 public:
5051 inline bool shouldEliminateUnconditionalBranch(TerminatorInst *TI);
5152 inline void eliminateUnconditionalBranch(BranchInst *BI);
5253 };
53 char TailDup::ID = 0;
54 RegisterPass X("tailduplicate", "Tail Duplication");
55 }
54 }
55
56 char TailDup::ID = 0;
57 static RegisterPass X("tailduplicate", "Tail Duplication");
5658
5759 // Public interface to the Tail Duplication pass
5860 FunctionPass *llvm::createTailDuplicationPass() { return new TailDup(); }
7979 bool CanMoveAboveCall(Instruction *I, CallInst *CI);
8080 Value *CanTransformAccumulatorRecursion(Instruction *I, CallInst *CI);
8181 };
82 char TailCallElim::ID = 0;
83 RegisterPass X("tailcallelim", "Tail Call Elimination");
84 }
82 }
83
84 char TailCallElim::ID = 0;
85 static RegisterPass X("tailcallelim", "Tail Call Elimination");
8586
8687 // Public interface to the TailCallElimination pass
8788 FunctionPass *llvm::createTailCallEliminationPass() {
2525
2626 using namespace llvm;
2727
28 namespace {
29 static cl::opt
30 BasicInlineThreshold("inline-threshold", cl::Hidden, cl::init(200),
31 cl::desc("Control the amount of basic inlining to perform (default = 200)"));
32 }
28 static cl::opt
29 BasicInlineThreshold("inline-threshold", cl::Hidden, cl::init(200),
30 cl::desc("Control the amount of basic inlining to perform (default = 200)"));
3331
3432 namespace llvm {
3533
4747 AU.addPreservedID(LoopSimplifyID);
4848 }
4949 };
50
51 char BreakCriticalEdges::ID = 0;
52 RegisterPass X("break-crit-edges",
53 "Break critical edges in CFG");
54 }
50 }
51
52 char BreakCriticalEdges::ID = 0;
53 static RegisterPass
54 X("break-crit-edges", "Break critical edges in CFG");
5555
5656 // Publically exposed interface to pass...
5757 const PassInfo *llvm::BreakCriticalEdgesID = X.getPassInfo();
9393 return std::binary_search(LoopBlocks.begin(), LoopBlocks.end(), B);
9494 }
9595 };
96
97 char LCSSA::ID = 0;
98 RegisterPass X("lcssa", "Loop-Closed SSA Form Pass");
99 }
96 }
97
98 char LCSSA::ID = 0;
99 static RegisterPass X("lcssa", "Loop-Closed SSA Form Pass");
100100
101101 LoopPass *llvm::createLCSSAPass() { return new LCSSA(); }
102102 const PassInfo *llvm::LCSSAID = X.getPassInfo();
9494 SmallVectorImpl &SplitPreds,
9595 Loop *L);
9696 };
97
98 char LoopSimplify::ID = 0;
99 RegisterPass
100 X("loopsimplify", "Canonicalize natural loops", true);
101 }
97 }
98
99 char LoopSimplify::ID = 0;
100 static RegisterPass
101 X("loopsimplify", "Canonicalize natural loops", true);
102102
103103 // Publically exposed interface to pass...
104104 const PassInfo *llvm::LoopSimplifyID = X.getPassInfo();
6565 ///
6666 bool runOnBasicBlock(BasicBlock &BB);
6767 };
68 }
6869
69 char LowerAllocations::ID = 0;
70 RegisterPass
71 X("lowerallocs", "Lower allocations from instructions to calls");
72 }
70 char LowerAllocations::ID = 0;
71 static RegisterPass
72 X("lowerallocs", "Lower allocations from instructions to calls");
7373
7474 // Publically exposed interface to pass...
7575 const PassInfo *llvm::LowerAllocationsID = X.getPassInfo();
9797 AllocaInst *InvokeNum, SwitchInst *CatchSwitch);
9898 bool insertExpensiveEHSupport(Function &F);
9999 };
100
101 char LowerInvoke::ID = 0;
102 RegisterPass
103 X("lowerinvoke", "Lower invoke and unwind, for unwindless code generators");
104 }
100 }
101
102 char LowerInvoke::ID = 0;
103 static RegisterPass
104 X("lowerinvoke", "Lower invoke and unwind, for unwindless code generators");
105105
106106 const PassInfo *llvm::LowerInvokePassID = X.getPassInfo();
107107
7676 return CI1->getValue().slt(CI2->getValue());
7777 }
7878 };
79
80 char LowerSwitch::ID = 0;
81 RegisterPass
82 X("lowerswitch", "Lower SwitchInst's to branches");
83 }
79 }
80
81 char LowerSwitch::ID = 0;
82 static RegisterPass
83 X("lowerswitch", "Lower SwitchInst's to branches");
8484
8585 // Publically exposed interface to pass...
8686 const PassInfo *llvm::LowerSwitchID = X.getPassInfo();
4747 AU.addPreservedID(LowerAllocationsID);
4848 }
4949 };
50 } // end of anonymous namespace
5051
51 char PromotePass::ID = 0;
52 RegisterPass X("mem2reg", "Promote Memory to Register");
53 } // end of anonymous namespace
52 char PromotePass::ID = 0;
53 static RegisterPass X("mem2reg", "Promote Memory to Register");
5454
5555 bool PromotePass::runOnFunction(Function &F) {
5656 std::vector Allocas;
15131513 //---- ConstantExpr::get() implementations...
15141514 //
15151515
1516 namespace {
1517
15161518 struct ExprMapKeyType {
15171519 explicit ExprMapKeyType(unsigned opc, std::vector ops,
15181520 unsigned short pred = 0) : opcode(opc), predicate(pred), operands(ops) { }
15351537 return !(*this == that);
15361538 }
15371539 };
1540
1541 }
15381542
15391543 namespace llvm {
15401544 template<>
359359 }
360360 };
361361
362 } // End of anon namespace
363
362364 static TimingInfo *TheTimeInfo;
363
364 } // End of anon namespace
365365
366366 //===----------------------------------------------------------------------===//
367367 // PMTopLevelManager implementation
549549 }
550550
551551
552 namespace {
552553
553554 /// TypePromotionGraph and graph traits - this is designed to allow us to do
554555 /// efficient SCC processing of type graphs. This is the exact same as
558559 Type *Ty;
559560 TypePromotionGraph(Type *T) : Ty(T) {}
560561 };
562
563 }
561564
562565 namespace llvm {
563566 template <> struct GraphTraits {
9191 return false;
9292 }
9393 };
94
95 char PreVerifier::ID = 0;
96 RegisterPass PreVer("preverify", "Preliminary module verification");
97 const PassInfo *PreVerifyID = PreVer.getPassInfo();
98
94 }
95
96 char PreVerifier::ID = 0;
97 static RegisterPass
98 PreVer("preverify", "Preliminary module verification");
99 static const PassInfo *PreVerifyID = PreVer.getPassInfo();
100
101 namespace {
99102 struct VISIBILITY_HIDDEN
100103 Verifier : public FunctionPass, InstVisitor {
101104 static char ID; // Pass ID, replacement for typeid
304307 Broken = true;
305308 }
306309 };
307
308 char Verifier::ID = 0;
309 RegisterPass X("verify", "Module Verifier");
310310 } // End anonymous namespace
311311
312 char Verifier::ID = 0;
313 static RegisterPass X("verify", "Module Verifier");
312314
313315 // Assert - We know that cond should be true, if not print an error message.
314316 #define Assert(C, M) \