llvm.org GIT mirror llvm / 613d807
[PM] Port PartiallyInlineLibCalls to the new pass manager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270798 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 3 years ago
6 changed file(s) with 59 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
236236 void initializeObjCARCOptPass(PassRegistry&);
237237 void initializePAEvalPass(PassRegistry &);
238238 void initializeOptimizePHIsPass(PassRegistry&);
239 void initializePartiallyInlineLibCallsPass(PassRegistry&);
239 void initializePartiallyInlineLibCallsLegacyPassPass(PassRegistry &);
240240 void initializePEIPass(PassRegistry&);
241241 void initializePHIEliminationPass(PassRegistry&);
242242 void initializePartialInlinerPass(PassRegistry&);
7272 #include "llvm/Transforms/Scalar/LoopSimplifyCFG.h"
7373 #include "llvm/Transforms/Scalar/LowerAtomic.h"
7474 #include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
75 #include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
7576 #include "llvm/Transforms/Scalar/Reassociate.h"
7677 #include "llvm/Transforms/Scalar/SCCP.h"
7778 #include "llvm/Transforms/Scalar/SROA.h"
120120 FUNCTION_PASS("lower-expect", LowerExpectIntrinsicPass())
121121 FUNCTION_PASS("guard-widening", GuardWideningPass())
122122 FUNCTION_PASS("gvn", GVN())
123 FUNCTION_PASS("partially-inline-libcalls", PartiallyInlineLibCallsPass())
123124 FUNCTION_PASS("print", PrintFunctionPass(dbgs()))
124125 FUNCTION_PASS("print", AssumptionPrinterPass(dbgs()))
125126 FUNCTION_PASS("print", BlockFrequencyPrinterPass(dbgs()))
1212 //
1313 //===----------------------------------------------------------------------===//
1414
15 #include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
1516 #include "llvm/Analysis/TargetLibraryInfo.h"
1617 #include "llvm/Analysis/TargetTransformInfo.h"
1718 #include "llvm/IR/IRBuilder.h"
2223
2324 #define DEBUG_TYPE "partially-inline-libcalls"
2425
25 namespace {
26 class PartiallyInlineLibCalls : public FunctionPass {
27 public:
28 static char ID;
29
30 PartiallyInlineLibCalls() :
31 FunctionPass(ID) {
32 initializePartiallyInlineLibCallsPass(*PassRegistry::getPassRegistry());
33 }
34
35 void getAnalysisUsage(AnalysisUsage &AU) const override {
36 AU.addRequired();
37 AU.addRequired();
38 FunctionPass::getAnalysisUsage(AU);
39 }
40
41 bool runOnFunction(Function &F) override;
42 };
43
44 char PartiallyInlineLibCalls::ID = 0;
45 }
46
47 INITIALIZE_PASS_BEGIN(PartiallyInlineLibCalls, "partially-inline-libcalls",
48 "Partially inline calls to library functions", false,
49 false)
50 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
51 INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
52 INITIALIZE_PASS_END(PartiallyInlineLibCalls, "partially-inline-libcalls",
53 "Partially inline calls to library functions", false, false)
5426
5527 static bool optimizeSQRT(CallInst *Call, Function *CalledFunc,
5628 BasicBlock &CurrBB, Function::iterator &BB) {
10779 return true;
10880 }
10981
110 bool PartiallyInlineLibCalls::runOnFunction(Function &F) {
111 if (skipFunction(F))
112 return false;
82 static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI,
83 const TargetTransformInfo *TTI) {
84 bool Changed = false;
11385
114 bool Changed = false;
11586 Function::iterator CurrBB;
116 TargetLibraryInfo *TLI =
117 &getAnalysis().getTLI();
118 const TargetTransformInfo *TTI =
119 &getAnalysis().getTTI(F);
12087 for (Function::iterator BB = F.begin(), BE = F.end(); BB != BE;) {
12188 CurrBB = BB++;
12289
154121 return Changed;
155122 }
156123
124 PreservedAnalyses
125 PartiallyInlineLibCallsPass::run(Function &F, AnalysisManager &AM) {
126 auto &TLI = AM.getResult(F);
127 auto &TTI = AM.getResult(F);
128 if (!runPartiallyInlineLibCalls(F, &TLI, &TTI))
129 return PreservedAnalyses::all();
130 return PreservedAnalyses::none();
131 }
132
133 namespace {
134 class PartiallyInlineLibCallsLegacyPass : public FunctionPass {
135 public:
136 static char ID;
137
138 PartiallyInlineLibCallsLegacyPass() : FunctionPass(ID) {
139 initializePartiallyInlineLibCallsLegacyPassPass(
140 *PassRegistry::getPassRegistry());
141 }
142
143 void getAnalysisUsage(AnalysisUsage &AU) const override {
144 AU.addRequired();
145 AU.addRequired();
146 FunctionPass::getAnalysisUsage(AU);
147 }
148
149 bool runOnFunction(Function &F) override {
150 if (skipFunction(F))
151 return false;
152
153 TargetLibraryInfo *TLI =
154 &getAnalysis().getTLI();
155 const TargetTransformInfo *TTI =
156 &getAnalysis().getTTI(F);
157 return runPartiallyInlineLibCalls(F, TLI, TTI);
158 }
159 };
160 }
161
162 char PartiallyInlineLibCallsLegacyPass::ID = 0;
163 INITIALIZE_PASS_BEGIN(PartiallyInlineLibCallsLegacyPass,
164 "partially-inline-libcalls",
165 "Partially inline calls to library functions", false,
166 false)
167 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
168 INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
169 INITIALIZE_PASS_END(PartiallyInlineLibCallsLegacyPass,
170 "partially-inline-libcalls",
171 "Partially inline calls to library functions", false, false)
172
157173 FunctionPass *llvm::createPartiallyInlineLibCallsPass() {
158 return new PartiallyInlineLibCalls();
174 return new PartiallyInlineLibCallsLegacyPass();
159175 }
6666 initializeMemCpyOptPass(Registry);
6767 initializeMergedLoadStoreMotionPass(Registry);
6868 initializeNaryReassociatePass(Registry);
69 initializePartiallyInlineLibCallsPass(Registry);
69 initializePartiallyInlineLibCallsLegacyPassPass(Registry);
7070 initializeReassociateLegacyPassPass(Registry);
7171 initializeRegToMemPass(Registry);
7272 initializeRewriteStatepointsForGCPass(Registry);
0 ; RUN: opt -S -partially-inline-libcalls < %s | FileCheck %s
1 ; RUN: opt -S -passes=partially-inline-libcalls < %s | FileCheck %s
12
23 target triple = "x86_64-unknown-linux-gnu"
34