Mercurial > hg > CbC > CbC_llvm
annotate lib/Transforms/IPO/PassManagerBuilder.cpp @ 16:d405342cecb1
can eliminate tail call regardless of optimize level
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Sep 2013 19:04:26 +0900 |
parents | b7de57f78d3a |
children |
rev | line source |
---|---|
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 //===- PassManagerBuilder.cpp - Build Standard Pass -----------------------===// |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 // |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // The LLVM Compiler Infrastructure |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 // |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is distributed under the University of Illinois Open Source |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // License. See LICENSE.TXT for details. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 // |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 //===----------------------------------------------------------------------===// |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 // |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // This file defines the PassManagerBuilder class, which is used to set up a |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 // "standard" optimization sequence suitable for languages like C and C++. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 // |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 //===----------------------------------------------------------------------===// |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 #include "llvm/Transforms/IPO/PassManagerBuilder.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 #include "llvm-c/Transforms/PassManagerBuilder.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 #include "llvm/ADT/SmallVector.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 #include "llvm/Analysis/Passes.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 #include "llvm/Analysis/Verifier.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 #include "llvm/PassManager.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 #include "llvm/Support/CommandLine.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 #include "llvm/Support/ManagedStatic.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 #include "llvm/Target/TargetLibraryInfo.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 #include "llvm/Transforms/IPO.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 #include "llvm/Transforms/Scalar.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 #include "llvm/Transforms/Vectorize.h" |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 using namespace llvm; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 static cl::opt<bool> |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 RunLoopVectorization("vectorize-loops", |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 cl::desc("Run the Loop vectorization passes")); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 static cl::opt<bool> |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 RunSLPVectorization("vectorize-slp", |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 cl::desc("Run the SLP vectorization passes")); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 static cl::opt<bool> |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 RunBBVectorization("vectorize-slp-aggressive", |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 cl::desc("Run the BB vectorization passes")); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 static cl::opt<bool> |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 UseGVNAfterVectorization("use-gvn-after-vectorization", |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 cl::init(false), cl::Hidden, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 cl::desc("Run GVN instead of Early CSE after vectorization passes")); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 static cl::opt<bool> UseNewSROA("use-new-sroa", |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 cl::init(true), cl::Hidden, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 cl::desc("Enable the new, experimental SROA pass")); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 PassManagerBuilder::PassManagerBuilder() { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 OptLevel = 2; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 SizeLevel = 0; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 LibraryInfo = 0; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 Inliner = 0; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 DisableSimplifyLibCalls = false; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 DisableUnitAtATime = false; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 DisableUnrollLoops = false; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 BBVectorize = RunBBVectorization; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 SLPVectorize = RunSLPVectorization; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62 LoopVectorize = RunLoopVectorization; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 PassManagerBuilder::~PassManagerBuilder() { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66 delete LibraryInfo; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 delete Inliner; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
68 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
69 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
70 /// Set of global extensions, automatically added as part of the standard set. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 static ManagedStatic<SmallVector<std::pair<PassManagerBuilder::ExtensionPointTy, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 PassManagerBuilder::ExtensionFn>, 8> > GlobalExtensions; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 void PassManagerBuilder::addGlobalExtension( |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 PassManagerBuilder::ExtensionPointTy Ty, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 PassManagerBuilder::ExtensionFn Fn) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 GlobalExtensions->push_back(std::make_pair(Ty, Fn)); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
81 Extensions.push_back(std::make_pair(Ty, Fn)); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 PassManagerBase &PM) const { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 if ((*GlobalExtensions)[i].first == ETy) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 (*GlobalExtensions)[i].second(*this, PM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 for (unsigned i = 0, e = Extensions.size(); i != e; ++i) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 if (Extensions[i].first == ETy) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 Extensions[i].second(*this, PM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 PassManagerBuilder::addInitialAliasAnalysisPasses(PassManagerBase &PM) const { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 // BasicAliasAnalysis wins if they disagree. This is intended to help |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 // support "obvious" type-punning idioms. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 PM.add(createTypeBasedAliasAnalysisPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100 PM.add(createBasicAliasAnalysisPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
103 void PassManagerBuilder::populateFunctionPassManager(FunctionPassManager &FPM) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
104 addExtensionsToPM(EP_EarlyAsPossible, FPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 // Add LibraryInfo if we have some. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 if (LibraryInfo) FPM.add(new TargetLibraryInfo(*LibraryInfo)); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 |
11
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
109 #ifndef noCbC |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
110 if (UseNewSROA) |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
111 FPM.add(createSROAPass(true,true)); |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
112 else |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
113 FPM.add(createScalarReplAggregatesPass()); |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
114 #endif |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
115 |
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 if (OptLevel == 0) return; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 addInitialAliasAnalysisPasses(FPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 FPM.add(createCFGSimplificationPass()); |
11
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
121 #ifndef noCbC |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
122 if (UseNewSROA) |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
123 FPM.add(createSROAPass(true,false)); |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
124 else |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
125 FPM.add(createScalarReplAggregatesPass()); |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
126 #else |
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127 if (UseNewSROA) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 FPM.add(createSROAPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 else |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 FPM.add(createScalarReplAggregatesPass()); |
11
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
131 #endif |
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 FPM.add(createEarlyCSEPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 FPM.add(createLowerExpectIntrinsicPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 // If all optimizations are disabled, just run the always-inline pass. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 if (OptLevel == 0) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 if (Inliner) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
140 MPM.add(Inliner); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 Inliner = 0; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 // pass manager, but we don't want to add extensions into that pass manager. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146 // To prevent this we must insert a no-op module pass to reset the pass |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147 // manager to get the same behavior as EP_OptimizerLast in non-O0 builds. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
148 if (!GlobalExtensions->empty() || !Extensions.empty()) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 MPM.add(createBarrierNoopPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 |
10
e3d004bb4de5
can tell the Type which is void or __code and set tail call flag only __code.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
151 #ifndef noCbC |
e3d004bb4de5
can tell the Type which is void or __code and set tail call flag only __code.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
152 MPM.add(createTailCallEliminationPass(true)); // Eliminate tail calls |
e3d004bb4de5
can tell the Type which is void or __code and set tail call flag only __code.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
153 #endif |
11
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
154 |
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 addExtensionsToPM(EP_EnabledOnOptLevel0, MPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156 return; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 // Add LibraryInfo if we have some. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 if (LibraryInfo) MPM.add(new TargetLibraryInfo(*LibraryInfo)); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 addInitialAliasAnalysisPasses(MPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 if (!DisableUnitAtATime) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 addExtensionsToPM(EP_ModuleOptimizerEarly, MPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
167 MPM.add(createGlobalOptimizerPass()); // Optimize out global vars |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
168 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
169 MPM.add(createIPSCCPPass()); // IP SCCP |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170 MPM.add(createDeadArgEliminationPass()); // Dead argument elimination |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
172 MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
173 MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
174 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 // Start of CallGraph SCC passes. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
177 if (!DisableUnitAtATime) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 MPM.add(createPruneEHPass()); // Remove dead EH info |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179 if (Inliner) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 MPM.add(Inliner); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 Inliner = 0; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 if (!DisableUnitAtATime) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 if (OptLevel > 2) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 // Start of function pass. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
189 // Break up aggregate allocas, using SSAUpdater. |
11
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
190 #ifndef noCbC |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
191 if (UseNewSROA) |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
192 MPM.add(createSROAPass(/*RequiresDomTree*/ false,false)); |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
193 else |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
194 MPM.add(createScalarReplAggregatesPass(-1, false)); |
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
195 #else |
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 if (UseNewSROA) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197 MPM.add(createSROAPass(/*RequiresDomTree*/ false)); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 else |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
199 MPM.add(createScalarReplAggregatesPass(-1, false)); |
11
b7de57f78d3a
add FPM SROA pass for function which contains goto cs().
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
200 #endif |
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 if (!DisableSimplifyLibCalls) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
203 MPM.add(createSimplifyLibCallsPass()); // Library Call Optimizations |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 MPM.add(createJumpThreadingPass()); // Thread jumps. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
206 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
207 MPM.add(createInstructionCombiningPass()); // Combine silly seq's |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
208 |
10
e3d004bb4de5
can tell the Type which is void or __code and set tail call flag only __code.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
209 #ifndef noCbC |
16
d405342cecb1
can eliminate tail call regardless of optimize level
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
210 MPM.add(createTailCallEliminationPass(true)); // Eliminate tail calls |
10
e3d004bb4de5
can tell the Type which is void or __code and set tail call flag only __code.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
211 #else |
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 MPM.add(createTailCallEliminationPass()); // Eliminate tail calls |
10
e3d004bb4de5
can tell the Type which is void or __code and set tail call flag only __code.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
213 #endif |
3
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 MPM.add(createReassociatePass()); // Reassociate expressions |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
216 MPM.add(createLoopRotatePass()); // Rotate Loop |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 MPM.add(createLICMPass()); // Hoist loop invariants |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
218 MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3)); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 MPM.add(createInstructionCombiningPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 MPM.add(createLoopIdiomPass()); // Recognize idioms like memset. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 MPM.add(createLoopDeletionPass()); // Delete dead loops |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224 if (LoopVectorize && OptLevel > 2) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
225 MPM.add(createLoopVectorizePass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 if (!DisableUnrollLoops) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 MPM.add(createLoopUnrollPass()); // Unroll small loops |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 addExtensionsToPM(EP_LoopOptimizerEnd, MPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
230 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
231 if (OptLevel > 1) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
232 MPM.add(createGVNPass()); // Remove redundancies |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
233 MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
234 MPM.add(createSCCPPass()); // Constant prop with SCCP |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
235 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
236 // Run instcombine after redundancy elimination to exploit opportunities |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
237 // opened up by them. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
238 MPM.add(createInstructionCombiningPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
239 MPM.add(createJumpThreadingPass()); // Thread jumps |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
240 MPM.add(createCorrelatedValuePropagationPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241 MPM.add(createDeadStoreEliminationPass()); // Delete dead stores |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
242 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
243 addExtensionsToPM(EP_ScalarOptimizerLate, MPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
244 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
245 if (SLPVectorize) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
246 MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
247 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
248 if (BBVectorize) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
249 MPM.add(createBBVectorizePass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
250 MPM.add(createInstructionCombiningPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 if (OptLevel > 1 && UseGVNAfterVectorization) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
252 MPM.add(createGVNPass()); // Remove redundancies |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
253 else |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
254 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
255 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
256 // BBVectorize may have significantly shortened a loop body; unroll again. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
257 if (!DisableUnrollLoops) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
258 MPM.add(createLoopUnrollPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
259 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
260 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
261 MPM.add(createAggressiveDCEPass()); // Delete dead instructions |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
262 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
263 MPM.add(createInstructionCombiningPass()); // Clean up after everything. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
264 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
265 if (!DisableUnitAtATime) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
266 // FIXME: We shouldn't bother with this anymore. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
267 MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
268 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
269 // GlobalOpt already deletes dead functions and globals, at -O2 try a |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
270 // late pass of GlobalDCE. It is capable of deleting dead cycles. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
271 if (OptLevel > 1) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
272 MPM.add(createGlobalDCEPass()); // Remove dead fns and globals. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
273 MPM.add(createConstantMergePass()); // Merge dup global constants |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
274 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
275 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
276 addExtensionsToPM(EP_OptimizerLast, MPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
277 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
278 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
279 void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
280 bool Internalize, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
281 bool RunInliner, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
282 bool DisableGVNLoadPRE) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
283 // Provide AliasAnalysis services for optimizations. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
284 addInitialAliasAnalysisPasses(PM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
285 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
286 // Now that composite has been compiled, scan through the module, looking |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
287 // for a main function. If main is defined, mark all other functions |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
288 // internal. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
289 if (Internalize) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
290 std::vector<const char*> E; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
291 E.push_back("main"); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
292 PM.add(createInternalizePass(E)); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
293 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
294 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
295 // Propagate constants at call sites into the functions they call. This |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
296 // opens opportunities for globalopt (and inlining) by substituting function |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
297 // pointers passed as arguments to direct uses of functions. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
298 PM.add(createIPSCCPPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
299 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
300 // Now that we internalized some globals, see if we can hack on them! |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
301 PM.add(createGlobalOptimizerPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
303 // Linking modules together can lead to duplicated global constants, only |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
304 // keep one copy of each constant. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
305 PM.add(createConstantMergePass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
306 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
307 // Remove unused arguments from functions. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
308 PM.add(createDeadArgEliminationPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
309 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
310 // Reduce the code after globalopt and ipsccp. Both can open up significant |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
311 // simplification opportunities, and both can propagate functions through |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
312 // function pointers. When this happens, we often have to resolve varargs |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
313 // calls, etc, so let instcombine do this. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
314 PM.add(createInstructionCombiningPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
315 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
316 // Inline small functions |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
317 if (RunInliner) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
318 PM.add(createFunctionInliningPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
319 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
320 PM.add(createPruneEHPass()); // Remove dead EH info. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
321 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
322 // Optimize globals again if we ran the inliner. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
323 if (RunInliner) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
324 PM.add(createGlobalOptimizerPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
325 PM.add(createGlobalDCEPass()); // Remove dead functions. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
326 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
327 // If we didn't decide to inline a function, check to see if we can |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
328 // transform it to pass arguments by value instead of by reference. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
329 PM.add(createArgumentPromotionPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
330 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
331 // The IPO passes may leave cruft around. Clean up after them. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
332 PM.add(createInstructionCombiningPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
333 PM.add(createJumpThreadingPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
334 // Break up allocas |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
335 if (UseNewSROA) |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
336 PM.add(createSROAPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
337 else |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
338 PM.add(createScalarReplAggregatesPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
339 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
340 // Run a few AA driven optimizations here and now, to cleanup the code. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
341 PM.add(createFunctionAttrsPass()); // Add nocapture. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
342 PM.add(createGlobalsModRefPass()); // IP alias analysis. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
343 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
344 PM.add(createLICMPass()); // Hoist loop invariants. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
345 PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
346 PM.add(createMemCpyOptPass()); // Remove dead memcpys. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
347 // Nuke dead stores. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
348 PM.add(createDeadStoreEliminationPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
349 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
350 // Cleanup and simplify the code after the scalar optimizations. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
351 PM.add(createInstructionCombiningPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
352 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
353 PM.add(createJumpThreadingPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
354 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
355 // Delete basic blocks, which optimization passes may have killed. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
356 PM.add(createCFGSimplificationPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
357 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
358 // Now that we have optimized the program, discard unreachable functions. |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
359 PM.add(createGlobalDCEPass()); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
360 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
361 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
362 inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
363 return reinterpret_cast<PassManagerBuilder*>(P); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
364 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
365 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
366 inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
367 return reinterpret_cast<LLVMPassManagerBuilderRef>(P); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
368 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
369 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
370 LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
371 PassManagerBuilder *PMB = new PassManagerBuilder(); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
372 return wrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
373 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
374 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
375 void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
376 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
377 delete Builder; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
378 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
379 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
380 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
381 LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
382 unsigned OptLevel) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
383 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
384 Builder->OptLevel = OptLevel; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
385 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
386 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
387 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
388 LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
389 unsigned SizeLevel) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
390 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
391 Builder->SizeLevel = SizeLevel; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
392 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
393 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
394 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
395 LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
396 LLVMBool Value) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
397 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
398 Builder->DisableUnitAtATime = Value; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
399 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
400 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
401 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
402 LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
403 LLVMBool Value) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
404 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
405 Builder->DisableUnrollLoops = Value; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
406 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
407 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
408 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
409 LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
410 LLVMBool Value) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
411 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
412 Builder->DisableSimplifyLibCalls = Value; |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
413 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
414 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
415 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
416 LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
417 unsigned Threshold) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
418 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
419 Builder->Inliner = createFunctionInliningPass(Threshold); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
420 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
421 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
422 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
423 LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
424 LLVMPassManagerRef PM) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
425 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
426 FunctionPassManager *FPM = unwrap<FunctionPassManager>(PM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
427 Builder->populateFunctionPassManager(*FPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
428 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
429 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
430 void |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
431 LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
432 LLVMPassManagerRef PM) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
433 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
434 PassManagerBase *MPM = unwrap(PM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
435 Builder->populateModulePassManager(*MPM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
436 } |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
437 |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
438 void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
439 LLVMPassManagerRef PM, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
440 LLVMBool Internalize, |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
441 LLVMBool RunInliner) { |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
442 PassManagerBuilder *Builder = unwrap(PMB); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
443 PassManagerBase *LPM = unwrap(PM); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
444 Builder->populateLTOPassManager(*LPM, Internalize != 0, RunInliner != 0); |
9ad51c7bc036
1st commit. remove git dir and add all files.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
445 } |