• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "llvm/Transforms/IPO/SCCP.h"
2 #include "llvm/Analysis/TargetLibraryInfo.h"
3 #include "llvm/Transforms/IPO.h"
4 #include "llvm/Transforms/Scalar/SCCP.h"
5 
6 using namespace llvm;
7 
run(Module & M,ModuleAnalysisManager & AM)8 PreservedAnalyses IPSCCPPass::run(Module &M, ModuleAnalysisManager &AM) {
9   const DataLayout &DL = M.getDataLayout();
10   auto &TLI = AM.getResult<TargetLibraryAnalysis>(M);
11   if (!runIPSCCP(M, DL, &TLI))
12     return PreservedAnalyses::all();
13   return PreservedAnalyses::none();
14 }
15 
16 namespace {
17 
18 //===--------------------------------------------------------------------===//
19 //
20 /// IPSCCP Class - This class implements interprocedural Sparse Conditional
21 /// Constant Propagation.
22 ///
23 class IPSCCPLegacyPass : public ModulePass {
24 public:
25   static char ID;
26 
IPSCCPLegacyPass()27   IPSCCPLegacyPass() : ModulePass(ID) {
28     initializeIPSCCPLegacyPassPass(*PassRegistry::getPassRegistry());
29   }
30 
runOnModule(Module & M)31   bool runOnModule(Module &M) override {
32     if (skipModule(M))
33       return false;
34     const DataLayout &DL = M.getDataLayout();
35     const TargetLibraryInfo *TLI =
36         &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
37     return runIPSCCP(M, DL, TLI);
38   }
39 
getAnalysisUsage(AnalysisUsage & AU) const40   void getAnalysisUsage(AnalysisUsage &AU) const override {
41     AU.addRequired<TargetLibraryInfoWrapperPass>();
42   }
43 };
44 
45 } // end anonymous namespace
46 
47 char IPSCCPLegacyPass::ID = 0;
48 
49 INITIALIZE_PASS_BEGIN(IPSCCPLegacyPass, "ipsccp",
50                       "Interprocedural Sparse Conditional Constant Propagation",
51                       false, false)
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)52 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
53 INITIALIZE_PASS_END(IPSCCPLegacyPass, "ipsccp",
54                     "Interprocedural Sparse Conditional Constant Propagation",
55                     false, false)
56 
57 // createIPSCCPPass - This is the public interface to this file.
58 ModulePass *llvm::createIPSCCPPass() { return new IPSCCPLegacyPass(); }
59