LLVM  10.0.0svn
Go to the documentation of this file.
5 #include "llvm/Transforms/IPO.h"
8 using namespace llvm;
11  const DataLayout &DL = M.getDataLayout();
12  auto &TLI = AM.getResult<TargetLibraryAnalysis>(M);
13  auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
14  auto getAnalysis = [&FAM](Function &F) -> AnalysisResultsForFn {
15  DominatorTree &DT = FAM.getResult<DominatorTreeAnalysis>(F);
16  return {
17  std::make_unique<PredicateInfo>(F, DT, FAM.getResult<AssumptionAnalysis>(F)),
18  &DT, FAM.getCachedResult<PostDominatorTreeAnalysis>(F)};
19  };
21  if (!runIPSCCP(M, DL, &TLI, getAnalysis))
22  return PreservedAnalyses::all();
28  return PA;
29 }
31 namespace {
33 //===--------------------------------------------------------------------===//
34 //
35 /// IPSCCP Class - This class implements interprocedural Sparse Conditional
36 /// Constant Propagation.
37 ///
38 class IPSCCPLegacyPass : public ModulePass {
39 public:
40  static char ID;
42  IPSCCPLegacyPass() : ModulePass(ID) {
44  }
46  bool runOnModule(Module &M) override {
47  if (skipModule(M))
48  return false;
49  const DataLayout &DL = M.getDataLayout();
50  const TargetLibraryInfo *TLI =
51  &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
53  auto getAnalysis = [this](Function &F) -> AnalysisResultsForFn {
54  DominatorTree &DT =
55  this->getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
56  return {
57  std::make_unique<PredicateInfo>(
58  F, DT,
59  this->getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
60  F)),
61  nullptr, // We cannot preserve the DT or PDT with the legacy pass
62  nullptr}; // manager, so set them to nullptr.
63  };
65  return runIPSCCP(M, DL, TLI, getAnalysis);
66  }
68  void getAnalysisUsage(AnalysisUsage &AU) const override {
72  }
73 };
75 } // end anonymous namespace
77 char IPSCCPLegacyPass::ID = 0;
80  "Interprocedural Sparse Conditional Constant Propagation",
81  false, false)
85 INITIALIZE_PASS_END(IPSCCPLegacyPass, "ipsccp",
86  "Interprocedural Sparse Conditional Constant Propagation",
87  false, false)
89 // createIPSCCPPass - This is the public interface to this file.
90 ModulePass *llvm::createIPSCCPPass() { return new IPSCCPLegacyPass(); }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Interprocedural Sparse Conditional Constant Propagation
Definition: SCCP.cpp:85
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:776
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Definition: SCCP.cpp:85
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
An immutable pass that tracks lazily created AssumptionCache objects.
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions...
Definition: SCCP.cpp:90
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:230
AnalysisUsage & addRequired()
Definition: PassSupport.h:50
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:369
Helper struct for bundling up the analysis results per function for IPSCCP.
Definition: SCCP.h:42
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:144
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
This is an important base class in LLVM.
Definition: Constant.h:41
Represent the analysis usage information of a pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:159
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
A function analysis which provides an AssumptionCache.
INITIALIZE_PASS_BEGIN(IPSCCPLegacyPass, "ipsccp", "Interprocedural Sparse Conditional Constant Propagation", false, false) INITIALIZE_PASS_END(IPSCCPLegacyPass
Analysis pass which computes a PostDominatorTree.
Provides information about what library functions are available for the current target.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: SCCP.cpp:10
void initializeIPSCCPLegacyPassPass(PassRegistry &)
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:224
void preserve()
Mark an analysis as preserved.
Definition: PassManager.h:174
Analysis pass providing the TargetLibraryInfo.
bool runIPSCCP(Module &M, const DataLayout &DL, const TargetLibraryInfo *TLI, function_ref< AnalysisResultsForFn(Function &)> getAnalysis)
Definition: SCCP.cpp:2002
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:259
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:1044